Use get/set for formIndex too

This commit is contained in:
NightKev 2024-11-02 08:00:57 -07:00
parent b977493b0f
commit df3c3db5bd
5 changed files with 18 additions and 34 deletions

View File

@ -60,7 +60,7 @@ export function getDailyRunStarters(scene: BattleScene, seed: string): Starter[]
function getDailyRunStarter(scene: BattleScene, starterSpeciesForm: PokemonSpeciesForm, startingLevel: integer): Starter { function getDailyRunStarter(scene: BattleScene, starterSpeciesForm: PokemonSpeciesForm, startingLevel: integer): Starter {
const starterSpecies = starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId); 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 pokemon = new PlayerPokemon(scene, starterSpecies, startingLevel, undefined, formIndex, undefined, undefined, undefined, undefined, undefined, undefined);
const starter: Starter = { const starter: Starter = {
species: starterSpecies, species: starterSpecies,

View File

@ -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)) { 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]]; moveType.value = Type[Type[form]];
return true; return true;
@ -4029,7 +4029,7 @@ export class TechnoBlastTypeAttr extends VariableMoveTypeAttr {
} }
if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.GENESECT)) { 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) { switch (form) {
case 1: // Shock Drive case 1: // Shock Drive
@ -4063,7 +4063,7 @@ export class AuraWheelTypeAttr extends VariableMoveTypeAttr {
} }
if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.MORPEKO)) { 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) { switch (form) {
case 1: // Hangry Mode case 1: // Hangry Mode
@ -4088,7 +4088,7 @@ export class RagingBullTypeAttr extends VariableMoveTypeAttr {
} }
if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.PALDEA_TAUROS)) { 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) { switch (form) {
case 1: // Blaze breed case 1: // Blaze breed
@ -4116,7 +4116,7 @@ export class IvyCudgelTypeAttr extends VariableMoveTypeAttr {
} }
if ([user.species.speciesId, user.fusionSpecies?.speciesId].includes(Species.OGERPON)) { 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) { switch (form) {
case 1: // Wellspring Mask case 1: // Wellspring Mask

View File

@ -71,10 +71,10 @@ export const ThePokemonSalesmanEncounter: MysteryEncounter =
// If no HA mon found or you roll 1%, give shiny Magikarp // If no HA mon found or you roll 1%, give shiny Magikarp
species = getPokemonSpecies(Species.MAGIKARP); species = getPokemonSpecies(Species.MAGIKARP);
const hiddenIndex = species.ability2 ? 2 : 1; 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 { } else {
const hiddenIndex = species.ability2 ? 2 : 1; 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(); pokemon.generateAndPopulateMoveset();

View File

@ -127,7 +127,7 @@ export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;
export abstract class PokemonSpeciesForm { export abstract class PokemonSpeciesForm {
public speciesId: Species; public speciesId: Species;
protected formIndex: number; protected _formIndex: number;
protected _generation: number; protected _generation: number;
readonly type1: Type; readonly type1: Type;
readonly type2: Type | null; readonly type2: Type | null;
@ -178,36 +178,20 @@ export abstract class PokemonSpeciesForm {
return ret; return ret;
} }
/**
* Method to retrieve the origin generation of a Pokemon species
* @returns a number
*/
get generation(): number { get generation(): number {
return this._generation; return this._generation;
} }
/**
* Method to set the generation of a specific form
* @param the generation of the form involved
*/
set generation(generation: number) { set generation(generation: number) {
this._generation = generation; this._generation = generation;
} }
/** get formIndex(): number {
* Method to retrieve the form index of a Pokemon species return this._formIndex;
* @returns the form index
*/
getFormIndex(): number {
return this.formIndex;
} }
/** set formIndex(formIndex: number) {
* Method to set the form index of a specific Pokemon species this._formIndex = formIndex;
* @param the form index
*/
setFormIndex(formIndex: number) {
this.formIndex = formIndex;
} }
isOfType(type: number): boolean { isOfType(type: number): boolean {
@ -653,7 +637,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
forms.forEach((form, f) => { forms.forEach((form, f) => {
form.speciesId = id; form.speciesId = id;
form.setFormIndex(f); form.formIndex = f;
form.generation = generation; form.generation = generation;
}); });
} }

View File

@ -3512,10 +3512,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
const speciesForm = this.getSpeciesForm(ignoreOveride); const speciesForm = this.getSpeciesForm(ignoreOveride);
const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOveride); const fusionSpeciesForm = this.getFusionSpeciesForm(ignoreOveride);
const spriteKey = speciesForm.getSpriteKey(this.getGender(ignoreOveride) === Gender.FEMALE, speciesForm.getFormIndex(), this.shiny, this.variant); 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.getFormIndex(), this.shiny, this.variant).replace("pkmn__", "pkmn__back__"); 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.getFormIndex(), this.fusionShiny, this.fusionVariant); 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.getFormIndex(), this.fusionShiny, this.fusionVariant).replace("pkmn__", "pkmn__back__"); 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 sourceTexture = this.scene.textures.get(spriteKey);
const sourceBackTexture = this.scene.textures.get(backSpriteKey); const sourceBackTexture = this.scene.textures.get(backSpriteKey);