Skip to content

Commit

Permalink
Merge pull request #90 from WatWowMap/default-form-id-fixes
Browse files Browse the repository at this point in the history
fix: default-form-id handling
  • Loading branch information
TurtIeSocks authored Oct 7, 2023
2 parents 6327e5b + f3e48d6 commit 5608afb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
49 changes: 21 additions & 28 deletions src/classes/Pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -533,41 +533,34 @@ 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,
proto: name,
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)
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion tests/defaultValues.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -311,6 +315,7 @@
"default_form_id": 0,
"forms": {
"0": {
"name": "Unset",
"proto": "FORM_UNSET"
}
},
Expand Down Expand Up @@ -504,6 +509,7 @@
"generation": "Kalos",
"forms": {
"0": {
"name": "Unset",
"proto": "FORM_UNSET"
}
},
Expand Down

0 comments on commit 5608afb

Please sign in to comment.