mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-23 20:43:52 -06:00
change how nominations filtering works and how layer blacklist and whitelist are parsed
This commit is contained in:
parent
0a69c8d712
commit
e770b5c4af
259
mapvote.js
259
mapvote.js
@ -86,11 +86,6 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
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)',
|
||||||
@ -111,11 +106,6 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
description: "factions to exclude in map vote. ( ex: ['CAF'] )",
|
description: "factions to exclude in map vote. ( ex: ['CAF'] )",
|
||||||
default: []
|
default: []
|
||||||
},
|
},
|
||||||
minRaasEntries: {
|
|
||||||
required: false,
|
|
||||||
description: 'Minimum amount of RAAS layers in the vote list.',
|
|
||||||
default: 2
|
|
||||||
},
|
|
||||||
minGamemodeEntries: {
|
minGamemodeEntries: {
|
||||||
required: false,
|
required: false,
|
||||||
description: 'Minimum amount layers in the vote list per gamemode.',
|
description: 'Minimum amount layers in the vote list per gamemode.',
|
||||||
@ -353,8 +343,59 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getModLayers(){
|
getTranslation(t) {
|
||||||
return Layers.layers//.filter((l) => this.options.modWhitelist.find((e) => e === l.modName));
|
const translations = {
|
||||||
|
'United States Army': "USA",
|
||||||
|
'United States Marine Corps': "USMC",
|
||||||
|
'Russian Ground Forces': "RGF",
|
||||||
|
'British Army': "BAF",
|
||||||
|
'British Armed Forces': "BAF",
|
||||||
|
'Canadian Army': "CAF",
|
||||||
|
'Australian Defence Force': "ADF",
|
||||||
|
'Irregular Militia Forces': "IMF",
|
||||||
|
'Middle Eastern Alliance': "MEA",
|
||||||
|
'Insurgent Forces': "INS",
|
||||||
|
'Unknown': "Unk"
|
||||||
|
}
|
||||||
|
if (translations[t.faction]) return translations[t.faction]
|
||||||
|
else {
|
||||||
|
const f = t.faction.split(' ');
|
||||||
|
if(f.length > 1) {
|
||||||
|
let fTag = "";
|
||||||
|
f.forEach((e) => {
|
||||||
|
fTag += e[0]
|
||||||
|
});
|
||||||
|
return fTag.toUpperCase();
|
||||||
|
} else if (t.faction.length <= 5) return t.faction;
|
||||||
|
else return 'Unk'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
layerfilterCorrectLayers(layers){
|
||||||
|
return layers.filter((l) => l.layerid && l.map);
|
||||||
|
}
|
||||||
|
|
||||||
|
layerfilterWlist(layers){
|
||||||
|
if(this.options.layerFilteringMode.toLowerCase() === "whitelist"){
|
||||||
|
const rawwl = layers.filter((l) => this.options.layerLevelWhitelist.find((fl) => this.getLayersFromStringId(fl).map((e => e.layerid).includes(l.layerid))));
|
||||||
|
if(this.options.applyBlacklistToWhitelist) return rawwl.filter((l) => !(this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))));
|
||||||
|
else return rawwl;
|
||||||
|
} else {
|
||||||
|
return layers.filter((l) => !(this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
layerfilterFactionBlacklist(layers){
|
||||||
|
return layers.filter((l) => !(this.options.factionsBlacklist.find((f) => [this.getTranslation(l.teams[0]), this.getTranslation(l.teams[1])].includes(f))));
|
||||||
|
}
|
||||||
|
|
||||||
|
layerfilterGamemodeWlist(layers){
|
||||||
|
return layers.filter((l) => this.options.gamemodeWhitelist.includes(l.gamemode.toUpperCase()));
|
||||||
|
}
|
||||||
|
|
||||||
|
layerfilterPrevMaps(layers){
|
||||||
|
const recentlyPlayedMaps = this.objArrToValArr(this.server.layerHistory.slice(0, this.options.numberRecentMapsToExlude), "layer", "map", "name");
|
||||||
|
return layers.filter((l) => !([this.server.currentLayer ? this.server.currentLayer.map.name : null, ...recentlyPlayedMaps].includes(l.map.name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
setSeedingMode(isNewGameEvent = false) {
|
setSeedingMode(isNewGameEvent = false) {
|
||||||
@ -367,8 +408,8 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
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 filterMaps = this.getModLayers();
|
const filterMaps = this.layerfilterWlist(this.layerfilterCorrectLayers(Layers.layers));
|
||||||
const seedingMaps = filterMaps.filter((l) => l.layerid && l.gamemode.toLowerCase() === this.options.seedingGameMode && !this.options.layerLevelBlacklist.find((fl) => l.layerid.toLowerCase().startsWith(fl.toLowerCase())))
|
const seedingMaps = filterMaps.filter(l => l.gamemode.toLowerCase() === this.options.seedingGameMode);
|
||||||
this.verbose(1, seedingMaps);
|
this.verbose(1, seedingMaps);
|
||||||
|
|
||||||
const rndMap = randomElement(seedingMaps);
|
const rndMap = randomElement(seedingMaps);
|
||||||
@ -554,60 +595,22 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
matchLayers(builtString) {
|
matchLayers(builtString) {
|
||||||
const modLayers = this.getModLayers();
|
const modLayers = this.layerfilterCorrectLayers(Layers.layers);
|
||||||
return modLayers.filter(element => element.layerid.includes(builtString));
|
return modLayers.filter(element => element.layerid.includes(builtString));
|
||||||
}
|
}
|
||||||
|
|
||||||
getMode(nomination, currentMode) {
|
|
||||||
const mapName = nomination.map;
|
|
||||||
let modes = nomination.modes;
|
|
||||||
let mode = modes[0];
|
|
||||||
|
|
||||||
if (mode === "Any")
|
|
||||||
modes = this.voteRules.modes;
|
|
||||||
|
|
||||||
if (this.voteRules.mode_repeat_blacklist.includes(currentMode)) {
|
|
||||||
modes = modes.filter(mode => !mode.includes(currentMode));
|
|
||||||
}
|
|
||||||
|
|
||||||
while (modes.length > 0) {
|
|
||||||
mode = randomElement(modes);
|
|
||||||
modes = modes.filter(elem => elem !== mode);
|
|
||||||
if (this.matchLayers(`${mapName}_${mode}`).length > 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: right now if version is set to "Any" no caf layers will be selected
|
|
||||||
populateNominations(steamid = null, cmdLayers = [], bypassRaasFilter = false, tries = 10) // gets nomination strings from layer options
|
populateNominations(steamid = null, cmdLayers = [], bypassRaasFilter = false, tries = 10) // gets nomination strings from layer options
|
||||||
{
|
{
|
||||||
this.options.gamemodeWhitelist.forEach((e, k, a) => a[k] = e.toUpperCase());
|
this.options.gamemodeWhitelist.forEach((e, k, a) => a[k] = e.toUpperCase());
|
||||||
// this.nominations.push(builtLayerString);
|
// this.nominations.push(builtLayerString);
|
||||||
// this.tallies.push(0);
|
// this.tallies.push(0);
|
||||||
|
|
||||||
const translations = {
|
|
||||||
'United States Army': "USA",
|
|
||||||
'United States Marine Corps': "USMC",
|
|
||||||
'Russian Ground Forces': "RGF",
|
|
||||||
'British Army': "BAF",
|
|
||||||
'British Armed Forces': "BAF",
|
|
||||||
'Canadian Army': "CAF",
|
|
||||||
'Australian Defence Force': "ADF",
|
|
||||||
'Irregular Militia Forces': "IMF",
|
|
||||||
'Middle Eastern Alliance': "MEA",
|
|
||||||
'Insurgent Forces': "INS",
|
|
||||||
'Unknown': "Unk"
|
|
||||||
}
|
|
||||||
|
|
||||||
this.nominations = [];
|
this.nominations = [];
|
||||||
this.tallies = [];
|
this.tallies = [];
|
||||||
this.factionStrings = [];
|
this.factionStrings = [];
|
||||||
const rnd_layers = [];
|
const rnd_layers = [];
|
||||||
|
|
||||||
const modLayers = this.getModLayers();
|
const sanitizedLayers = this.layerfilterCorrectLayers(Layers.layers);
|
||||||
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);
|
||||||
|
|
||||||
@ -625,86 +628,39 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false && isRandomVote) {
|
|
||||||
// this.populateNominations(steamid,cmdLayers,bypassRaasFilter,)
|
|
||||||
|
|
||||||
|
|
||||||
const all_layers = sanitizedLayers.filter((l) =>
|
|
||||||
this.options.gamemodeWhitelist.includes(l.gamemode.toUpperCase()) &&
|
|
||||||
![this.server.currentLayer ? this.server.currentLayer.map.name : null, ...recentlyPlayedMaps].includes(l.map.name) &&
|
|
||||||
(
|
|
||||||
(this.options.layerFilteringMode.toLowerCase() === "blacklist" && !this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))) ||
|
|
||||||
(
|
|
||||||
this.options.layerFilteringMode.toLowerCase() === "whitelist"
|
|
||||||
&& this.options.layerLevelWhitelist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))
|
|
||||||
&& !(this.options.applyBlacklistToWhitelist && this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid)))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
&& !(this.options.factionsBlacklist.find((f) => [getTranslation(l.teams[0]), getTranslation(l.teams[1])].includes(f)))
|
|
||||||
);
|
|
||||||
for (let i = 1; i <= Math.min(optionAmount, all_layers.length); i++) {
|
|
||||||
const needMoreRAAS = !bypassRaasFilter && rnd_layers.filter((l) => l.gamemode.toUpperCase() === 'RAAS').length < this.options.minRaasEntries;
|
|
||||||
let l;
|
|
||||||
let maxtries = 20;
|
|
||||||
do l = randomElement(needMoreRAAS ? all_layers.filter((l) => l.gamemode.toLowerCase() === "raas") : all_layers);
|
|
||||||
while ((rnd_layers.find(lf => lf.layerid === l.layerid) || rnd_layers.filter(lf => lf.map.name === l.map.name).length > (this.options.allowedSameMapEntries - 1)) && --maxtries >= 0)
|
|
||||||
if (maxtries > 0 && l) {
|
|
||||||
// this.verbose(1,"Testing layer",l, maxtries);
|
|
||||||
rnd_layers.push(l);
|
|
||||||
this.nominations[i] = l.layerid
|
|
||||||
this.tallies[i] = 0;
|
|
||||||
this.factionStrings[i] = getTranslation(l.teams[0]) + "-" + getTranslation(l.teams[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if (!bypassRaasFilter && this.options.gamemodeWhitelist.includes("RAAS") && rnd_layers.filter((l) => l.gamemode === 'RAAS').length < Math.floor(maxOptions / 2)) this.populateNominations();
|
|
||||||
if (this.nominations.length === 0) {
|
|
||||||
if (--tries > 0) this.populateNominations(steamid, cmdLayers, bypassRaasFilter, tries);
|
|
||||||
else this.warn("")
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (cmdLayers.length === 1) while (cmdLayers.length < optionAmount) cmdLayers.push(cmdLayers[0])
|
if (cmdLayers.length === 1) while (cmdLayers.length < optionAmount) cmdLayers.push(cmdLayers[0])
|
||||||
|
|
||||||
if (cmdLayers.length <= maxOptions) {
|
if (cmdLayers.length <= maxOptions) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (const cl of cmdLayers) {
|
for (const cl of cmdLayers) {
|
||||||
const cls = cl.toLowerCase().split('_');
|
const cls = cl.toLowerCase().split('_'); //cls[0] = mod, cls[1] = map, cls[2] = gamemode, cls[3] = version, cls[4] = faction
|
||||||
const fLayers = sanitizedLayers.filter((l) => (
|
const whitefilt = this.layerfilterWlist(sanitizedLayers);
|
||||||
rnd_layers.filter(l2 => l2.map.name === l.map.name).length < this.options.allowedSameMapEntries &&
|
const modfilt = whitefilt.filter((l) => (!cls[0] || (cls[0] === "*" || l.mod.startsWith(cls[0].toUpperCase()))));
|
||||||
(![this.server.currentLayer ? this.server.currentLayer.map.name : null, ...recentlyPlayedMaps].includes(l.map.name) || cls[2]) &&
|
const mapfilt = modfilt.filter((l) => (!cls[1] || (cls[1] === "*" || l.map.name.toLowerCase().startsWith(cls[1].toLowerCase()))));
|
||||||
(
|
const gamemodefilt = mapfilt.filter(l => (!cls[2] || (cls[2] === "*" || l.gamemode.toLowerCase().startsWith(cls[2].toLowerCase()))));
|
||||||
(
|
const versionfilt = gamemodefilt.filter(l => (!cls[3] || (cls[3] === "*" || l.version.toLowerCase().startsWith("v" + cls[3].replace(/v/gi, '')))));
|
||||||
(this.options.layerFilteringMode.toLowerCase() === "blacklist" && !this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))) ||
|
const factionfilt = versionfilt.filter(l => (!cls[4] || (cls[4] === "*" || [this.getTranslation(l.teams[0]), this.getTranslation(l.teams[1])].includes(cls[4].toUpperCase()))));
|
||||||
(
|
|
||||||
this.options.layerFilteringMode.toLowerCase() === "whitelist"
|
const factionblack = this.layerfilterFactionBlacklist(factionfilt);
|
||||||
&& this.options.layerLevelWhitelist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))
|
const gamemodewhite = this.layerfilterGamemodeWlist(factionblack);
|
||||||
&& !(this.options.applyBlacklistToWhitelist && this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid)))
|
const samemapfilt = gamemodewhite.filter((l) => rnd_layers.filter(l2 => l2.map.name === l.map.name).length < this.options.allowedSameMapEntries);
|
||||||
)
|
const prevmapfilt = this.layerfilterPrevMaps(samemapfilt);
|
||||||
) || cls[2]
|
if (factionfilt.length === 0) continue;
|
||||||
)
|
|
||||||
&& (
|
|
||||||
(cls[0] === "*" || l.layerid.toLowerCase().startsWith(cls[0]))
|
|
||||||
|| (cls[0].toLowerCase().startsWith('f:') && [getTranslation(l.teams[0]), getTranslation(l.teams[1])].includes(cls[0].substring(2).toUpperCase()))
|
|
||||||
)
|
|
||||||
&& (l.gamemode.toLowerCase().startsWith(cls[1]) || (!cls[1] && this.options.gamemodeWhitelist.includes(l.gamemode.toUpperCase())))
|
|
||||||
&& (!cls[2] || l.version.toLowerCase().startsWith("v" + cls[2].replace(/v/gi, '')))
|
|
||||||
// && !(this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f)))
|
|
||||||
&& (cls[2] || !(
|
|
||||||
this.options.layerLevelBlacklist.find((fl) => this.getLayersFromStringId(fl).map((e) => e.layerid).includes(l.layerid))
|
|
||||||
|| this.options.factionsBlacklist.find((f) => [getTranslation(l.teams[0]), getTranslation(l.teams[1])].includes(f))
|
|
||||||
))
|
|
||||||
));
|
|
||||||
if (fLayers.length === 0) continue;
|
|
||||||
// this.verbose(1, 'fLayers', fLayers.map(l => l.layerid));
|
// this.verbose(1, 'fLayers', fLayers.map(l => l.layerid));
|
||||||
// this.verbose(1, 'rnd_layers', rnd_layers.map(l => l.layerid));
|
// this.verbose(1, 'rnd_layers', rnd_layers.map(l => l.layerid));
|
||||||
let l;
|
|
||||||
let maxtries = 10;
|
let rndl;
|
||||||
do l = randomElement(fLayers); while ((rnd_layers.filter(lf => lf.map.name === l.map.name).length > (this.options.allowedSameMapEntries - 1)) && --maxtries >= 0 && !rnd_layers.find((e) => e === l))
|
if (prevmapfilt.length > 0) rndl = randomElement(prevmapfilt);
|
||||||
if (l) {
|
else if(samemapfilt.length > 0) rndl = randomElement(samemapfilt);
|
||||||
rnd_layers.push(l);
|
else if(gamemodewhite.length > 0) rndl = randomElement(gamemodewhite);
|
||||||
this.nominations[i] = l.layerid
|
else if(factionblack.length > 0) rndl = randomElement(factionblack);
|
||||||
|
else rndl = randomElement(factionfilt);
|
||||||
|
if(rndl){
|
||||||
|
rnd_layers.push(rndl);
|
||||||
|
this.nominations[i] = rndl.layerid;
|
||||||
this.tallies[i] = 0;
|
this.tallies[i] = 0;
|
||||||
this.factionStrings[i] = getTranslation(l.teams[0]) + "-" + getTranslation(l.teams[1]);
|
this.factionStrings[i] = this.getTranslation(rndl.teams[0]) + "-" + this.getTranslation(rndl.teams[1]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -712,7 +668,6 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
this.warn(steamid, "You cannot start a vote with more than " + maxOptions + " options");
|
this.warn(steamid, "You cannot start a vote with more than " + maxOptions + " options");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (this.options.showRerollOption && (isRandomVote || this.options.showRerollOptionInCustomVotes)) {
|
if (this.options.showRerollOption && (isRandomVote || this.options.showRerollOptionInCustomVotes)) {
|
||||||
// if (this.nominations.length > 5) {
|
// if (this.nominations.length > 5) {
|
||||||
@ -732,21 +687,6 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
|
|
||||||
if (this.nominations[1] !== "")
|
if (this.nominations[1] !== "")
|
||||||
this.server.rcon.execute(`AdminSetNextLayer ${this.nominations[1]} `);
|
this.server.rcon.execute(`AdminSetNextLayer ${this.nominations[1]} `);
|
||||||
|
|
||||||
function getTranslation(t) {
|
|
||||||
if (translations[t.faction]) return translations[t.faction]
|
|
||||||
else {
|
|
||||||
const f = t.faction.split(' ');
|
|
||||||
if(f.length > 1) {
|
|
||||||
let fTag = "";
|
|
||||||
f.forEach((e) => {
|
|
||||||
fTag += e[0]
|
|
||||||
});
|
|
||||||
return fTag.toUpperCase();
|
|
||||||
} else if (t.faction.length <= 5) return t.faction;
|
|
||||||
else return 'Unk'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks if there are enough players to start voting, if not binds itself to player connected
|
// checks if there are enough players to start voting, if not binds itself to player connected
|
||||||
@ -904,20 +844,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatFancyLayer(layer) {
|
formatFancyLayer(layer) {
|
||||||
const translations = {
|
const factionString = this.getTranslation(layer.teams[0]) + "-" + this.getTranslation(layer.teams[1]);
|
||||||
'United States Army': "USA",
|
|
||||||
'United States Marine Corps': "USMC",
|
|
||||||
'Russian Ground Forces': "RGF",
|
|
||||||
'British Army': "BAF",
|
|
||||||
'British Armed Forces': "BAF",
|
|
||||||
'Canadian Army': "CAF",
|
|
||||||
'Australian Defence Force': "ADF",
|
|
||||||
'Irregular Militia Forces': "IMF",
|
|
||||||
'Middle Eastern Alliance': "MEA",
|
|
||||||
'Insurgent Forces': "INS",
|
|
||||||
'Unknown': "Unk"
|
|
||||||
}
|
|
||||||
const factionString = getTranslation(layer.teams[0]) + "-" + getTranslation(layer.teams[1]);
|
|
||||||
|
|
||||||
const helis = layer.teams[0].numberOfHelicopters + layer.teams[1].numberOfHelicopters
|
const helis = layer.teams[0].numberOfHelicopters + layer.teams[1].numberOfHelicopters
|
||||||
const tanks = layer.teams[0].numberOfTanks + layer.teams[1].numberOfTanks
|
const tanks = layer.teams[0].numberOfTanks + layer.teams[1].numberOfTanks
|
||||||
@ -932,27 +859,13 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
.replace(/\{map_version\}/i, layer.version)
|
.replace(/\{map_version\}/i, layer.version)
|
||||||
.replace(/\{factions\}/i, factionString)
|
.replace(/\{factions\}/i, factionString)
|
||||||
.replace(/\{main_assets\}/i, vehiclesString)
|
.replace(/\{main_assets\}/i, vehiclesString)
|
||||||
|
|
||||||
function getTranslation(t) {
|
|
||||||
if (translations[t.faction]) return translations[t.faction]
|
|
||||||
else {
|
|
||||||
const f = t.faction.split(' ');
|
|
||||||
if(f.length > 1) {
|
|
||||||
let fTag = "";
|
|
||||||
f.forEach((e) => {
|
|
||||||
fTag += e[0]
|
|
||||||
});
|
|
||||||
return fTag.toUpperCase();
|
|
||||||
} else if (t.faction.length <= 5) return t.faction;
|
|
||||||
else return 'Unk'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLayersFromStringId(stringid) {
|
getLayersFromStringId(stringid) {
|
||||||
const cls = stringid.toLowerCase().split('_');
|
// const cls = stringid.toLowerCase().split('_');
|
||||||
const modLayers = this.getModLayers();
|
const modLayers = this.layerfilterCorrectLayers(Layers.layers);
|
||||||
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, '')))));
|
const ret = modLayers.filter(l => l.layerid.toLowerCase().contains(stringid.replace(/\*/gi,'').toLowerCase()));
|
||||||
|
// 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