From a0bab922fe2eaab7f945f99abb1b62806bb3b08f Mon Sep 17 00:00:00 2001 From: shrianshChari <30420527+shrianshChari@users.noreply.github.com> Date: Sat, 6 Jul 2024 20:22:31 -0700 Subject: [PATCH] Add teambuilder support for BW 1 (#2257) --- build-tools/build-indexes | 24 +++++++++++++++++-- .../src/battle-dex-search.ts | 14 ++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/build-tools/build-indexes b/build-tools/build-indexes index 68e5b0175..73e040303 100755 --- a/build-tools/build-indexes +++ b/build-tools/build-indexes @@ -322,7 +322,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); const LC = GENS.map(num => num + 0.7); const STADIUM = [2.04, 1.04]; const NATDEX = [9.1, 8.1]; - const OTHER = [9.9, 9.6, 9.411, 9.41, 9.401, 9.4, 9.2, -9.4, -9.401, 8.6, 8.4, 8.2, 8.1, -8.4, -8.6, 7.1]; + const OTHER = [9.9, 9.6, 9.411, 9.41, 9.401, 9.4, 9.2, -9.4, -9.401, 8.6, 8.4, 8.2, 8.1, -8.4, -8.6, 7.1, 5.1]; // process.stdout.write("\n "); for (const genIdent of [...GENS, ...DOUBLES, ...VGC, ...NFE, ...STADIUM, ...OTHER, ...NATDEX, ...LC]) { @@ -341,6 +341,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); const isGen9BH = genIdent === 9.9; const isSSB = genIdent === 9.6; const genNum = Math.floor(isDoubles ? -genIdent : genIdent); + const isBW1 = genIdent === 5.1; const gen = (() => { let genStr = 'gen' + genNum; if (isSSDLC1) genStr += 'dlc1'; @@ -350,6 +351,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); if (isSVDLC1) genStr += 'dlc1'; if (isStadium) genStr += 'stadium' + (genNum > 1 ? genNum : ''); if (isSSB) genStr += 'ssb'; + if (isBW1) genStr += 'bw1'; return genStr; })(); // process.stdout.write("" + gen + (isDoubles ? " doubles" : "") + "... "); @@ -557,6 +559,14 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); BattleTeambuilderTable.ubersUUBans = ubersUUBans; BattleTeambuilderTable.monotypeBans = monotypeBans; BattleTeambuilderTable.formatSlices = formatSlices; + } else if (isBW1) { + BattleTeambuilderTable[gen] = {}; + BattleTeambuilderTable[gen].overrideTier = overrideTier; + BattleTeambuilderTable[gen].tiers = tiers; + BattleTeambuilderTable[gen].items = items; + BattleTeambuilderTable[gen].formatSlices = formatSlices; + BattleTeambuilderTable[gen].nonstandardMoves = nonstandardMoves; + BattleTeambuilderTable[gen].learnsets = {}; } else { BattleTeambuilderTable[gen] = {}; BattleTeambuilderTable[gen].overrideTier = overrideTier; @@ -915,6 +925,16 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); if (minGen === 1) learnsets[id][moveid] = '12' + learnsets[id][moveid]; } } + const G5BW1Learnsets = Dex.mod('gen5bw1').data.Learnsets; + for (const id in G5BW1Learnsets) { + const species = Dex.mod('gen5bw1').species.get(id); + if (species.isNonstandard && !['Unobtainable', 'CAP'].includes(species.isNonstandard)) continue; + const learnset = G5BW1Learnsets[id].learnset; + BattleTeambuilderTable['gen5bw1'].learnsets[id] = {}; + for (const moveid in learnset) { + BattleTeambuilderTable['gen5bw1'].learnsets[id][moveid] = '5'; + } + } const LGLearnsets = Dex.mod('gen7letsgo').data.Learnsets; for (const id in LGLearnsets) { const species = Dex.mod('gen7letsgo').species.get(id); @@ -1166,7 +1186,7 @@ process.stdout.write("Building `data/teambuilder-tables.js`... "); // Mods // - for (const mod of ['gen7letsgo', 'gen8bdsp', 'gen9ssb']) { + for (const mod of ['gen5bw1', 'gen7letsgo', 'gen8bdsp', 'gen9ssb']) { const modDex = Dex.mod(mod); const modData = modDex.data; const parentDex = Dex.forGen(modDex.gen); diff --git a/play.pokemonshowdown.com/src/battle-dex-search.ts b/play.pokemonshowdown.com/src/battle-dex-search.ts index a77879b84..e2a197757 100644 --- a/play.pokemonshowdown.com/src/battle-dex-search.ts +++ b/play.pokemonshowdown.com/src/battle-dex-search.ts @@ -549,7 +549,7 @@ abstract class BattleTypedSearch { */ set: PokemonSet | null = null; - protected formatType: 'doubles' | 'bdsp' | 'bdspdoubles' | 'letsgo' | 'metronome' | 'natdex' | 'nfe' | + protected formatType: 'doubles' | 'bdsp' | 'bdspdoubles' | 'bw1' | 'letsgo' | 'metronome' | 'natdex' | 'nfe' | 'ssdlc1' | 'ssdlc1doubles' | 'predlc' | 'predlcdoubles' | 'predlcnatdex' | 'svdlc1' | 'svdlc1doubles' | 'svdlc1natdex' | 'stadium' | 'lc' | null = null; @@ -628,6 +628,10 @@ abstract class BattleTypedSearch { format = format.slice(4) as ID; this.dex = Dex.mod('gen8bdsp' as ID); } + if (format.includes('bw1')) { + this.formatType = 'bw1'; + this.dex = Dex.mod('gen5bw1' as ID); + } if (format === 'partnersincrime') this.formatType = 'doubles'; if (format.startsWith('ffa') || format === 'freeforall') this.formatType = 'doubles'; if (format.includes('letsgo')) { @@ -747,6 +751,7 @@ abstract class BattleTypedSearch { let table = BattleTeambuilderTable; if (this.formatType?.startsWith('bdsp')) table = table['gen8bdsp']; if (this.formatType === 'letsgo') table = table['gen7letsgo']; + if (this.formatType === 'bw1') table = table['gen5bw1']; if (speciesid in table.learnsets) return speciesid; const species = this.dex.species.get(speciesid); if (!species.exists) return '' as ID; @@ -813,6 +818,7 @@ abstract class BattleTypedSearch { let table = BattleTeambuilderTable; if (this.formatType?.startsWith('bdsp')) table = table['gen8bdsp']; if (this.formatType === 'letsgo') table = table['gen7letsgo']; + if (this.formatType === 'bw1') table = table['gen5bw1']; let learnset = table.learnsets[learnsetid]; if (learnset && (moveid in learnset) && (!this.format.startsWith('tradebacks') ? learnset[moveid].includes(genChar) : learnset[moveid].includes(genChar) || @@ -833,6 +839,7 @@ abstract class BattleTypedSearch { this.formatType === 'letsgo' ? 'gen7letsgo' : this.formatType === 'bdsp' ? 'gen8bdsp' : this.formatType === 'bdspdoubles' ? 'gen8bdspdoubles' : + this.formatType === 'bw1' ? 'gen5bw1' : this.formatType === 'nfe' ? `gen${gen}nfe` : this.formatType === 'lc' ? `gen${gen}lc` : this.formatType === 'ssdlc1' ? 'gen8dlc1' : @@ -956,6 +963,8 @@ class BattlePokemonSearch extends BattleTypedSearch<'pokemon'> { table = table['gen8' + this.formatType]; } else if (this.formatType === 'letsgo') { table = table['gen7letsgo']; + } else if (this.formatType === 'bw1') { + table = table['gen5bw1']; } else if (this.formatType === 'natdex') { table = table['gen' + dex.gen + 'natdex']; } else if (this.formatType === 'metronome') { @@ -1231,6 +1240,8 @@ class BattleItemSearch extends BattleTypedSearch<'item'> { let table = BattleTeambuilderTable; if (this.formatType?.startsWith('bdsp')) { table = table['gen8bdsp']; + } else if (this.formatType === 'bw1') { + table = table['gen5bw1']; } else if (this.formatType === 'natdex') { table = table['gen' + this.dex.gen + 'natdex']; } else if (this.formatType === 'metronome') { @@ -1574,6 +1585,7 @@ class BattleMoveSearch extends BattleTypedSearch<'move'> { let lsetTable = BattleTeambuilderTable; if (this.formatType?.startsWith('bdsp')) lsetTable = lsetTable['gen8bdsp']; if (this.formatType === 'letsgo') lsetTable = lsetTable['gen7letsgo']; + if (this.formatType === 'bw1') lsetTable = lsetTable['gen5bw1']; if (this.formatType?.startsWith('ssdlc1')) lsetTable = lsetTable['gen8dlc1']; if (this.formatType?.startsWith('predlc')) lsetTable = lsetTable['gen9predlc']; if (this.formatType?.startsWith('svdlc1')) lsetTable = lsetTable['gen9dlc1'];