From 007d58e6986cf262a577f8342c58400bdf1127ec Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Wed, 29 Apr 2020 00:24:12 -0400 Subject: [PATCH] Fix cosmetic formes in replays Replays don't load BattleAliases but they do load BattlePokedex, making the old BattleBaseSpeciesChart unnecessary. In its place, a new chart, specifically for cosmetic formes! --- src/battle-dex-data.ts | 87 +----------------------------------------- src/battle-dex.ts | 7 ++++ 2 files changed, 9 insertions(+), 85 deletions(-) diff --git a/src/battle-dex-data.ts b/src/battle-dex-data.ts index 35c4c99f9..2d1827500 100644 --- a/src/battle-dex-data.ts +++ b/src/battle-dex-data.ts @@ -138,61 +138,8 @@ const BattleStatNames = { } as const; const BattleBaseSpeciesChart = [ - 'pikachu', - 'pichu', - 'unown', - 'castform', - 'deoxys', - 'burmy', - 'wormadam', - 'cherrim', - 'shellos', - 'gastrodon', - 'rotom', - 'giratina', - 'shaymin', - 'arceus', - 'basculin', - 'darmanitan', - 'deerling', - 'sawsbuck', - 'tornadus', - 'thundurus', - 'landorus', - 'kyurem', - 'keldeo', - 'meloetta', - 'genesect', - 'vivillon', - 'flabebe', - 'floette', - 'florges', - 'furfrou', - 'aegislash', - 'pumpkaboo', - 'gourgeist', - 'meowstic', - 'hoopa', - 'zygarde', - 'lycanroc', - 'wishiwashi', - 'minior', - 'mimikyu', - 'greninja', - 'oricorio', - 'silvally', - 'necrozma', - - // alola totems - 'raticate', - 'marowak', - 'kommoo', - - // mega evolutions - 'charizard', - 'mewtwo', - // others are hardcoded by ending with 'mega' -]; + "unown", "burmy", "shellos", "gastrodon", "deerling", "sawsbuck", "vivillon", "flabebe", "floette", "florges", "furfrou", "minior", "alcremie", "pokestarufo", "pokestarbrycenman", "pokestarmt", "pokestarmt2", "pokestartransport", "pokestargiant", "pokestarhumanoid", "pokestarmonster", "pokestarf00", "pokestarf002", "pokestarspirit", "pokestarblackdoor", "pokestarwhitedoor", "pokestarblackbelt", +] as ID[]; const BattlePokemonIconIndexes: {[id: string]: number} = { egg: 900 + 1, @@ -1335,36 +1282,6 @@ class Species implements Effect { this.id = id; this.gen = data.gen || 0; this.exists = ('exists' in data ? !!data.exists : true); - if (!data.abilities && - !['hooh', 'hakamoo', 'jangmoo', 'kommoo', 'porygonz'].includes(this.id)) { - const dashIndex = name.indexOf('-'); - if (this.id === 'kommoototem') { - data.baseSpecies = 'Kommo-o'; - data.forme = 'Totem'; - } else if (dashIndex > 0) { - data.baseSpecies = name.slice(0, dashIndex); - data.forme = name.slice(dashIndex + 1); - } - } - if (!data.abilities) { - // deprecated BattleBaseSpeciesChart - for (const baseid of BattleBaseSpeciesChart) { - if (this.id.length > baseid.length && this.id.slice(0, baseid.length) === baseid) { - data.baseSpecies = baseid; - data.forme = this.id.slice(baseid.length); - } - } - if (this.id !== 'yanmega' && this.id.slice(-4) === 'mega') { - data.baseSpecies = this.id.slice(0, -4); - data.forme = this.id.slice(-4); - } else if (this.id.slice(-6) === 'primal') { - data.baseSpecies = this.id.slice(0, -6); - data.forme = this.id.slice(-6); - } else if (this.id.slice(-5) === 'alola') { - data.baseSpecies = this.id.slice(0, -5); - data.forme = this.id.slice(-5); - } - } this.baseSpecies = data.baseSpecies || name; this.forme = data.forme || ''; const baseId = toID(this.baseSpecies); diff --git a/src/battle-dex.ts b/src/battle-dex.ts index 372d1aab3..793704f51 100644 --- a/src/battle-dex.ts +++ b/src/battle-dex.ts @@ -465,6 +465,13 @@ const Dex = new class implements ModdedDex { if (window.BattleAliases && id in BattleAliases) { name = BattleAliases[id]; id = toID(name); + } else if (window.BattlePokedex && !(id in BattlePokedex) && window.BattleBaseSpeciesChart) { + for (const baseSpeciesId of BattleBaseSpeciesChart) { + if (formid.startsWith(baseSpeciesId)) { + id = baseSpeciesId; + break; + } + } } if (!window.BattlePokedex) window.BattlePokedex = {}; let data = window.BattlePokedex[id];