From 03819dd36e45385d8cb6dedee91f8d69d8242426 Mon Sep 17 00:00:00 2001 From: frutescens Date: Thu, 19 Sep 2024 17:00:34 -0700 Subject: [PATCH] formIndex set to protected --- src/battle-scene.ts | 10 +++++----- src/data/daily-run.ts | 2 +- src/data/move.ts | 10 +++++----- src/data/pokemon-species.ts | 20 ++++++++++++++++++-- src/field/pokemon.ts | 8 ++++---- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index c8100e0d3b9..8c48804d40d 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -2752,15 +2752,15 @@ export default class BattleScene extends SceneBase { const keys: string[] = []; const playerParty = this.getParty(); playerParty.forEach(p => { - keys.push("pkmn__" + p.species.getSpriteId(p.gender === Gender.FEMALE, p.species.formIndex, p.shiny, p.variant)); - keys.push("pkmn__" + p.species.getSpriteId(p.gender === Gender.FEMALE, p.species.formIndex, p.shiny, p.variant, true)); - keys.push("cry/" + p.species.getCryKey(p.species.formIndex)); + keys.push("pkmn__" + p.species.getSpriteId(p.gender === Gender.FEMALE, p.species.getFormIndex(), p.shiny, p.variant)); + keys.push("pkmn__" + p.species.getSpriteId(p.gender === Gender.FEMALE, p.species.getFormIndex(), p.shiny, p.variant, true)); + keys.push("cry/" + p.species.getCryKey(p.species.getFormIndex())); }); // enemyParty has to be operated on separately from playerParty because playerPokemon =/= enemyPokemon const enemyParty = this.getEnemyParty(); enemyParty.forEach(p => { - keys.push(p.species.getSpriteKey(p.gender === Gender.FEMALE, p.species.formIndex, p.shiny, p.variant)); - keys.push("cry/" + p.species.getCryKey(p.species.formIndex)); + keys.push(p.species.getSpriteKey(p.gender === Gender.FEMALE, p.species.getFormIndex(), p.shiny, p.variant)); + keys.push("cry/" + p.species.getCryKey(p.species.getFormIndex())); }); return keys; } diff --git a/src/data/daily-run.ts b/src/data/daily-run.ts index 370b13ea3a3..80bc01ed408 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.formIndex; + const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.getFormIndex(); 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 14d7addead0..420ef99f76e 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3896,7 +3896,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?.formIndex!; // TODO: is this bang correct? + const form = user.species.speciesId === Species.ARCEUS || user.species.speciesId === Species.SILVALLY ? user.formIndex : user.fusionSpecies?.getFormIndex()!; moveType.value = Type[Type[form]]; return true; @@ -3914,7 +3914,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?.formIndex; + const form = user.species.speciesId === Species.GENESECT ? user.formIndex : user.fusionSpecies?.getFormIndex(); switch (form) { case 1: // Shock Drive @@ -3948,7 +3948,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?.formIndex; + const form = user.species.speciesId === Species.MORPEKO ? user.formIndex : user.fusionSpecies?.getFormIndex(); switch (form) { case 1: // Hangry Mode @@ -3973,7 +3973,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?.formIndex; + const form = user.species.speciesId === Species.PALDEA_TAUROS ? user.formIndex : user.fusionSpecies?.getFormIndex(); switch (form) { case 1: // Blaze breed @@ -4001,7 +4001,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?.formIndex; + const form = user.species.speciesId === Species.OGERPON ? user.formIndex : user.fusionSpecies?.getFormIndex(); switch (form) { case 1: // Wellspring Mask diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index b3a566cfca5..f46e289262c 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; - public formIndex: number; + protected formIndex: number; protected generation: number; readonly type1: Type; readonly type2: Type | null; @@ -194,6 +194,22 @@ export abstract class PokemonSpeciesForm { this.generation = generation; } + /** + * Method to retrieve the form index of a Pokemon species + * @returns the form index + */ + getFormIndex(): 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; + } + isOfType(type: number): boolean { return this.type1 === type || (this.type2 !== null && this.type2 === type); } @@ -629,7 +645,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali forms.forEach((form, f) => { form.speciesId = id; - form.formIndex = f; + form.setFormIndex(f); form.setGeneration(generation); }); } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index e0a9a4a86ce..9e9dc96191a 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3191,10 +3191,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.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 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 sourceTexture = this.scene.textures.get(spriteKey); const sourceBackTexture = this.scene.textures.get(backSpriteKey);