From cfd29205d5ca5308dcf02c2d5e93c1ae4cf16205 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sat, 16 Nov 2019 02:07:40 -0500 Subject: [PATCH] Fix misc bugs in Gen 8 migration --- build-tools/build-learnsets | 10 ++-------- src/battle-dex-data.ts | 26 ++++++++++++++++---------- src/battle-dex.ts | 5 +++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/build-tools/build-learnsets b/build-tools/build-learnsets index f1d7a4e21..e1f1c61e6 100755 --- a/build-tools/build-learnsets +++ b/build-tools/build-learnsets @@ -28,13 +28,7 @@ function updateLearnsets(callback) { const alphabetize = (a, b) => a.localeCompare(b); const getLsetGen = lset => lset.charAt(0); - const padNumString = function (str) { - switch (str.length) { - case 1: return '00' + str; - case 2: return '0' + str; - case 3: return '' + str; - } - }; + const padNumString = str => str.padStart(3, '0'); const inLearnset = function (lset, learnset) { const secondChar = lset.charAt(1); if (secondChar !== 'L') return learnset.indexOf(lset) >= 0; @@ -105,7 +99,7 @@ function updateLearnsets(callback) { if (!newLearnset[moveid]) newLearnset[moveid] = []; newLearnset[moveid] = newLearnset[moveid].map(formatLset); for (let i = 0, len = fullLearnset[moveid].length; i < len; i++) { - if (getLsetGen(fullLearnset[moveid][i]) !== '7') continue; + if (getLsetGen(fullLearnset[moveid][i]) !== '8') continue; if (inLearnset(fullLearnset[moveid][i], newLearnset[moveid])) continue; newLearnset[moveid].push(formatLset(fullLearnset[moveid][i])); } diff --git a/src/battle-dex-data.ts b/src/battle-dex-data.ts index 8d5a2d578..7141fbaa7 100644 --- a/src/battle-dex-data.ts +++ b/src/battle-dex-data.ts @@ -1052,7 +1052,7 @@ class Move implements Effect { readonly desc: string; readonly shortDesc: string; readonly isViable: boolean; - readonly isNonstandard: boolean; + readonly isNonstandard: string | null; readonly isZ: ID; readonly zMovePower: number; readonly zMoveEffect: string; @@ -1087,7 +1087,7 @@ class Move implements Effect { this.desc = data.desc; this.shortDesc = data.shortDesc; this.isViable = !!data.isViable; - this.isNonstandard = !!data.isNonstandard; + this.isNonstandard = data.isNonstandard || null; this.isZ = data.isZ || ''; this.zMovePower = data.zMovePower || 0; this.zMoveEffect = data.zMoveEffect || ''; @@ -1141,7 +1141,11 @@ class Ability implements Effect { this.shortDesc = data.shortDesc || data.desc || ''; this.desc = data.desc || data.shortDesc || ''; if (!this.gen) { - if (this.num >= 165) { + if (this.num >= 234) { + this.gen = 8; + } else if (this.num >= 192) { + this.gen = 7; + } else if (this.num >= 165) { this.gen = 6; } else if (this.num >= 124) { this.gen = 5; @@ -1201,9 +1205,10 @@ class Template implements Effect { readonly tier: string; readonly isTotem: boolean; readonly isMega: boolean; + readonly isGigantamax: boolean; readonly isPrimal: boolean; readonly battleOnly: boolean; - readonly isNonstandard: boolean; + readonly isNonstandard: string | null; readonly unreleasedHidden: boolean; constructor(id: ID, name: string, data: any) { @@ -1278,12 +1283,17 @@ class Template implements Effect { this.isTotem = false; this.isMega = false; + this.isGigantamax = !!(this.forme && this.forme.endsWith('Gmax')); this.isPrimal = false; this.battleOnly = !!data.battleOnly; - this.isNonstandard = !!data.isNonstandard; + this.isNonstandard = data.isNonstandard || null; this.unreleasedHidden = !!data.unreleasedHidden; if (!this.gen) { - if (this.forme && ['-mega', '-megax', '-megay'].includes(this.formeid)) { + if (this.num >= 810 || this.forme === 'Galar' || this.isGigantamax) { + this.gen = 8; + } else if (this.num >= 722 || this.formeid === '-alola' || this.formeid === '-starter') { + this.gen = 7; + } else if (this.forme && ['-mega', '-megax', '-megay'].includes(this.formeid)) { this.gen = 6; this.isMega = true; this.battleOnly = true; @@ -1294,10 +1304,6 @@ class Template implements Effect { } else if (this.formeid === '-totem' || this.formeid === '-alolatotem') { this.gen = 7; this.isTotem = true; - } else if (this.formeid === '-alola' || this.formeid === '-starter') { - this.gen = 7; - } else if (this.num >= 722) { - this.gen = 7; } else if (this.num >= 650) { this.gen = 6; } else if (this.num >= 494) { diff --git a/src/battle-dex.ts b/src/battle-dex.ts index 67ce34b0f..e87e0b791 100644 --- a/src/battle-dex.ts +++ b/src/battle-dex.ts @@ -444,7 +444,7 @@ const Dex = new class implements ModdedDex { /** @deprecated */ getTier(pokemon: Template, gen = 7, isDoubles = false): string { - if (gen < 7) pokemon = this.forGen(gen).getTemplate(pokemon.id); + if (gen < 8) pokemon = this.forGen(gen).getTemplate(pokemon.id); if (!isDoubles) return pokemon.tier; let table = window.BattleTeambuilderTable; if (table && table[`gen${this.gen}doubles`]) { @@ -717,7 +717,7 @@ const Dex = new class implements ModdedDex { if (pokemon.species && !spriteid) { spriteid = template.spriteid || toID(pokemon.species); } - if (Dex.getTemplate(pokemon.species).exists === false) { + if (template.exists === false) { return 'background-image:url(' + Dex.resourcePrefix + 'sprites/gen5/0.png);background-position:10px 5px;background-repeat:no-repeat'; } let shiny = (pokemon.shiny ? '-shiny' : ''); @@ -737,6 +737,7 @@ const Dex = new class implements ModdedDex { let xydexExists = !template.isNonstandard || [ "pikachustarter", "eeveestarter", "meltan", "melmetal", "fidgit", "stratagem", "tomohawk", "mollux", "crucibelle", "crucibellemega", "kerfluffle", "pajantom", "jumbao", "caribolt", "smokomodo", "snaelstrom", "equilibra", "scratchet", "pluffle", "smogecko", "pokestarufo", "pokestarufo2", "pokestarbrycenman", "pokestarmt", "pokestarmt2", "pokestargiant", "pokestarhumanoid", "pokestarmonster", "pokestarf00", "pokestarf002", "pokestarspirit", ].includes(template.id); + if (template.gen === 8) xydexExists = false; if ((!gen || gen >= 6) && xydexExists && !Dex.prefs('bwgfx')) { let offset = '-2px -3px'; if (template.gen >= 7) offset = '-6px -7px';