mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-23 20:43:52 -06:00
fixes
This commit is contained in:
parent
a40e92f4b7
commit
11ac74acbd
14
mapvote.js
14
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,
|
||||||
@ -636,7 +636,8 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
const needMoreRAAS = !bypassRaasFilter && rnd_layers.filter((l) => l.gamemode.toUpperCase() === 'RAAS').length < this.options.minRaasEntries;
|
const needMoreRAAS = !bypassRaasFilter && rnd_layers.filter((l) => l.gamemode.toUpperCase() === 'RAAS').length < this.options.minRaasEntries;
|
||||||
let l;
|
let l;
|
||||||
let maxtries = 20;
|
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)
|
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) {
|
if (maxtries > 0 && l) {
|
||||||
// this.verbose(1,"Testing layer",l, maxtries);
|
// this.verbose(1,"Testing layer",l, maxtries);
|
||||||
rnd_layers.push(l);
|
rnd_layers.push(l);
|
||||||
@ -1121,7 +1122,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
|
|
||||||
for (const layer of response.data.Maps) {
|
for (const layer of response.data.Maps) {
|
||||||
if (!Layers.layers.find((e) => e.layerid === layer.rawName)){
|
if (!Layers.layers.find((e) => e.layerid === layer.rawName)){
|
||||||
if(rconLayers.find((e) => e.layer === layer.rawName)) {
|
if(rconLayers.find((e) => e === layer.rawName)) {
|
||||||
const hellolayer = new Layer(layer);
|
const hellolayer = new Layer(layer);
|
||||||
Layers._layers.set(hellolayer.layerid, hellolayer);
|
Layers._layers.set(hellolayer.layerid, hellolayer);
|
||||||
}
|
}
|
||||||
@ -1153,13 +1154,13 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
mapLayer(l) {
|
mapLayer(l) {
|
||||||
l = l.replace(/[^a-z_\d]/gi, '')
|
l = l.replace(/[^a-z_\d]/gi, '')
|
||||||
// this.verbose(1, 'Parsing layer', l)
|
// this.verbose(1, 'Parsing layer', l)
|
||||||
const gl = /^((?<mod>\w+_))?(?<level>\w+)_(?<gamemode>\w+)_(?<version>\w+)$/i.exec(l)?.groups
|
const gl = /^((?<mod>[a-z]+)_)?(?<level>[a-z]+)_(?<gamemode>[a-z]+)_(?<version>[a-z0-9]+)(_(?<team1>[a-z]+)v(?<team2>[a-z]+))?$/i.exec(l)?.groups
|
||||||
// this.verbose(1, 'Parsed layer', gl)
|
// this.verbose(1, 'Parsed layer', gl)
|
||||||
if (!gl || Object.keys(gl).length !== 3) return;
|
if (!gl || Object.keys(gl).length !== 3) return;
|
||||||
|
|
||||||
if (!gl.level) this.verbose(1, 'Empty level', gl)
|
if (!gl.level) this.verbose(1, 'Empty level', gl)
|
||||||
|
|
||||||
const teams = []
|
let teams = []
|
||||||
for (const t of ['team1', 'team2']) {
|
for (const t of ['team1', 'team2']) {
|
||||||
teams.push({
|
teams.push({
|
||||||
faction: 'Unknown',
|
faction: 'Unknown',
|
||||||
@ -1171,6 +1172,9 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
numberOfHelicopters: 0
|
numberOfHelicopters: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(gl.team1) teams[0].faction = gl.team1;
|
||||||
|
if(gl.team2) teams[1].faction = gl.team2;
|
||||||
// this.verbose(1, 'teams', teams)
|
// this.verbose(1, 'teams', teams)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user