diff --git a/src/battle-phases.ts b/src/battle-phases.ts index fdde003e3..e3b89507c 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -284,7 +284,7 @@ export class SelectStarterPhase extends BattlePhase { const loadPokemonAssets: Promise[] = []; for (let starter of starters) { const starterProps = this.scene.gameData.getSpeciesDexAttrProps(starter.species, starter.dexAttr); - const starterFormIndex = Math.min(starterProps.formIndex, starter.species.forms.length - 1); + const starterFormIndex = Math.min(starterProps.formIndex, Math.max(starter.species.forms.length - 1, 0)); const starterGender = starter.species.malePercent !== null ? !starterProps.female ? Gender.MALE : Gender.FEMALE : Gender.GENDERLESS; diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index cec9e062a..e566e67dd 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -352,7 +352,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm { getName(formIndex?: integer): string { if (formIndex !== undefined && this.forms.length) { - const form = this.forms[Math.min(formIndex, this.forms.length - 1)]; + const form = this.forms[formIndex]; switch (form.formKey) { case SpeciesFormKey.MEGA: case SpeciesFormKey.ETERNAMAX: diff --git a/src/system/pokemon-data.ts b/src/system/pokemon-data.ts index 3d8cc97a8..46cd439b0 100644 --- a/src/system/pokemon-data.ts +++ b/src/system/pokemon-data.ts @@ -7,7 +7,7 @@ import { PokeballType } from "../data/pokeball"; import { getPokemonSpecies } from "../data/pokemon-species"; import { Species } from "../data/enums/species"; import { Status } from "../data/status-effect"; -import Pokemon, { EnemyPokemon, PlayerPokemon, PokemonMove, PokemonSummonData } from "../pokemon"; +import Pokemon, { EnemyPokemon, PokemonMove, PokemonSummonData } from "../pokemon"; export default class PokemonData { public id: integer; @@ -48,7 +48,7 @@ export default class PokemonData { this.id = source.id; this.player = sourcePokemon ? sourcePokemon.isPlayer() : source.player; this.species = sourcePokemon ? sourcePokemon.species.speciesId : source.species; - this.formIndex = source.formIndex; + this.formIndex = Math.max(Math.min(source.formIndex, getPokemonSpecies(this.species).forms.length - 1), 0); this.abilityIndex = source.abilityIndex; this.shiny = source.shiny; this.pokeball = source.pokeball;