mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-29 11:42:21 +02:00
set generations to protected
This commit is contained in:
parent
42bbd1cda8
commit
1c6ecf6252
@ -417,7 +417,7 @@ export class SingleGenerationChallenge extends Challenge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean {
|
applyStarterChoice(pokemon: PokemonSpecies, valid: Utils.BooleanHolder, dexAttr: DexAttrProps, soft: boolean = false): boolean {
|
||||||
const generations = [pokemon.generation];
|
const generations = [pokemon.getGeneration()];
|
||||||
if (soft) {
|
if (soft) {
|
||||||
const speciesToCheck = [pokemon.speciesId];
|
const speciesToCheck = [pokemon.speciesId];
|
||||||
while (speciesToCheck.length) {
|
while (speciesToCheck.length) {
|
||||||
@ -425,7 +425,7 @@ export class SingleGenerationChallenge extends Challenge {
|
|||||||
if (checking && pokemonEvolutions.hasOwnProperty(checking)) {
|
if (checking && pokemonEvolutions.hasOwnProperty(checking)) {
|
||||||
pokemonEvolutions[checking].forEach(e => {
|
pokemonEvolutions[checking].forEach(e => {
|
||||||
speciesToCheck.push(e.speciesId);
|
speciesToCheck.push(e.speciesId);
|
||||||
generations.push(getPokemonSpecies(e.speciesId).generation);
|
generations.push(getPokemonSpecies(e.speciesId).getGeneration());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,8 +439,8 @@ export class SingleGenerationChallenge extends Challenge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean {
|
applyPokemonInBattle(pokemon: Pokemon, valid: Utils.BooleanHolder): boolean {
|
||||||
const baseGeneration = pokemon.species.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.species.speciesId).generation;
|
const baseGeneration = pokemon.species.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.species.speciesId).getGeneration();
|
||||||
const fusionGeneration = pokemon.isFusion() ? pokemon.fusionSpecies?.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.fusionSpecies!.speciesId).generation : 0; // TODO: is the bang on fusionSpecies correct?
|
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))) {
|
if (pokemon.isPlayer() && (baseGeneration !== this.value || (pokemon.isFusion() && fusionGeneration !== this.value))) {
|
||||||
valid.value = false;
|
valid.value = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -45,7 +45,7 @@ export function getPokemonSpecies(species: Species | Species[] | undefined): Pok
|
|||||||
return allSpecies[species - 1];
|
return allSpecies[species - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPokemonSpeciesForm(species: Species, formIndex: integer): PokemonSpeciesForm {
|
export function getPokemonSpeciesForm(species: Species, formIndex: number): PokemonSpeciesForm {
|
||||||
const retSpecies: PokemonSpecies = species >= 2000
|
const retSpecies: PokemonSpecies = species >= 2000
|
||||||
? allSpecies.find(s => s.speciesId === species)! // TODO: is the bang correct?
|
? allSpecies.find(s => s.speciesId === species)! // TODO: is the bang correct?
|
||||||
: allSpecies[species - 1];
|
: allSpecies[species - 1];
|
||||||
@ -127,26 +127,26 @@ export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;
|
|||||||
|
|
||||||
export abstract class PokemonSpeciesForm {
|
export abstract class PokemonSpeciesForm {
|
||||||
public speciesId: Species;
|
public speciesId: Species;
|
||||||
public formIndex: integer;
|
public formIndex: number;
|
||||||
public generation: integer;
|
protected generation: number;
|
||||||
public type1: Type;
|
readonly type1: Type;
|
||||||
public type2: Type | null;
|
readonly type2: Type | null;
|
||||||
public height: number;
|
readonly height: number;
|
||||||
public weight: number;
|
readonly weight: number;
|
||||||
public ability1: Abilities;
|
readonly ability1: Abilities;
|
||||||
public ability2: Abilities;
|
readonly ability2: Abilities;
|
||||||
public abilityHidden: Abilities;
|
readonly abilityHidden: Abilities;
|
||||||
public baseTotal: integer;
|
readonly baseTotal: number;
|
||||||
public baseStats: integer[];
|
readonly baseStats: number[];
|
||||||
public catchRate: integer;
|
readonly catchRate: number;
|
||||||
public baseFriendship: integer;
|
readonly baseFriendship: number;
|
||||||
public baseExp: integer;
|
readonly baseExp: number;
|
||||||
public genderDiffs: boolean;
|
readonly genderDiffs: boolean;
|
||||||
public isStarterSelectable: boolean;
|
readonly isStarterSelectable: boolean;
|
||||||
|
|
||||||
constructor(type1: Type, type2: Type | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities,
|
constructor(type1: Type, type2: Type | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities,
|
||||||
baseTotal: integer, baseHp: integer, baseAtk: integer, baseDef: integer, baseSpatk: integer, baseSpdef: integer, baseSpd: integer,
|
baseTotal: number, baseHp: number, baseAtk: number, baseDef: number, baseSpatk: number, baseSpdef: number, baseSpd: number,
|
||||||
catchRate: integer, baseFriendship: integer, baseExp: integer, genderDiffs: boolean, isStarterSelectable: boolean) {
|
catchRate: number, baseFriendship: number, baseExp: number, genderDiffs: boolean, isStarterSelectable: boolean) {
|
||||||
this.type1 = type1;
|
this.type1 = type1;
|
||||||
this.type2 = type2;
|
this.type2 = type2;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
@ -178,7 +178,23 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
isOfType(type: integer): boolean {
|
/**
|
||||||
|
* Method to retrieve the origin generation of a Pokemon species
|
||||||
|
* @returns a number
|
||||||
|
*/
|
||||||
|
getGeneration(): 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
isOfType(type: number): boolean {
|
||||||
return this.type1 === type || (this.type2 !== null && this.type2 === type);
|
return this.type1 === type || (this.type2 !== null && this.type2 === type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +202,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
* Method to get the total number of abilities a Pokemon species has.
|
* Method to get the total number of abilities a Pokemon species has.
|
||||||
* @returns Number of abilities
|
* @returns Number of abilities
|
||||||
*/
|
*/
|
||||||
getAbilityCount(): integer {
|
getAbilityCount(): number {
|
||||||
return this.abilityHidden !== Abilities.NONE ? 3 : 2;
|
return this.abilityHidden !== Abilities.NONE ? 3 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +211,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
* @param abilityIndex Which ability to get (should only be 0-2)
|
* @param abilityIndex Which ability to get (should only be 0-2)
|
||||||
* @returns The id of the Ability
|
* @returns The id of the Ability
|
||||||
*/
|
*/
|
||||||
getAbility(abilityIndex: integer): Abilities {
|
getAbility(abilityIndex: number): Abilities {
|
||||||
let ret: Abilities;
|
let ret: Abilities;
|
||||||
if (abilityIndex === 0) {
|
if (abilityIndex === 0) {
|
||||||
ret = this.ability1;
|
ret = this.ability1;
|
||||||
@ -248,11 +264,11 @@ export abstract class PokemonSpeciesForm {
|
|||||||
* @param stat The desired stat.
|
* @param stat The desired stat.
|
||||||
* @returns The species' base stat amount.
|
* @returns The species' base stat amount.
|
||||||
*/
|
*/
|
||||||
getBaseStat(stat: Stat): integer {
|
getBaseStat(stat: Stat): number {
|
||||||
return this.baseStats[stat];
|
return this.baseStats[stat];
|
||||||
}
|
}
|
||||||
|
|
||||||
getBaseExp(): integer {
|
getBaseExp(): number {
|
||||||
let ret = this.baseExp;
|
let ret = this.baseExp;
|
||||||
switch (this.getFormSpriteKey()) {
|
switch (this.getFormSpriteKey()) {
|
||||||
case SpeciesFormKey.MEGA:
|
case SpeciesFormKey.MEGA:
|
||||||
@ -267,12 +283,12 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpriteAtlasPath(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string {
|
getSpriteAtlasPath(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string {
|
||||||
const spriteId = this.getSpriteId(female, formIndex, shiny, variant).replace(/\_{2}/g, "/");
|
const spriteId = this.getSpriteId(female, formIndex, shiny, variant).replace(/\_{2}/g, "/");
|
||||||
return `${/_[1-3]$/.test(spriteId) ? "variant/" : ""}${spriteId}`;
|
return `${/_[1-3]$/.test(spriteId) ? "variant/" : ""}${spriteId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpriteId(female: boolean, formIndex?: integer, shiny?: boolean, variant: integer = 0, back?: boolean): string {
|
getSpriteId(female: boolean, formIndex?: number, shiny?: boolean, variant: number = 0, back?: boolean): string {
|
||||||
if (formIndex === undefined || this instanceof PokemonForm) {
|
if (formIndex === undefined || this instanceof PokemonForm) {
|
||||||
formIndex = this.formIndex;
|
formIndex = this.formIndex;
|
||||||
}
|
}
|
||||||
@ -289,11 +305,11 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return `${back ? "back__" : ""}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? "shiny__" : ""}${baseSpriteKey}${shiny && variantSet && variantSet[variant] === 2 ? `_${variant + 1}` : ""}`;
|
return `${back ? "back__" : ""}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? "shiny__" : ""}${baseSpriteKey}${shiny && variantSet && variantSet[variant] === 2 ? `_${variant + 1}` : ""}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpriteKey(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string {
|
getSpriteKey(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string {
|
||||||
return `pkmn__${this.getSpriteId(female, formIndex, shiny, variant)}`;
|
return `pkmn__${this.getSpriteId(female, formIndex, shiny, variant)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getFormSpriteKey(formIndex?: integer): string;
|
abstract getFormSpriteKey(formIndex?: number): string;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,9 +317,9 @@ export abstract class PokemonSpeciesForm {
|
|||||||
* @param formIndex optional form index for pokemon with different forms
|
* @param formIndex optional form index for pokemon with different forms
|
||||||
* @returns species id if no additional forms, index with formkey if a pokemon with a form
|
* @returns species id if no additional forms, index with formkey if a pokemon with a form
|
||||||
*/
|
*/
|
||||||
getVariantDataIndex(formIndex?: integer) {
|
getVariantDataIndex(formIndex?: number) {
|
||||||
let formkey: string | null = null;
|
let formkey: string | null = null;
|
||||||
let variantDataIndex: integer | string = this.speciesId;
|
let variantDataIndex: number | string = this.speciesId;
|
||||||
const species = getPokemonSpecies(this.speciesId);
|
const species = getPokemonSpecies(this.speciesId);
|
||||||
if (species.forms.length > 0 && formIndex !== undefined) {
|
if (species.forms.length > 0 && formIndex !== undefined) {
|
||||||
formkey = species.forms[formIndex]?.getFormSpriteKey(formIndex);
|
formkey = species.forms[formIndex]?.getFormSpriteKey(formIndex);
|
||||||
@ -314,13 +330,13 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return variantDataIndex;
|
return variantDataIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIconAtlasKey(formIndex?: integer, shiny?: boolean, variant?: integer): string {
|
getIconAtlasKey(formIndex?: number, shiny?: boolean, variant?: number): string {
|
||||||
const variantDataIndex = this.getVariantDataIndex(formIndex);
|
const variantDataIndex = this.getVariantDataIndex(formIndex);
|
||||||
const isVariant = shiny && variantData[variantDataIndex] && (variant !== undefined && variantData[variantDataIndex][variant]);
|
const isVariant = shiny && variantData[variantDataIndex] && (variant !== undefined && variantData[variantDataIndex][variant]);
|
||||||
return `pokemon_icons_${this.generation}${isVariant ? "v" : ""}`;
|
return `pokemon_icons_${this.generation}${isVariant ? "v" : ""}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIconId(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string {
|
getIconId(female: boolean, formIndex?: number, shiny?: boolean, variant?: number): string {
|
||||||
if (formIndex === undefined) {
|
if (formIndex === undefined) {
|
||||||
formIndex = this.formIndex;
|
formIndex = this.formIndex;
|
||||||
}
|
}
|
||||||
@ -369,7 +385,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCryKey(formIndex?: integer): string {
|
getCryKey(formIndex?: number): string {
|
||||||
let speciesId = this.speciesId;
|
let speciesId = this.speciesId;
|
||||||
if (this.speciesId > 2000) {
|
if (this.speciesId > 2000) {
|
||||||
switch (this.speciesId) {
|
switch (this.speciesId) {
|
||||||
@ -435,7 +451,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
validateStarterMoveset(moveset: StarterMoveset, eggMoves: integer): boolean {
|
validateStarterMoveset(moveset: StarterMoveset, eggMoves: number): boolean {
|
||||||
const rootSpeciesId = this.getRootSpeciesId();
|
const rootSpeciesId = this.getRootSpeciesId();
|
||||||
for (const moveId of moveset) {
|
for (const moveId of moveset) {
|
||||||
if (speciesEggMoves.hasOwnProperty(rootSpeciesId)) {
|
if (speciesEggMoves.hasOwnProperty(rootSpeciesId)) {
|
||||||
@ -456,7 +472,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAssets(scene: BattleScene, female: boolean, formIndex?: integer, shiny?: boolean, variant?: Variant, startLoad?: boolean): Promise<void> {
|
loadAssets(scene: BattleScene, female: boolean, formIndex?: number, shiny?: boolean, variant?: Variant, startLoad?: boolean): Promise<void> {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant);
|
const spriteKey = this.getSpriteKey(female, formIndex, shiny, variant);
|
||||||
scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant));
|
scene.loadPokemonAtlas(spriteKey, this.getSpriteAtlasPath(female, formIndex, shiny, variant));
|
||||||
@ -523,7 +539,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return cry;
|
return cry;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateCandyColors(scene: BattleScene): integer[][] {
|
generateCandyColors(scene: BattleScene): number[][] {
|
||||||
const sourceTexture = scene.textures.get(this.getSpriteKey(false));
|
const sourceTexture = scene.textures.get(this.getSpriteKey(false));
|
||||||
|
|
||||||
const sourceFrame = sourceTexture.frames[sourceTexture.firstFrame];
|
const sourceFrame = sourceTexture.frames[sourceTexture.firstFrame];
|
||||||
@ -531,7 +547,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
|
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
|
|
||||||
const spriteColors: integer[][] = [];
|
const spriteColors: number[][] = [];
|
||||||
|
|
||||||
const context = canvas.getContext("2d");
|
const context = canvas.getContext("2d");
|
||||||
const frame = sourceFrame;
|
const frame = sourceFrame;
|
||||||
@ -554,7 +570,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < pixelData.length; i += 4) {
|
for (let i = 0; i < pixelData.length; i += 4) {
|
||||||
const total = pixelData.slice(i, i + 3).reduce((total: integer, value: integer) => total + value, 0);
|
const total = pixelData.slice(i, i + 3).reduce((total: number, value: number) => total + value, 0);
|
||||||
if (!total) {
|
if (!total) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -573,7 +589,7 @@ export abstract class PokemonSpeciesForm {
|
|||||||
|
|
||||||
Math.random = originalRandom;
|
Math.random = originalRandom;
|
||||||
|
|
||||||
return Array.from(paletteColors.keys()).map(c => Object.values(rgbaFromArgb(c)) as integer[]);
|
return Array.from(paletteColors.keys()).map(c => Object.values(rgbaFromArgb(c)) as number[]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,10 +605,10 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
readonly canChangeForm: boolean;
|
readonly canChangeForm: boolean;
|
||||||
readonly forms: PokemonForm[];
|
readonly forms: PokemonForm[];
|
||||||
|
|
||||||
constructor(id: Species, generation: integer, subLegendary: boolean, legendary: boolean, mythical: boolean, species: string,
|
constructor(id: Species, generation: number, subLegendary: boolean, legendary: boolean, mythical: boolean, species: string,
|
||||||
type1: Type, type2: Type | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities,
|
type1: Type, type2: Type | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities,
|
||||||
baseTotal: integer, baseHp: integer, baseAtk: integer, baseDef: integer, baseSpatk: integer, baseSpdef: integer, baseSpd: integer,
|
baseTotal: number, baseHp: number, baseAtk: number, baseDef: number, baseSpatk: number, baseSpdef: number, baseSpd: number,
|
||||||
catchRate: integer, baseFriendship: integer, baseExp: integer, growthRate: GrowthRate, malePercent: number | null,
|
catchRate: number, baseFriendship: number, baseExp: number, growthRate: GrowthRate, malePercent: number | null,
|
||||||
genderDiffs: boolean, canChangeForm?: boolean, ...forms: PokemonForm[]) {
|
genderDiffs: boolean, canChangeForm?: boolean, ...forms: PokemonForm[]) {
|
||||||
super(type1, type2, height, weight, ability1, ability2, abilityHidden, baseTotal, baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd,
|
super(type1, type2, height, weight, ability1, ability2, abilityHidden, baseTotal, baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd,
|
||||||
catchRate, baseFriendship, baseExp, genderDiffs, false);
|
catchRate, baseFriendship, baseExp, genderDiffs, false);
|
||||||
@ -614,11 +630,11 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
forms.forEach((form, f) => {
|
forms.forEach((form, f) => {
|
||||||
form.speciesId = id;
|
form.speciesId = id;
|
||||||
form.formIndex = f;
|
form.formIndex = f;
|
||||||
form.generation = generation;
|
form.setGeneration(generation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getName(formIndex?: integer): string {
|
getName(formIndex?: number): string {
|
||||||
if (formIndex !== undefined && this.forms.length) {
|
if (formIndex !== undefined && this.forms.length) {
|
||||||
const form = this.forms[formIndex];
|
const form = this.forms[formIndex];
|
||||||
let key: string | null;
|
let key: string | null;
|
||||||
@ -649,15 +665,15 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
this.name = i18next.t(`pokemon:${Species[this.speciesId].toLowerCase()}`);
|
this.name = i18next.t(`pokemon:${Species[this.speciesId].toLowerCase()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWildSpeciesForLevel(level: integer, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): Species {
|
getWildSpeciesForLevel(level: number, allowEvolving: boolean, isBoss: boolean, gameMode: GameMode): Species {
|
||||||
return this.getSpeciesForLevel(level, allowEvolving, false, (isBoss ? PartyMemberStrength.WEAKER : PartyMemberStrength.AVERAGE) + (gameMode?.isEndless ? 1 : 0));
|
return this.getSpeciesForLevel(level, allowEvolving, false, (isBoss ? PartyMemberStrength.WEAKER : PartyMemberStrength.AVERAGE) + (gameMode?.isEndless ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
getTrainerSpeciesForLevel(level: integer, allowEvolving: boolean = false, strength: PartyMemberStrength, currentWave: number = 0): Species {
|
getTrainerSpeciesForLevel(level: number, allowEvolving: boolean = false, strength: PartyMemberStrength, currentWave: number = 0): Species {
|
||||||
return this.getSpeciesForLevel(level, allowEvolving, true, strength, currentWave);
|
return this.getSpeciesForLevel(level, allowEvolving, true, strength, currentWave);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStrengthLevelDiff(strength: PartyMemberStrength): integer {
|
private getStrengthLevelDiff(strength: PartyMemberStrength): number {
|
||||||
switch (Math.min(strength, PartyMemberStrength.STRONGER)) {
|
switch (Math.min(strength, PartyMemberStrength.STRONGER)) {
|
||||||
case PartyMemberStrength.WEAKEST:
|
case PartyMemberStrength.WEAKEST:
|
||||||
return 60;
|
return 60;
|
||||||
@ -674,7 +690,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getSpeciesForLevel(level: integer, allowEvolving: boolean = false, forTrainer: boolean = false, strength: PartyMemberStrength = PartyMemberStrength.WEAKER, currentWave: number = 0): Species {
|
getSpeciesForLevel(level: number, allowEvolving: boolean = false, forTrainer: boolean = false, strength: PartyMemberStrength = PartyMemberStrength.WEAKER, currentWave: number = 0): Species {
|
||||||
const prevolutionLevels = this.getPrevolutionLevels();
|
const prevolutionLevels = this.getPrevolutionLevels();
|
||||||
|
|
||||||
if (prevolutionLevels.length) {
|
if (prevolutionLevels.length) {
|
||||||
@ -814,7 +830,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This could definitely be written better and more accurate to the getSpeciesForLevel logic, but it is only for generating movesets for evolved Pokemon
|
// This could definitely be written better and more accurate to the getSpeciesForLevel logic, but it is only for generating movesets for evolved Pokemon
|
||||||
getSimulatedEvolutionChain(currentLevel: integer, forTrainer: boolean = false, isBoss: boolean = false, player: boolean = false): EvolutionLevel[] {
|
getSimulatedEvolutionChain(currentLevel: number, forTrainer: boolean = false, isBoss: boolean = false, player: boolean = false): EvolutionLevel[] {
|
||||||
const ret: EvolutionLevel[] = [];
|
const ret: EvolutionLevel[] = [];
|
||||||
if (pokemonPrevolutions.hasOwnProperty(this.speciesId)) {
|
if (pokemonPrevolutions.hasOwnProperty(this.speciesId)) {
|
||||||
const prevolutionLevels = this.getPrevolutionLevels().reverse();
|
const prevolutionLevels = this.getPrevolutionLevels().reverse();
|
||||||
@ -866,7 +882,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
|
|||||||
return variantData.hasOwnProperty(variantDataIndex) || variantData.hasOwnProperty(this.speciesId);
|
return variantData.hasOwnProperty(variantDataIndex) || variantData.hasOwnProperty(this.speciesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormSpriteKey(formIndex?: integer) {
|
getFormSpriteKey(formIndex?: number) {
|
||||||
if (this.forms.length && (formIndex !== undefined && formIndex >= this.forms.length)) {
|
if (this.forms.length && (formIndex !== undefined && formIndex >= this.forms.length)) {
|
||||||
console.warn(`Attempted accessing form with index ${formIndex} of species ${this.getName()} with only ${this.forms.length || 0} forms`);
|
console.warn(`Attempted accessing form with index ${formIndex} of species ${this.getName()} with only ${this.forms.length || 0} forms`);
|
||||||
formIndex = Math.min(formIndex, this.forms.length - 1);
|
formIndex = Math.min(formIndex, this.forms.length - 1);
|
||||||
@ -886,8 +902,8 @@ export class PokemonForm extends PokemonSpeciesForm {
|
|||||||
private starterSelectableKeys: string[] = ["10", "50", "10-pc", "50-pc", "red", "orange", "yellow", "green", "blue", "indigo", "violet"];
|
private starterSelectableKeys: string[] = ["10", "50", "10-pc", "50-pc", "red", "orange", "yellow", "green", "blue", "indigo", "violet"];
|
||||||
|
|
||||||
constructor(formName: string, formKey: string, type1: Type, type2: Type | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities,
|
constructor(formName: string, formKey: string, type1: Type, type2: Type | null, height: number, weight: number, ability1: Abilities, ability2: Abilities, abilityHidden: Abilities,
|
||||||
baseTotal: integer, baseHp: integer, baseAtk: integer, baseDef: integer, baseSpatk: integer, baseSpdef: integer, baseSpd: integer,
|
baseTotal: number, baseHp: number, baseAtk: number, baseDef: number, baseSpatk: number, baseSpdef: number, baseSpd: number,
|
||||||
catchRate: integer, baseFriendship: integer, baseExp: integer, genderDiffs?: boolean, formSpriteKey?: string | null, isStarterSelectable?: boolean, ) {
|
catchRate: number, baseFriendship: number, baseExp: number, genderDiffs?: boolean, formSpriteKey?: string | null, isStarterSelectable?: boolean, ) {
|
||||||
super(type1, type2, height, weight, ability1, ability2, abilityHidden, baseTotal, baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd,
|
super(type1, type2, height, weight, ability1, ability2, abilityHidden, baseTotal, baseHp, baseAtk, baseDef, baseSpatk, baseSpdef, baseSpd,
|
||||||
catchRate, baseFriendship, baseExp, !!genderDiffs, (!!isStarterSelectable || !formKey));
|
catchRate, baseFriendship, baseExp, !!genderDiffs, (!!isStarterSelectable || !formKey));
|
||||||
this.formName = formName;
|
this.formName = formName;
|
||||||
@ -895,7 +911,7 @@ export class PokemonForm extends PokemonSpeciesForm {
|
|||||||
this.formSpriteKey = formSpriteKey !== undefined ? formSpriteKey : null;
|
this.formSpriteKey = formSpriteKey !== undefined ? formSpriteKey : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getFormSpriteKey(_formIndex?: integer) {
|
getFormSpriteKey(_formIndex?: number) {
|
||||||
return this.formSpriteKey !== null ? this.formSpriteKey : this.formKey;
|
return this.formSpriteKey !== null ? this.formSpriteKey : this.formKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3303,7 +3319,7 @@ export const noStarterFormKeys: string[] = [
|
|||||||
SpeciesFormKey.ETERNAMAX
|
SpeciesFormKey.ETERNAMAX
|
||||||
].map(k => k.toString());
|
].map(k => k.toString());
|
||||||
|
|
||||||
export function getStarterValueFriendshipCap(value: integer): integer {
|
export function getStarterValueFriendshipCap(value: number): number {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 1:
|
case 1:
|
||||||
return 20;
|
return 20;
|
||||||
|
@ -578,7 +578,7 @@ describe("UI - Starter select", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(starterSelectUiHandler?.starterSpecies.length).toBe(1);
|
expect(starterSelectUiHandler?.starterSpecies.length).toBe(1);
|
||||||
expect(starterSelectUiHandler?.starterSpecies[0].generation).toBe(1);
|
expect(starterSelectUiHandler?.starterSpecies[0].getGeneration()).toBe(1);
|
||||||
expect(starterSelectUiHandler?.starterSpecies[0].speciesId).toBe(32);
|
expect(starterSelectUiHandler?.starterSpecies[0].speciesId).toBe(32);
|
||||||
expect(starterSelectUiHandler?.cursorObj.x).toBe(53);
|
expect(starterSelectUiHandler?.cursorObj.x).toBe(53);
|
||||||
expect(starterSelectUiHandler?.cursorObj.y).toBe(31);
|
expect(starterSelectUiHandler?.cursorObj.y).toBe(31);
|
||||||
|
@ -360,7 +360,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
if (!this.player) {
|
if (!this.player) {
|
||||||
if (this.nameText.visible) {
|
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.generation}`) })));
|
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("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
|
this.nameText.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1439,7 +1439,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);
|
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.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0);
|
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 newCost = this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId);
|
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
|
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 = [
|
options = [
|
||||||
@ -2386,7 +2386,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
const isStarterProgressable = speciesEggMoves.hasOwnProperty(container.species.speciesId);
|
const isStarterProgressable = speciesEggMoves.hasOwnProperty(container.species.speciesId);
|
||||||
|
|
||||||
// Gen filter
|
// Gen filter
|
||||||
const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.generation);
|
const fitsGen = this.filterBar.getVals(DropDownColumn.GEN).includes(container.species.getGeneration());
|
||||||
|
|
||||||
// Type filter
|
// Type filter
|
||||||
const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => container.species.isOfType((type as number) - 1));
|
const fitsType = this.filterBar.getVals(DropDownColumn.TYPES).some(type => container.species.isOfType((type as number) - 1));
|
||||||
@ -3301,7 +3301,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tryUpdateValue(add?: integer, addingToParty?: boolean): boolean {
|
tryUpdateValue(add?: integer, addingToParty?: boolean): boolean {
|
||||||
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 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 newValue = value + (add || 0);
|
const newValue = value + (add || 0);
|
||||||
const valueLimit = this.getValueLimit();
|
const valueLimit = this.getValueLimit();
|
||||||
const overLimit = newValue > valueLimit;
|
const overLimit = newValue > valueLimit;
|
||||||
|
Loading…
Reference in New Issue
Block a user