From 4eae81f5db38d7ef68ccf507179a9015ccaed751 Mon Sep 17 00:00:00 2001 From: komatoo Date: Thu, 12 Jan 2023 12:06:06 +0200 Subject: [PATCH 1/2] Add minimum votes to accept result configuration --- mapvote.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/mapvote.js b/mapvote.js index d2117c8..c0b6704 100644 --- a/mapvote.js +++ b/mapvote.js @@ -150,6 +150,11 @@ export default class MapVote extends DiscordBasePlugin { required: false, description: 'Array of timeframes to override options', default: [] + }, + minimumVotesToAcceptResult: { + required: false, + description: "Minimum votes per map to accept result.", + default: 1 } }; } @@ -278,7 +283,6 @@ export default class MapVote extends DiscordBasePlugin { } } setSeedingMode(isNewGameEvent = false) { - // setTimeout(()=>{this.msgDirect('76561198419229279',"MV\ntest\ntest")},1000) // this.msgBroadcast("[MapVote] Seeding mode active") const baseDataExist = this && this.options && this.server && this.server.players; if (baseDataExist) { @@ -853,15 +857,17 @@ export default class MapVote extends DiscordBasePlugin { let highestScore = -Infinity; for (let choice in this.tallies) { const score = this.tallies[ choice ]; - if (score < highestScore) - continue; - else if (score > highestScore) { - highestScore = score; - ties.length = 0; - ties.push(choice); + if (score >= this.options.minimumVotesToAcceptResult) { + if (score < highestScore) + continue; + else if (score > highestScore) { + highestScore = score; + ties.length = 0; + ties.push(choice); + } + else // equal + ties.push(choice); } - else // equal - ties.push(choice); } return ties.map(i => this.nominations[ i ]); From f54ae8f46bdc5f074ad13f225b1c2a2c1cd8261f Mon Sep 17 00:00:00 2001 From: komatoo Date: Wed, 15 Feb 2023 00:49:51 +0200 Subject: [PATCH 2/2] Update documentation by minimumVotesToAcceptResult --- README.MD | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.MD b/README.MD index 57b7ff6..00934d6 100644 --- a/README.MD +++ b/README.MD @@ -239,6 +239,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 ```json { @@ -270,6 +279,7 @@ Array of timeframes that allows to override options based on local time. See exa "channelID": "112233445566778899", "persistentDataFile": "", "timezone": 2, + "minimumVotesToAcceptResult": 1, "timeFrames": [ { "name": "follow layer rotation list",