From df3c3db5bd8443360aa22f27576bab782e7bc3e3 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Sat, 2 Nov 2024 08:00:57 -0700 Subject: [PATCH] Use get/set for formIndex too --- src/data/daily-run.ts | 2 +- src/data/move.ts | 10 +++---- .../the-pokemon-salesman-encounter.ts | 4 +-- src/data/pokemon-species.ts | 28 ++++--------------- src/field/pokemon.ts | 8 +++--- 5 files changed, 18 insertions(+), 34 deletions(-) diff --git a/src/data/daily-run.ts b/src/data/daily-run.ts index 80bc01ed408..370b13ea3a3 100644 --- a/src/data/daily-run.ts +++ b/src/data/daily-run.ts @@ -60,7 +60,7 @@ export function getDailyRunStarters(scene: BattleScene, seed: string): Starter[] function getDailyRunStarter(scene: BattleScene, starterSpeciesForm: PokemonSpeciesForm, startingLevel: integer): Starter { const starterSpecies = starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId); - const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.getFormIndex(); + const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex; const pokemon = new PlayerPokemon(scene, starterSpecies, startingLevel, undefined, formIndex, undefined, undefined, undefined, undefined, undefined, undefined); const starter: Starter = { species: starterSpecies, diff --git a/src/data/move.ts b/src/data/move.ts index 73b24ed2f73..8422a8abd31 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4011,7 +4011,7 @@ export class FormChangeItemTypeAttr extends VariableMoveTypeAttr { } if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.ARCEUS) || [user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.SILVALLY)) { - const form = user.species.speciesId === Species.ARCEUS || user.species.speciesId === Species.SILVALLY ? user.formIndex : user.fusionSpecies?.getFormIndex()!; + const form = user.species.speciesId === Species.ARCEUS || user.species.speciesId === Species.SILVALLY ? user.formIndex : user.fusionSpecies?.formIndex!; moveType.value = Type[Type[form]]; return true; @@ -4029,7 +4029,7 @@ export class TechnoBlastTypeAttr extends VariableMoveTypeAttr { } if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.GENESECT)) { - const form = user.species.speciesId === Species.GENESECT ? user.formIndex : user.fusionSpecies?.getFormIndex(); + const form = user.species.speciesId === Species.GENESECT ? user.formIndex : user.fusionSpecies?.formIndex; switch (form) { case 1: // Shock Drive @@ -4063,7 +4063,7 @@ export class AuraWheelTypeAttr extends VariableMoveTypeAttr { } if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.MORPEKO)) { - const form = user.species.speciesId === Species.MORPEKO ? user.formIndex : user.fusionSpecies?.getFormIndex(); + const form = user.species.speciesId === Species.MORPEKO ? user.formIndex : user.fusionSpecies?.formIndex; switch (form) { case 1: // Hangry Mode @@ -4088,7 +4088,7 @@ export class RagingBullTypeAttr extends VariableMoveTypeAttr { } if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.PALDEA_TAUROS)) { - const form = user.species.speciesId === Species.PALDEA_TAUROS ? user.formIndex : user.fusionSpecies?.getFormIndex(); + const form = user.species.speciesId === Species.PALDEA_TAUROS ? user.formIndex : user.fusionSpecies?.formIndex; switch (form) { case 1: // Blaze breed @@ -4116,7 +4116,7 @@ export class IvyCudgelTypeAttr extends VariableMoveTypeAttr { } if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.OGERPON)) { - const form = user.species.speciesId === Species.OGERPON ? user.formIndex : user.fusionSpecies?.getFormIndex(); + const form = user.species.speciesId === Species.OGERPON ? user.formIndex : user.fusionSpecies?.formIndex; switch (form) { case 1: // Wellspring Mask diff --git a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts index 57ff026c7da..c26c6aa3b7f 100644 --- a/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-pokemon-salesman-encounter.ts @@ -71,10 +71,10 @@ export const ThePokemonSalesmanEncounter: MysteryEncounter = // If no HA mon found or you roll 1%, give shiny Magikarp species = getPokemonSpecies(Species.MAGIKARP); const hiddenIndex = species.ability2 ? 2 : 1; - pokemon = new PlayerPokemon(scene, species, 5, hiddenIndex, species.getFormIndex(), undefined, true); + pokemon = new PlayerPokemon(scene, species, 5, hiddenIndex, species.formIndex, undefined, true); } else { const hiddenIndex = species.ability2 ? 2 : 1; - pokemon = new PlayerPokemon(scene, species, 5, hiddenIndex, species.getFormIndex()); + pokemon = new PlayerPokemon(scene, species, 5, hiddenIndex, species.formIndex); } pokemon.generateAndPopulateMoveset(); diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 3f31da01b70..2ddfdac2112 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -127,7 +127,7 @@ export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean; export abstract class PokemonSpeciesForm { public speciesId: Species; - protected formIndex: number; + protected _formIndex: number; protected _generation: number; readonly type1: Type; readonly type2: Type | null; @@ -178,36 +178,20 @@ export abstract class PokemonSpeciesForm { return ret; } - /** - * Method to retrieve the origin generation of a Pokemon species - * @returns a number - */ get generation(): number { return this._generation; } - /** - * Method to set the generation of a specific form - * @param the generation of the form involved - */ set generation(generation: number) { this._generation = generation; } - /** - * Method to retrieve the form index of a Pokemon species - * @returns the form index - */ - getFormIndex(): number { - return this.formIndex; + get formIndex(): number { + return this._formIndex; } - /** - * Method to set the form index of a specific Pokemon species - * @param the form index - */ - setFormIndex(formIndex: number) { - this.formIndex = formIndex; + set formIndex(formIndex: number) { + this._formIndex = formIndex; } isOfType(type: number): boolean { @@ -653,7 +637,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali forms.forEach((form, f) => { form.speciesId = id; - form.setFormIndex(f); + form.formIndex = f; form.generation = generation; }); } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 98ecd3cd85d..5cfdb333db2 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3512,10 +3512,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const speciesForm = this.getSpeciesForm(ignoreOveride); const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOveride); - const spriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.getFormIndex(), this.shiny, this.variant); - const backSpriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.getFormIndex(), this.shiny, this.variant).replace("pkmn__", "pkmn__back__"); - const fusionSpriteKey = fusionSpeciesForm.getSpriteKey(this.getFusionGender(ignoreOveride) === Gender.FEMALE, fusionSpeciesForm.getFormIndex(), this.fusionShiny, this.fusionVariant); - const fusionBackSpriteKey = fusionSpeciesForm.getSpriteKey(this.getFusionGender(ignoreOveride) === Gender.FEMALE, fusionSpeciesForm.getFormIndex(), this.fusionShiny, this.fusionVariant).replace("pkmn__", "pkmn__back__"); + const spriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.formIndex, this.shiny, this.variant); + const backSpriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.formIndex, this.shiny, this.variant).replace("pkmn__", "pkmn__back__"); + const fusionSpriteKey = fusionSpeciesForm.getSpriteKey(this.getFusionGender(ignoreOveride) === Gender.FEMALE, fusionSpeciesForm.formIndex, this.fusionShiny, this.fusionVariant); + const fusionBackSpriteKey = fusionSpeciesForm.getSpriteKey(this.getFusionGender(ignoreOveride) === Gender.FEMALE, fusionSpeciesForm.formIndex, this.fusionShiny, this.fusionVariant).replace("pkmn__", "pkmn__back__"); const sourceTexture = this.scene.textures.get(spriteKey); const sourceBackTexture = this.scene.textures.get(backSpriteKey);