mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-24 00:13:52 -06:00
fix: update layer list
This commit is contained in:
parent
bb84fbe523
commit
09d117d86e
18
mapvote.js
18
mapvote.js
@ -579,7 +579,7 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
)
|
)
|
||||||
&& !(this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f)))
|
&& !(this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f)))
|
||||||
);
|
);
|
||||||
for (let i = 1; i <= optionAmount; i++) {
|
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;
|
const needMoreRAAS = !bypassRaasFilter && rnd_layers.filter((l) => l.gamemode.toUpperCase() === 'RAAS').length < this.options.minRaasEntries;
|
||||||
let l, maxtries = 20;
|
let l, 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)
|
||||||
@ -603,9 +603,9 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
if (cmdLayers.length <= maxOptions) {
|
if (cmdLayers.length <= maxOptions) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (let cl of cmdLayers) {
|
for (let cl of cmdLayers) {
|
||||||
|
|
||||||
const cls = cl.toLowerCase().split('_');
|
const cls = cl.toLowerCase().split('_');
|
||||||
const fLayers = sanitizedLayers.filter((l) => (
|
const fLayers = sanitizedLayers.filter((l) => (
|
||||||
|
!rnd_layers.find(l2 => l2.layerid == l.layerid) &&
|
||||||
(
|
(
|
||||||
(cls[ 0 ] == "*" || l.layerid.toLowerCase().startsWith(cls[ 0 ]))
|
(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()))
|
|| (cls[ 0 ].toLowerCase().startsWith('f:') && [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(cls[ 0 ].substring(2).toUpperCase()))
|
||||||
@ -618,6 +618,9 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
|| this.options.factionsBlacklist.find((f) => [ getTranslation(l.teams[ 0 ]), getTranslation(l.teams[ 1 ]) ].includes(f))
|
|| 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, 'rnd_layers', rnd_layers.map(l => l.layerid));
|
||||||
let l, maxtries = 10;
|
let l, maxtries = 10;
|
||||||
do l = randomElement(fLayers); while ((rnd_layers.filter(lf => lf.map.name == l.map.name).length > (this.options.allowedSameMapEntries - 1)) && --maxtries >= 0)
|
do l = randomElement(fLayers); while ((rnd_layers.filter(lf => lf.map.name == l.map.name).length > (this.options.allowedSameMapEntries - 1)) && --maxtries >= 0)
|
||||||
if (l) {
|
if (l) {
|
||||||
@ -1036,19 +1039,20 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sheetCsv = (await axios.get('https://docs.google.com/spreadsheets/d/1OYO1IvNI0wrUZWKz_pz6Ka1xFAvBjBupddYn2E4fNFg/gviz/tq?tqx=out:csv&sheet=Map%20Layers')).data?.replace(/\"/g, '')?.split('\n') || []//.map((l) => l.split(','))
|
const sheetCsv = (await axios.get('https://docs.google.com/spreadsheets/d/1OYO1IvNI0wrUZWKz_pz6Ka1xFAvBjBupddYn2E4fNFg/gviz/tq?tqx=out:csv&sheet=Map%20Layers')).data?.replace(/\"/g, '')?.split('\n') || []//.map((l) => l.split(','))
|
||||||
sheetCsv.shift();
|
|
||||||
// this.verbose(1, 'Sheet', Layers.layers.length, sheetCsv.length, sheetCsv.find(l => l[ 2 ] == "Manicouagan_RAAS_v1"))
|
|
||||||
// this.verbose(1, 'Sheet', sheetCsv)
|
// this.verbose(1, 'Sheet', sheetCsv)
|
||||||
|
sheetCsv.shift();
|
||||||
|
// this.verbose(1, 'Sheet', Layers.layers.length, sheetCsv.length, sheetCsv.find(l => l.includes("Manicouagan_RAAS_v1")))
|
||||||
|
|
||||||
const rconLayers = (await this.server.rcon.execute('ListLayers'))?.split('\n') || [];
|
const rconLayers = (await this.server.rcon.execute('ListLayers'))?.split('\n') || [];
|
||||||
rconLayers.shift();
|
rconLayers.shift();
|
||||||
console.log(rconLayers);
|
|
||||||
if (rconLayers.length > 0) Layers.layers = Layers.layers.filter((l) => l != null && rconLayers.includes(l.layerid))
|
if (rconLayers.length > 0) Layers.layers = Layers.layers.filter((l) => l != null && rconLayers.includes(l.layerid))
|
||||||
this.verbose(1, 'RCON Layers', rconLayers.length, this.mapLayer(rconLayers[ 0 ]))
|
// this.verbose(1, 'RCON Layers', rconLayers.length, this.mapLayer(rconLayers[ 0 ]))
|
||||||
if (sheetCsv.length > 0) {
|
if (sheetCsv.length > 0) {
|
||||||
for (const layer of rconLayers) {
|
for (const layer of rconLayers) {
|
||||||
if (!Layers.layers.find((e) => e?.layerid == layer)) {
|
if (!Layers.layers.find((e) => e?.layerid == layer)) {
|
||||||
let newLayer = this.mapLayer(layer);
|
let newLayer = this.mapLayer(layer);
|
||||||
|
if (!newLayer) continue;
|
||||||
|
|
||||||
const csvLayer = sheetCsv.find(l => l.includes(newLayer?.layerid))?.split(',');
|
const csvLayer = sheetCsv.find(l => l.includes(newLayer?.layerid))?.split(',');
|
||||||
// console.log(newLayer.layerid, csvLayer[ 2 ]);
|
// console.log(newLayer.layerid, csvLayer[ 2 ]);
|
||||||
@ -1085,6 +1089,8 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
// 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)
|
||||||
|
|
||||||
let teams = []
|
let teams = []
|
||||||
for (const t of [ 'team1', 'team2' ]) {
|
for (const t of [ 'team1', 'team2' ]) {
|
||||||
teams.push({
|
teams.push({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user