mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-23 23:03:51 -06:00
update mapvote
This commit is contained in:
parent
dd9e24aa02
commit
0d6e8226cd
23
mapvote.js
23
mapvote.js
@ -17,7 +17,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
static get defaultEnabled() {
|
static get defaultEnabled() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
layer
|
|
||||||
static get optionsSpecification() {
|
static get optionsSpecification() {
|
||||||
return {
|
return {
|
||||||
...DiscordBasePlugin.optionsSpecification,
|
...DiscordBasePlugin.optionsSpecification,
|
||||||
@ -86,6 +86,11 @@ layer
|
|||||||
description: "Select Whitelist mode or Blacklist mode",
|
description: "Select Whitelist mode or Blacklist mode",
|
||||||
default: "blacklist"
|
default: "blacklist"
|
||||||
},
|
},
|
||||||
|
modWhiteList: {
|
||||||
|
required: false,
|
||||||
|
description: "select mods (short ID) to whitelist for voting",
|
||||||
|
default: ["Vanilla"]
|
||||||
|
},
|
||||||
layerLevelWhitelist: {
|
layerLevelWhitelist: {
|
||||||
required: false,
|
required: false,
|
||||||
description: 'random layer list will include only the whitelisted layers or levels. (acceptable formats: Gorodok/Gorodok_RAAS/Gorodok_AAS_v1)',
|
description: 'random layer list will include only the whitelisted layers or levels. (acceptable formats: Gorodok/Gorodok_RAAS/Gorodok_AAS_v1)',
|
||||||
@ -348,6 +353,10 @@ layer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getModLayers(){
|
||||||
|
return Layers.layers.filter((l) => this.options.modWhiteList.find((e) => e === l.modName));
|
||||||
|
}
|
||||||
|
|
||||||
setSeedingMode(isNewGameEvent = false) {
|
setSeedingMode(isNewGameEvent = false) {
|
||||||
this.options.seedingGameMode = this.options.seedingGameMode.toLowerCase();
|
this.options.seedingGameMode = this.options.seedingGameMode.toLowerCase();
|
||||||
// this.msgBroadcast("[MapVote] Seeding mode active")
|
// this.msgBroadcast("[MapVote] Seeding mode active")
|
||||||
@ -358,7 +367,8 @@ layer
|
|||||||
const maxSeedingModePlayerCount = Math.max(this.options.nextLayerSeedingModePlayerCount, this.options.instantSeedingModePlayerCount);
|
const maxSeedingModePlayerCount = Math.max(this.options.nextLayerSeedingModePlayerCount, this.options.instantSeedingModePlayerCount);
|
||||||
if (this.server.players.length >= 1 && this.server.players.length < maxSeedingModePlayerCount) {
|
if (this.server.players.length >= 1 && this.server.players.length < maxSeedingModePlayerCount) {
|
||||||
if (+(new Date()) - +this.server.layerHistory[0].time > 30 * 1000) {
|
if (+(new Date()) - +this.server.layerHistory[0].time > 30 * 1000) {
|
||||||
const seedingMaps = Layers.layers.filter((l) => l.layerid && l.gamemode.toLowerCase() === this.options.seedingGameMode && !this.options.layerLevelBlacklist.find((fl) => l.layerid.toLowerCase().startsWith(fl.toLowerCase())))
|
const filterMaps = this.getModLayers();
|
||||||
|
const seedingMaps = filterMaps.filter((l) => l.layerid && l.gamemode.toLowerCase() === this.options.seedingGameMode && !this.options.layerLevelBlacklist.find((fl) => l.layerid.toLowerCase().startsWith(fl.toLowerCase())))
|
||||||
this.verbose(1, seedingMaps);
|
this.verbose(1, seedingMaps);
|
||||||
|
|
||||||
const rndMap = randomElement(seedingMaps);
|
const rndMap = randomElement(seedingMaps);
|
||||||
@ -544,7 +554,8 @@ layer
|
|||||||
}
|
}
|
||||||
|
|
||||||
matchLayers(builtString) {
|
matchLayers(builtString) {
|
||||||
return Layers.layers.filter(element => element.layerid.includes(builtString));
|
const modLayers = this.getModLayers();
|
||||||
|
return modLayers.filter(element => element.layerid.includes(builtString));
|
||||||
}
|
}
|
||||||
|
|
||||||
getMode(nomination, currentMode) {
|
getMode(nomination, currentMode) {
|
||||||
@ -595,7 +606,8 @@ layer
|
|||||||
this.factionStrings = [];
|
this.factionStrings = [];
|
||||||
const rnd_layers = [];
|
const rnd_layers = [];
|
||||||
|
|
||||||
const sanitizedLayers = Layers.layers.filter((l) => l.layerid && l.map);
|
const modLayers = this.getModLayers();
|
||||||
|
const sanitizedLayers = modLayers.filter((l) => l.layerid && l.map);
|
||||||
const maxOptions = this.options.showRerollOption ? 20 : 21;
|
const maxOptions = this.options.showRerollOption ? 20 : 21;
|
||||||
const optionAmount = Math.min(maxOptions, this.options.entriesAmount);
|
const optionAmount = Math.min(maxOptions, this.options.entriesAmount);
|
||||||
|
|
||||||
@ -939,7 +951,8 @@ layer
|
|||||||
|
|
||||||
getLayersFromStringId(stringid) {
|
getLayersFromStringId(stringid) {
|
||||||
const cls = stringid.toLowerCase().split('_');
|
const cls = stringid.toLowerCase().split('_');
|
||||||
const ret = Layers.layers.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] || parseInt(l.version.toLowerCase().replace(/v/gi, '')) == parseInt(cls[2].replace(/v/gi, '')))));
|
const modLayers = this.getModLayers();
|
||||||
|
const ret = modLayers.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] || parseInt(l.version.toLowerCase().replace(/v/gi, '')) == parseInt(cls[2].replace(/v/gi, '')))));
|
||||||
// this.verbose(1,"layers from string",stringid,cls,ret)
|
// this.verbose(1,"layers from string",stringid,cls,ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user