mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-24 00:13:52 -06:00
Merge pull request #9 from komatooo/master
Add minimum votes to accept result.
This commit is contained in:
commit
dfe531cbd2
10
README.MD
10
README.MD
@ -246,6 +246,15 @@ Array of timeframes that allows to override options based on local time. See exa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
#### minimumVotesToAcceptResult
|
||||||
|
###### Description
|
||||||
|
Minimum votes per map to accept result.
|
||||||
|
|
||||||
|
Can be used to prevent situation when insignificant number of players decide what map should be next, but most still wants to play map according to rotation.
|
||||||
|
###### Default
|
||||||
|
```json
|
||||||
|
1
|
||||||
|
```
|
||||||
### Example configuration
|
### Example configuration
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -278,6 +287,7 @@ Array of timeframes that allows to override options based on local time. See exa
|
|||||||
"channelID": "112233445566778899",
|
"channelID": "112233445566778899",
|
||||||
"persistentDataFile": "",
|
"persistentDataFile": "",
|
||||||
"timezone": 2,
|
"timezone": 2,
|
||||||
|
"minimumVotesToAcceptResult": 1,
|
||||||
"timeFrames": [
|
"timeFrames": [
|
||||||
{
|
{
|
||||||
"name": "follow layer rotation list",
|
"name": "follow layer rotation list",
|
||||||
|
24
mapvote.js
24
mapvote.js
@ -170,6 +170,11 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
required: false,
|
required: false,
|
||||||
description: 'Array of timeframes to override options',
|
description: 'Array of timeframes to override options',
|
||||||
default: []
|
default: []
|
||||||
|
},
|
||||||
|
minimumVotesToAcceptResult: {
|
||||||
|
required: false,
|
||||||
|
description: "Minimum votes per map to accept result.",
|
||||||
|
default: 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -301,7 +306,6 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setSeedingMode(isNewGameEvent = false) {
|
setSeedingMode(isNewGameEvent = false) {
|
||||||
// setTimeout(()=>{this.msgDirect('76561198419229279',"MV\ntest\ntest")},1000)
|
|
||||||
// this.msgBroadcast("[MapVote] Seeding mode active")
|
// this.msgBroadcast("[MapVote] Seeding mode active")
|
||||||
const baseDataExist = this && this.options && this.server && this.server.players;
|
const baseDataExist = this && this.options && this.server && this.server.players;
|
||||||
if (baseDataExist) {
|
if (baseDataExist) {
|
||||||
@ -970,15 +974,17 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
let highestScore = -Infinity;
|
let highestScore = -Infinity;
|
||||||
for (let choice in this.tallies) {
|
for (let choice in this.tallies) {
|
||||||
const score = this.tallies[ choice ];
|
const score = this.tallies[ choice ];
|
||||||
if (score < highestScore)
|
if (score >= this.options.minimumVotesToAcceptResult) {
|
||||||
continue;
|
if (score < highestScore)
|
||||||
else if (score > highestScore) {
|
continue;
|
||||||
highestScore = score;
|
else if (score > highestScore) {
|
||||||
ties.length = 0;
|
highestScore = score;
|
||||||
ties.push(choice);
|
ties.length = 0;
|
||||||
|
ties.push(choice);
|
||||||
|
}
|
||||||
|
else // equal
|
||||||
|
ties.push(choice);
|
||||||
}
|
}
|
||||||
else // equal
|
|
||||||
ties.push(choice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ties.map(i => this.nominations[ i ]);
|
return ties.map(i => this.nominations[ i ]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user