From 4eae81f5db38d7ef68ccf507179a9015ccaed751 Mon Sep 17 00:00:00 2001 From: komatoo Date: Thu, 12 Jan 2023 12:06:06 +0200 Subject: [PATCH] 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 ]);