fixed allowedMapDuplicates

This commit is contained in:
Davide Fantino 2022-10-04 01:02:51 +02:00
parent a09f6ed882
commit f6c9ba104d

View File

@ -468,7 +468,7 @@ export default class MapVote extends DiscordBasePlugin {
);
for (let i = 1; i <= maxOptions; i++) {
let l, maxtries = 10;
do l = randomElement(all_layers); while ((rnd_layers.find(lf => lf.layerid == l.layerid) || rnd_layers.filter(lf => lf.map.name == l.map.name).length > this.options.allowedMapDuplicates) && --maxtries >= 0)
do l = randomElement(all_layers); while ((rnd_layers.find(lf => lf.layerid == l.layerid) || rnd_layers.filter(lf => lf.map.name == l.map.name).length > (this.options.allowedMapDuplicates-1)) && --maxtries >= 0)
if (maxtries > 0) {
rnd_layers.push(l);
this.nominations[ i ] = l.layerid
@ -492,8 +492,8 @@ export default class MapVote extends DiscordBasePlugin {
for (let cl of cmdLayers) {
const cls = cl.split('_');
const fLayers = sanitizedLayers.filter((l) => ((cls[ 0 ] == "*" || l.layerid.toLowerCase().startsWith(cls[ 0 ])) && (l.gamemode.toLowerCase().startsWith(cls[ 1 ]) || (!cls[ 1 ] && [ 'RAAS', 'AAS', 'INVASION' ].includes(l.gamemode.toUpperCase()))) && (!cls[ 2 ] || l.version.toLowerCase().startsWith("v" + cls[ 2 ].replace(/v/gi, '')))));
let l;
do l = randomElement(fLayers); while (rnd_layers.includes(l))
let l, maxtries = 10;
do l = randomElement(fLayers); while ((rnd_layers.filter(lf => lf.map.name == l.map.name).length > (this.options.allowedMapDuplicates-1)) && --maxtries >= 0)
if (l) {
rnd_layers.push(l);
this.nominations[ i ] = l.layerid