From f3e48d6e8dedf2e2a68b765ec86648dc7151881f Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 7 Oct 2023 14:12:46 -0400 Subject: [PATCH] fix: default-form-id handling --- package.json | 2 +- src/classes/Pokemon.ts | 49 +++++++++++++++++----------------------- src/index.ts | 4 ++-- tests/defaultValues.json | 8 ++++++- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 92f95f1..25706cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pogo-data-generator", - "version": "1.16.4", + "version": "1.16.5", "description": "Pokemon GO project data generator", "author": "TurtIeSocks", "license": "Apache-2.0", diff --git a/src/classes/Pokemon.ts b/src/classes/Pokemon.ts index 1a39581..15047b7 100644 --- a/src/classes/Pokemon.ts +++ b/src/classes/Pokemon.ts @@ -55,7 +55,7 @@ export default class Pokemon extends Masterfile { this.parsedPokemon = {} this.parsedForms = { 0: { - formName: options.unsetFormName, + formName: options.unsetFormName ?? 'Unset', proto: 'FORM_UNSET', formId: 0, }, @@ -533,27 +533,27 @@ export default class Pokemon extends Masterfile { const id: number = Rpc.HoloPokemonId[pkmn as PokemonIdProto] const formName = this.formName(id, name) - if (!this.skipForms(formName)) { - if (!this.parsedPokemon[id]) { - this.parsedPokemon[id] = { - pokemonName: this.pokemonName(id), - forms: - this.options.includeUnset && - !this.options.noFormPlaceholders - ? [0] - : [], - pokedexId: id, - ...this.getGeneration(+id), - } - } - if (this.parsedPokemon[id].defaultFormId === undefined) { - this.parsedPokemon[id].defaultFormId = - this.options.unsetDefaultForm && - this.options.includeUnset && - this.parsedPokemon[id].forms.includes(0) - ? 0 - : +formId + if (!this.parsedPokemon[id]) { + this.parsedPokemon[id] = { + pokemonName: this.pokemonName(id), + forms: + this.options.includeUnset && !this.options.noFormPlaceholders + ? [0] + : [], + pokedexId: id, + defaultFormId: 0, + ...this.getGeneration(+id), } + } + + if ( + !this.skipForms(formName) && + !( + this.parsedPokemon[id].defaultFormId === 0 && + formName === 'Normal' && + this.options.skipNormalIfUnset + ) + ) { if (!this.parsedForms[formId]) { this.parsedForms[formId] = { formName, @@ -561,13 +561,6 @@ export default class Pokemon extends Masterfile { formId: +formId, } } - if ( - this.parsedPokemon[id].defaultFormId === 0 && - formName === 'Normal' && - this.options.skipNormalIfUnset - ) { - return - } switch (formId) { case Rpc.PokemonDisplayProto.Form.TYPHLOSION_HISUIAN: this.addFormBaseStats(formId, 73, 84, 78, 119, 85, 95) diff --git a/src/index.ts b/src/index.ts index 69791c1..51252f2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -110,11 +110,11 @@ export async function generate({ AllTypes.buildTypes() + AllPokemon.missingPokemon() + AllPokemon.parseCostumes() if (pokemon.options.includeProtos || translations.options.includeProtos) { AllPokemon.generateProtoForms() } - AllPokemon.missingPokemon() - AllPokemon.parseCostumes() AllPokemon.sortForms() if (pokeApi === true) { diff --git a/tests/defaultValues.json b/tests/defaultValues.json index a1f080c..650c187 100644 --- a/tests/defaultValues.json +++ b/tests/defaultValues.json @@ -244,8 +244,12 @@ "531": { "name": "Audino", "pokedex_id": 531, - "default_form_id": 1997, + "default_form_id": 0, "forms": { + "0": { + "name": "Unset", + "proto": "FORM_UNSET" + }, "1997": { "name": "Normal", "proto": "AUDINO_NORMAL", @@ -311,6 +315,7 @@ "default_form_id": 0, "forms": { "0": { + "name": "Unset", "proto": "FORM_UNSET" } }, @@ -504,6 +509,7 @@ "generation": "Kalos", "forms": { "0": { + "name": "Unset", "proto": "FORM_UNSET" } },