mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 06:49:35 +02:00
get / set generation
This commit is contained in:
parent
42d45c6254
commit
7bf7574306
@ -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;
|
||||
|
@ -403,7 +403,7 @@ function getPokemonTradeOptions(scene: BattleScene): Map<number, EnemyPokemon[]>
|
||||
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);
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user