fix: vote end broadcast

This commit is contained in:
Davide Fantino 2023-03-18 01:22:12 +01:00
parent 09d117d86e
commit 20a2649b4a

View File

@ -703,13 +703,11 @@ export default class MapVote extends DiscordBasePlugin {
async endVotingGently(steamID = null) { async endVotingGently(steamID = null) {
if (!this.votingEnabled) return; if (!this.votingEnabled) return;
this.endVoting();
if (steamID) await this.warn(steamID, "Voting terminated!");
const winningLayerId = this.updateNextMap(); const winningLayerId = this.updateNextMap();
if (!winningLayerId) return; if (!winningLayerId) {
this.verbose(1, 'No winning layer available', winningLayerId)
return;
}
const winnerLayer = Layers.layers.find((l) => l.layerid == winningLayerId); const winnerLayer = Layers.layers.find((l) => l.layerid == winningLayerId);
const fancyWinner = this.formatFancyLayer(winnerLayer); const fancyWinner = this.formatFancyLayer(winnerLayer);
@ -762,6 +760,9 @@ export default class MapVote extends DiscordBasePlugin {
}); });
} }
this.endVoting();
if (steamID) await this.warn(steamID, "Voting terminated!");
return true; return true;
} }
@ -1012,15 +1013,16 @@ export default class MapVote extends DiscordBasePlugin {
const score = this.tallies[ choice ]; const score = this.tallies[ choice ];
if (score >= this.options.minimumVotesToAcceptResult) { if (score >= this.options.minimumVotesToAcceptResult) {
if (score < highestScore) if (score < highestScore)
continue; continue;
else if (score > highestScore) { else if (score > highestScore) {
highestScore = score; highestScore = score;
ties.length = 0; ties.length = 0;
ties.push(choice); ties.push(choice);
} }
else // equal else // equal
ties.push(choice); ties.push(choice);
} }
this.verbose(1, 'Ties', ties, ties.map(i => this.nominations[ i ]))
} }
return ties.map(i => this.nominations[ i ]); return ties.map(i => this.nominations[ i ]);