From 5ef6ba3dbbd9410c5b7c4529fb553faa4ff93332 Mon Sep 17 00:00:00 2001 From: Davide Fantino <80767709+fantinodavide@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:45:06 +0100 Subject: [PATCH] fix: seeding mode next layer --- mapvote.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/mapvote.js b/mapvote.js index 32d126b..5cb90db 100644 --- a/mapvote.js +++ b/mapvote.js @@ -321,17 +321,19 @@ export default class MapVote extends DiscordBasePlugin { } } else this.verbose(1, "Bad data (currentLayer). Seeding mode for current layer skipped to prevent errors."); - /*if (this.server.nextLayer) { - const nextMaps = seedingMaps.filter((l) => (!this.server.currentLayer || l.layerid != this.server.currentLayer.layerid)) - let rndMap2; - do rndMap2 = randomElement(nextMaps); - while (rndMap2.layerid == rndMap.layerid) + if (+this.layerHistory[ 0 ].time - +(new Date()) > 30 * 1000) { + if (this.server.nextLayer) { + const nextMaps = seedingMaps.filter((l) => (!this.server.currentLayer || l.layerid != this.server.currentLayer.layerid)) + let rndMap2; + do rndMap2 = randomElement(nextMaps); + while (rndMap2.layerid == rndMap.layerid) - if (isNewGameEvent && this.server.players.length < 20 && this.server.nextLayer.gamemode.toLowerCase() != "seed") { - const newNextMap = rndMap2.layerid; - this.server.rcon.execute(`AdminSetNextLayer ${newNextMap} `); - } - } else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors.");*/ + if (this.server.players.length < 20 && this.server.nextLayer.gamemode.toLowerCase() != "seed") { + const newNextMap = rndMap2.layerid; + this.server.rcon.execute(`AdminSetNextLayer ${newNextMap} `); + } + } else this.verbose(1, "Bad data (nextLayer). Seeding mode for next layer skipped to prevent errors."); + } } else this.verbose(1, `Player count doesn't allow seeding mode (${this.server.players.length}/20)`); } else this.verbose(1, "Seeding mode disabled in config"); @@ -625,9 +627,11 @@ export default class MapVote extends DiscordBasePlugin { this.nominations[ 0 ] = "Reroll vote list with random options" this.tallies[ 0 ] = 0; this.factionStrings[ 0 ] = ""; - } + if (this.nominations[ 1 ] != "") + this.server.rcon.execute(`AdminSetNextLayer ${this.nominations[ 1 ]} `); + function getTranslation(layer) { if (translations[ layer.faction ]) return translations[ layer.faction ] else if (layer.faction) { @@ -998,7 +1002,7 @@ export default class MapVote extends DiscordBasePlugin { this.verbose(1, 'Layer list updated'); } - + formatChoice(choiceIndex, mapString, currentVotes, hideVoteCount) { return `${choiceIndex}➤ ${mapString} ` + (!hideVoteCount ? `(${currentVotes})` : "");