diff --git a/src/data/challenge.ts b/src/data/challenge.ts index f5dd2ddba2e..111050ec589 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -417,7 +417,7 @@ export class SingleGenerationChallenge extends Challenge { } applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean { - const generations = [pokemon.getGeneration()]; + const generations = [pokemon.generation]; if (soft) { const speciesToCheck = [pokemon.speciesId]; while (speciesToCheck.length) { @@ -425,7 +425,7 @@ export class SingleGenerationChallenge extends Challenge { if (checking && pokemonEvolutions.hasOwnProperty(checking)) { pokemonEvolutions[checking].forEach(e => { speciesToCheck.push(e.speciesId); - generations.push(getPokemonSpecies(e.speciesId).getGeneration()); + generations.push(getPokemonSpecies(e.speciesId).generation); }); } } @@ -439,7 +439,7 @@ export class SingleGenerationChallenge extends Challenge { } applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean { - const baseGeneration = pokemon.species.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.species.speciesId).getGeneration(); + const baseGeneration = pokemon.species.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.species.speciesId).generation; const fusionGeneration = pokemon.isFusion() ? pokemon.fusionSpecies?.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.fusionSpecies!.speciesId).getGeneration() : 0; // TODO: is the bang on fusionSpecies correct? if (pokemon.isPlayer() && (baseGeneration !== this.value || (pokemon.isFusion() && fusionGeneration !== this.value))) { valid.value = false; diff --git a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts index 636b2513b83..55d4953d438 100644 --- a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts +++ b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts @@ -403,7 +403,7 @@ function getPokemonTradeOptions(scene: BattleScene): Map scene.getParty().forEach(pokemon => { // If the party member is legendary/mythical, the only trade options available are always pulled from generation-specific legendary trade pools if (pokemon.species.legendary || pokemon.species.subLegendary || pokemon.species.mythical) { - const generation = pokemon.species.getGeneration(); + const generation = pokemon.species.generation; const tradeOptions: EnemyPokemon[] = LEGENDARY_TRADE_POOLS[generation].map(s => { const pokemonSpecies = getPokemonSpecies(s); return new EnemyPokemon(scene, pokemonSpecies, 5, TrainerSlot.NONE, false); diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 6080aac4923..3f31da01b70 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -128,7 +128,7 @@ export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean; export abstract class PokemonSpeciesForm { public speciesId: Species; protected formIndex: number; - protected generation: number; + protected _generation: number; readonly type1: Type; readonly type2: Type | null; readonly height: number; @@ -182,16 +182,16 @@ export abstract class PokemonSpeciesForm { * Method to retrieve the origin generation of a Pokemon species * @returns a number */ - getGeneration(): number { - return this.generation; + get generation(): number { + return this._generation; } /** * Method to set the generation of a specific form * @param the generation of the form involved */ - setGeneration(generation: number) { - this.generation = generation; + set generation(generation: number) { + this._generation = generation; } /** @@ -654,7 +654,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali forms.forEach((form, f) => { form.speciesId = id; form.setFormIndex(f); - form.setGeneration(generation); + form.generation = generation; }); } diff --git a/src/test/ui/starter-select.test.ts b/src/test/ui/starter-select.test.ts index 5d479fa372c..6d26ebfd6b3 100644 --- a/src/test/ui/starter-select.test.ts +++ b/src/test/ui/starter-select.test.ts @@ -578,7 +578,7 @@ describe("UI - Starter select", () => { }); expect(starterSelectUiHandler?.starterSpecies.length).toBe(1); - expect(starterSelectUiHandler?.starterSpecies[0].getGeneration()).toBe(1); + expect(starterSelectUiHandler?.starterSpecies[0].generation).toBe(1); expect(starterSelectUiHandler?.starterSpecies[0].speciesId).toBe(32); expect(starterSelectUiHandler?.cursorObj.x).toBe(53); expect(starterSelectUiHandler?.cursorObj.y).toBe(31); diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index b55b9f2c6c0..1d598f6ac4e 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -363,7 +363,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { if (!this.player) { if (this.nameText.visible) { - this.nameText.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip("", i18next.t("battleInfo:generation", { generation: i18next.t(`starterSelectUiHandler:gen${pokemon.species.getGeneration()}`) }))); + this.nameText.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip("", i18next.t("battleInfo:generation", { generation: i18next.t(`starterSelectUiHandler:gen${pokemon.species.generation}`) }))); this.nameText.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip()); } diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 6cfc5a9ca01..5ef26d1ba88 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -1463,7 +1463,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, this.lastSpecies, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)), isPartyValid); - const currentPartyValue = this.starterSpecies.map(s => s.getGeneration()).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); + const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); const newCost = this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId); if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < 6) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party options = [ @@ -2415,7 +2415,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { const isStarterProgressable = speciesEggMoves.hasOwnProperty(container.species.speciesId); // Gen filter - const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.getGeneration()); + const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation); // Type filter const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => container.species.isOfType((type as number) - 1)); @@ -3382,7 +3382,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } tryUpdateValue(add?: integer, addingToParty?: boolean): boolean { - const value = this.starterSpecies.map(s => s.getGeneration()).reduce((total: integer, gen: integer, i: integer) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); + const value = this.starterSpecies.map(s => s.generation).reduce((total: integer, gen: integer, i: integer) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0); const newValue = value + (add || 0); const valueLimit = this.getValueLimit(); const overLimit = newValue > valueLimit;