From 7017185f7980735113c2e8ccda66327e80912826 Mon Sep 17 00:00:00 2001 From: demir Date: Sat, 21 Dec 2024 19:57:23 +0300 Subject: [PATCH 1/4] Changed 35pokes validation --- config/formats.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/config/formats.ts b/config/formats.ts index 4c0a4dac7ced..797c0d966860 100644 --- a/config/formats.ts +++ b/config/formats.ts @@ -2286,28 +2286,37 @@ export const Formats: import('../sim/dex-formats').FormatList = [ 'Sleep Clause Mod', 'Forme Clause', 'Z-Move Clause', 'Terastal Clause', 'Mega Rayquaza Clause', ], banlist: [ - 'ND Uber', 'ND AG', 'ND OU', 'ND UUBL', 'ND UU', 'ND RUBL', 'ND RU', 'ND NFE', 'ND LC', 'Battle Bond', 'Moody', 'Shadow Tag', 'Berserk Gene', 'King\'s Rock', 'Quick Claw', 'Razor Fang', 'Acupressure', 'Last Respects', ], - unbanlist: [ - 'Appletun', 'Aurorus', 'Avalugg-Base', 'Banette-Base', 'Cacturne', 'Carracosta', 'Celebi', 'Cetitan', 'Chandelure', 'Cryogonal', 'Dipplin', - 'Garbodor', 'Golem-Alola', 'Guzzlord', 'Jumpluff', 'Luvdisc', 'Magmortar', 'Mawile-Base', 'Milotic', 'Morpeko', 'Pachirisu', 'Perrserker', - 'Primarina', 'Pupitar', 'Pyukumuku', 'Ribombee', 'Roserade', 'Rotom-Frost', 'Scovillain', 'Toxicroak', 'Walrein', 'Wo-Chien', 'Wugtrio', - 'Yanmega', 'Zoroark-Base', - ], // Stupid hardcode - onValidateSet(set, format, setHas, teamHas) { + onValidateSet(set) { + const allowedPokemon: string[] = [ + 'Appletun', 'Aurorus', 'Avalugg', 'Banette', 'Cacturne', 'Carracosta', 'Celebi', 'Cetitan', 'Chandelure', 'Cryogonal', 'Dipplin', + 'Garbodor', 'Golem-Alola', 'Guzzlord', 'Jumpluff', 'Luvdisc', 'Magmortar', 'Mawile', 'Milotic', 'Morpeko', 'Pachirisu', 'Perrserker', + 'Primarina', 'Pupitar', 'Pyukumuku', 'Ribombee', 'Roserade', 'Rotom-Frost', 'Scovillain', 'Toxicroak', 'Walrein', 'Wo-Chien', 'Wugtrio', + 'Yanmega', 'Zoroark', + ]; + const problems: string[] = []; + // To be called by the client build script. + if(this.gen === 0) { + if(!allowedPokemon.includes(set.species)) problems.push('bad'); + return problems.length ? problems : undefined; + } + const species = this.dex.species.get(set.species); + if(!this.ruleTable.has('-pokemontag:allpokemon')) { + if(!allowedPokemon.includes(set.species)) problems.push(`${set.species} is not part of this month's roster.`); + } if (set.item) { const item = this.dex.items.get(set.item); if (item.megaEvolves && !(this.ruleTable.has(`+item:${item.id}`) || this.ruleTable.has(`+pokemontag:mega`))) { - return [`Mega Evolution is banned.`]; + problems.push(`Mega Evolution is banned.`); } } - const species = this.dex.species.get(set.species); if (set.moves.map(x => this.toID(this.dex.moves.get(x).realMove) || x).includes('hiddenpower') && species.baseSpecies !== 'Unown' && !this.ruleTable.has(`+move:hiddenpower`)) { - return [`Hidden Power is banned.`]; + problems.push(`Hidden Power is banned.`); } + if(problems.length) return problems; }, }, { From c6029be518a9def46a0b28536f2cff7d275cb9c4 Mon Sep 17 00:00:00 2001 From: demir Date: Mon, 23 Dec 2024 05:24:07 +0300 Subject: [PATCH 2/4] Fix dexited mons broken validation --- config/formats.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/config/formats.ts b/config/formats.ts index 797c0d966860..5b734c413e14 100644 --- a/config/formats.ts +++ b/config/formats.ts @@ -2289,8 +2289,8 @@ export const Formats: import('../sim/dex-formats').FormatList = [ 'Battle Bond', 'Moody', 'Shadow Tag', 'Berserk Gene', 'King\'s Rock', 'Quick Claw', 'Razor Fang', 'Acupressure', 'Last Respects', ], // Stupid hardcode - onValidateSet(set) { - const allowedPokemon: string[] = [ + validateSet(set, teamHas) { + const allowedPokemonCurrent: string[] = [ 'Appletun', 'Aurorus', 'Avalugg', 'Banette', 'Cacturne', 'Carracosta', 'Celebi', 'Cetitan', 'Chandelure', 'Cryogonal', 'Dipplin', 'Garbodor', 'Golem-Alola', 'Guzzlord', 'Jumpluff', 'Luvdisc', 'Magmortar', 'Mawile', 'Milotic', 'Morpeko', 'Pachirisu', 'Perrserker', 'Primarina', 'Pupitar', 'Pyukumuku', 'Ribombee', 'Roserade', 'Rotom-Frost', 'Scovillain', 'Toxicroak', 'Walrein', 'Wo-Chien', 'Wugtrio', @@ -2299,12 +2299,21 @@ export const Formats: import('../sim/dex-formats').FormatList = [ const problems: string[] = []; // To be called by the client build script. if(this.gen === 0) { - if(!allowedPokemon.includes(set.species)) problems.push('bad'); - return problems.length ? problems : undefined; + if(!allowedPokemonCurrent.includes(set.species)) problems.push('bad'); + return problems.length ? problems : null; } - const species = this.dex.species.get(set.species); - if(!this.ruleTable.has('-pokemontag:allpokemon')) { - if(!allowedPokemon.includes(set.species)) problems.push(`${set.species} is not part of this month's roster.`); + if(this.ruleTable.has('-pokemontag:allpokemon') && this.format.customRules) { + const allowedPokemonCustom: string[] = []; + for(const tmpName of this.format.customRules) { + const tmpSpecies = this.dex.species.get(tmpName); + if(tmpSpecies.exists) allowedPokemonCustom.push(tmpSpecies.id); + } + if(!allowedPokemonCustom.includes(this.toID(set.species))) { + problems.push(`${set.species} is not part of this roster.`); + } + } + else if(!allowedPokemonCurrent.includes(set.species)) { + problems.push(`${set.species} is not part of this month's roster.`); } if (set.item) { const item = this.dex.items.get(set.item); @@ -2312,11 +2321,15 @@ export const Formats: import('../sim/dex-formats').FormatList = [ problems.push(`Mega Evolution is banned.`); } } + const species = this.dex.species.get(set.species); if (set.moves.map(x => this.toID(this.dex.moves.get(x).realMove) || x).includes('hiddenpower') && species.baseSpecies !== 'Unown' && !this.ruleTable.has(`+move:hiddenpower`)) { problems.push(`Hidden Power is banned.`); } if(problems.length) return problems; + const problemsMore = this.validateSet.call(this, set, teamHas); + if(problemsMore) problems.push(...problemsMore); + return problems.length ? problems : null; }, }, { From a0a0ccd4f59cc49971ea90618a5facce1fbb273f Mon Sep 17 00:00:00 2001 From: demir Date: Mon, 23 Dec 2024 23:34:37 +0300 Subject: [PATCH 3/4] Handle bans/unbans regardless of -allpokemon --- config/formats.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config/formats.ts b/config/formats.ts index 5b734c413e14..975dfaebbfda 100644 --- a/config/formats.ts +++ b/config/formats.ts @@ -2290,31 +2290,32 @@ export const Formats: import('../sim/dex-formats').FormatList = [ ], // Stupid hardcode validateSet(set, teamHas) { - const allowedPokemonCurrent: string[] = [ + const allowedPokemon: Set = new Set([ 'Appletun', 'Aurorus', 'Avalugg', 'Banette', 'Cacturne', 'Carracosta', 'Celebi', 'Cetitan', 'Chandelure', 'Cryogonal', 'Dipplin', 'Garbodor', 'Golem-Alola', 'Guzzlord', 'Jumpluff', 'Luvdisc', 'Magmortar', 'Mawile', 'Milotic', 'Morpeko', 'Pachirisu', 'Perrserker', 'Primarina', 'Pupitar', 'Pyukumuku', 'Ribombee', 'Roserade', 'Rotom-Frost', 'Scovillain', 'Toxicroak', 'Walrein', 'Wo-Chien', 'Wugtrio', 'Yanmega', 'Zoroark', - ]; + ].map((x) => this.toID(x))); const problems: string[] = []; - // To be called by the client build script. if(this.gen === 0) { - if(!allowedPokemonCurrent.includes(set.species)) problems.push('bad'); + // This block is only to be reached by the client build script. + if(!allowedPokemon.has(this.toID(set.species))) problems.push('bad'); return problems.length ? problems : null; } - if(this.ruleTable.has('-pokemontag:allpokemon') && this.format.customRules) { - const allowedPokemonCustom: string[] = []; - for(const tmpName of this.format.customRules) { + if(this.format.customRules){ + if(this.ruleTable.has('-pokemontag:allpokemon')) allowedPokemon.clear(); + for(const tmpRule of this.format.customRules) { + const tmpName = tmpRule.slice(1); const tmpSpecies = this.dex.species.get(tmpName); - if(tmpSpecies.exists) allowedPokemonCustom.push(tmpSpecies.id); - } - if(!allowedPokemonCustom.includes(this.toID(set.species))) { - problems.push(`${set.species} is not part of this roster.`); + if(!tmpSpecies.exists) continue; + if(tmpRule.charAt(0) === "+") allowedPokemon.add(tmpSpecies.id); + else if(tmpRule.charAt(0) === "-") allowedPokemon.delete(tmpSpecies.id); } } - else if(!allowedPokemonCurrent.includes(set.species)) { + if(!allowedPokemon.has(this.toID(set.species))) { problems.push(`${set.species} is not part of this month's roster.`); } + if(problems.length) return problems; if (set.item) { const item = this.dex.items.get(set.item); if (item.megaEvolves && !(this.ruleTable.has(`+item:${item.id}`) || this.ruleTable.has(`+pokemontag:mega`))) { @@ -2326,7 +2327,6 @@ export const Formats: import('../sim/dex-formats').FormatList = [ species.baseSpecies !== 'Unown' && !this.ruleTable.has(`+move:hiddenpower`)) { problems.push(`Hidden Power is banned.`); } - if(problems.length) return problems; const problemsMore = this.validateSet.call(this, set, teamHas); if(problemsMore) problems.push(...problemsMore); return problems.length ? problems : null; From 9607d36cdbee34e2f15a28d37ad994daa83875e6 Mon Sep 17 00:00:00 2001 From: demir Date: Fri, 27 Dec 2024 21:27:56 +0300 Subject: [PATCH 4/4] Undo some 'reinventing the wheel' --- config/formats.ts | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/config/formats.ts b/config/formats.ts index 975dfaebbfda..04f5e276a2b4 100644 --- a/config/formats.ts +++ b/config/formats.ts @@ -2286,50 +2286,43 @@ export const Formats: import('../sim/dex-formats').FormatList = [ 'Sleep Clause Mod', 'Forme Clause', 'Z-Move Clause', 'Terastal Clause', 'Mega Rayquaza Clause', ], banlist: [ + 'ND Uber', 'ND AG', 'ND OU', 'ND UUBL', 'ND UU', 'ND RUBL', 'ND RU', 'ND NFE', 'ND LC', 'Battle Bond', 'Moody', 'Shadow Tag', 'Berserk Gene', 'King\'s Rock', 'Quick Claw', 'Razor Fang', 'Acupressure', 'Last Respects', ], - // Stupid hardcode - validateSet(set, teamHas) { - const allowedPokemon: Set = new Set([ - 'Appletun', 'Aurorus', 'Avalugg', 'Banette', 'Cacturne', 'Carracosta', 'Celebi', 'Cetitan', 'Chandelure', 'Cryogonal', 'Dipplin', - 'Garbodor', 'Golem-Alola', 'Guzzlord', 'Jumpluff', 'Luvdisc', 'Magmortar', 'Mawile', 'Milotic', 'Morpeko', 'Pachirisu', 'Perrserker', + validateTeam(team, options) { + const allowedPokemon = [ + 'Appletun', 'Aurorus', 'Avalugg-Base', 'Banette-Base', 'Cacturne', 'Carracosta', 'Celebi', 'Cetitan', 'Chandelure', 'Cryogonal', 'Dipplin', + 'Garbodor', 'Golem-Alola', 'Guzzlord', 'Jumpluff', 'Luvdisc', 'Magmortar', 'Mawile-Base', 'Milotic', 'Morpeko', 'Pachirisu', 'Perrserker', 'Primarina', 'Pupitar', 'Pyukumuku', 'Ribombee', 'Roserade', 'Rotom-Frost', 'Scovillain', 'Toxicroak', 'Walrein', 'Wo-Chien', 'Wugtrio', - 'Yanmega', 'Zoroark', - ].map((x) => this.toID(x))); - const problems: string[] = []; + 'Yanmega', 'Zoroark-Base', + ]; if(this.gen === 0) { // This block is only to be reached by the client build script. - if(!allowedPokemon.has(this.toID(set.species))) problems.push('bad'); - return problems.length ? problems : null; + const display = allowedPokemon.map((mon) => mon.endsWith('-Base') ? mon.slice(0, -5) : mon).includes(team[0].species); + return display ? [] : undefined; } - if(this.format.customRules){ - if(this.ruleTable.has('-pokemontag:allpokemon')) allowedPokemon.clear(); - for(const tmpRule of this.format.customRules) { - const tmpName = tmpRule.slice(1); - const tmpSpecies = this.dex.species.get(tmpName); - if(!tmpSpecies.exists) continue; - if(tmpRule.charAt(0) === "+") allowedPokemon.add(tmpSpecies.id); - else if(tmpRule.charAt(0) === "-") allowedPokemon.delete(tmpSpecies.id); + if(!this.ruleTable.has('-pokemontag:allpokemon')) { + for(const mon of allowedPokemon) { + const rule = this.dex.formats.validateRule('+' + mon, this.format) as string; + if(!this.ruleTable.check(rule.slice(1))) this.ruleTable.set(rule, ''); } } - if(!allowedPokemon.has(this.toID(set.species))) { - problems.push(`${set.species} is not part of this month's roster.`); - } - if(problems.length) return problems; + const problems = this.baseValidateTeam.call(this, team, options); + if(problems) return problems; + }, + // Stupid hardcode + onValidateSet(set, format, setHas, teamHas) { if (set.item) { const item = this.dex.items.get(set.item); if (item.megaEvolves && !(this.ruleTable.has(`+item:${item.id}`) || this.ruleTable.has(`+pokemontag:mega`))) { - problems.push(`Mega Evolution is banned.`); + return [`Mega Evolution is banned.`]; } } const species = this.dex.species.get(set.species); if (set.moves.map(x => this.toID(this.dex.moves.get(x).realMove) || x).includes('hiddenpower') && species.baseSpecies !== 'Unown' && !this.ruleTable.has(`+move:hiddenpower`)) { - problems.push(`Hidden Power is banned.`); + return [`Hidden Power is banned.`]; } - const problemsMore = this.validateSet.call(this, set, teamHas); - if(problemsMore) problems.push(...problemsMore); - return problems.length ? problems : null; }, }, {