mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-20 16:42:45 +02:00
Merge 1bb688f284
into 1ff2701964
This commit is contained in:
commit
08ed35e4a9
@ -1,3 +1,5 @@
|
|||||||
|
import type { IVTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
export interface DexData {
|
export interface DexData {
|
||||||
[key: number]: DexEntry;
|
[key: number]: DexEntry;
|
||||||
}
|
}
|
||||||
@ -9,5 +11,5 @@ export interface DexEntry {
|
|||||||
seenCount: number;
|
seenCount: number;
|
||||||
caughtCount: number;
|
caughtCount: number;
|
||||||
hatchedCount: number;
|
hatchedCount: number;
|
||||||
ivs: number[];
|
ivs: IVTuple;
|
||||||
}
|
}
|
||||||
|
60
src/@types/stat-types.ts
Normal file
60
src/@types/stat-types.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import type { Head, Tail } from "#app/@types/utility-types/tuple";
|
||||||
|
|
||||||
|
// biome-ignore lint/correctness/noUnusedImports: Type Imports
|
||||||
|
import type { PermanentStat, BattleStat } from "#enums/stat";
|
||||||
|
|
||||||
|
type StatTuple = [
|
||||||
|
hp: number,
|
||||||
|
atk: number,
|
||||||
|
def: number,
|
||||||
|
spAtk: number,
|
||||||
|
spDef: number,
|
||||||
|
spd: number,
|
||||||
|
acc: number,
|
||||||
|
eva: number,
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Tuple containing all {@linkcode PermanentStat}s of a Pokemon. */
|
||||||
|
export type PermanentStatTuple = Head<Head<StatTuple>>;
|
||||||
|
/** Tuple containing all {@linkcode BattleStat}s of a Pokemon. */
|
||||||
|
export type BattleStatTuple = Tail<PermanentStatTuple>;
|
||||||
|
|
||||||
|
/** Integer literal union containing all numbers from 0-31 inclusive; used to strongly type Pokemon IVs. */
|
||||||
|
export type IVType =
|
||||||
|
| 0
|
||||||
|
| 1
|
||||||
|
| 2
|
||||||
|
| 3
|
||||||
|
| 4
|
||||||
|
| 5
|
||||||
|
| 6
|
||||||
|
| 7
|
||||||
|
| 8
|
||||||
|
| 9
|
||||||
|
| 10
|
||||||
|
| 11
|
||||||
|
| 12
|
||||||
|
| 13
|
||||||
|
| 14
|
||||||
|
| 15
|
||||||
|
| 16
|
||||||
|
| 17
|
||||||
|
| 18
|
||||||
|
| 19
|
||||||
|
| 20
|
||||||
|
| 21
|
||||||
|
| 22
|
||||||
|
| 23
|
||||||
|
| 24
|
||||||
|
| 25
|
||||||
|
| 26
|
||||||
|
| 27
|
||||||
|
| 28
|
||||||
|
| 29
|
||||||
|
| 30
|
||||||
|
| 31;
|
||||||
|
|
||||||
|
type toIvTuple<T extends [...any]> = { [k in keyof T]: IVType };
|
||||||
|
|
||||||
|
/** A 6-length tuple of integers in the range [0-31]; used to strongly type Pokemon IVs. */
|
||||||
|
export type IVTuple = toIvTuple<PermanentStatTuple>;
|
9
src/@types/utility-types/global-augments.ts
Normal file
9
src/@types/utility-types/global-augments.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export {};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// Array global augments to allow semi-easy working with tuples...???
|
||||||
|
interface Array<T> {
|
||||||
|
map<U>(callbackfn: (value: T, index: number, array: this) => U, thisArg?: any): { [K in keyof this]: U };
|
||||||
|
slice(start: 0): { [K in keyof this]: T };
|
||||||
|
}
|
||||||
|
}
|
5
src/@types/utility-types/tuple.ts
Normal file
5
src/@types/utility-types/tuple.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/** Extract the elements of a tuple type, excluding the first element. */
|
||||||
|
export type Tail<T extends any[]> = Required<T> extends [any, ...infer Head] ? Head : never;
|
||||||
|
|
||||||
|
/** Extract the elements of a tuple type, excluding the last element. */
|
||||||
|
export type Head<T extends [...any]> = Required<T> extends [...infer Head, any] ? Head : never;
|
@ -161,12 +161,16 @@ import { timedEventManager } from "./global-event-manager";
|
|||||||
import { starterColors } from "./global-vars/starter-colors";
|
import { starterColors } from "./global-vars/starter-colors";
|
||||||
import { startingWave } from "./starting-wave";
|
import { startingWave } from "./starting-wave";
|
||||||
import { PhaseManager } from "./phase-manager";
|
import { PhaseManager } from "./phase-manager";
|
||||||
|
import type { IVTuple, IVType } from "#app/@types/stat-types";
|
||||||
|
|
||||||
const DEBUG_RNG = false;
|
const DEBUG_RNG = false;
|
||||||
|
|
||||||
const OPP_IVS_OVERRIDE_VALIDATED: number[] = (
|
const OPP_IVS_OVERRIDE_VALIDATED: IVTuple | null =
|
||||||
Array.isArray(Overrides.OPP_IVS_OVERRIDE) ? Overrides.OPP_IVS_OVERRIDE : new Array(6).fill(Overrides.OPP_IVS_OVERRIDE)
|
Overrides.OPP_IVS_OVERRIDE === null
|
||||||
).map(iv => (Number.isNaN(iv) || iv === null || iv > 31 ? -1 : iv));
|
? null
|
||||||
|
: Array.isArray(Overrides.OPP_IVS_OVERRIDE)
|
||||||
|
? Overrides.OPP_IVS_OVERRIDE
|
||||||
|
: (new Array(6).fill(Overrides.OPP_IVS_OVERRIDE) as IVTuple);
|
||||||
|
|
||||||
export interface PokeballCounts {
|
export interface PokeballCounts {
|
||||||
[pb: string]: number;
|
[pb: string]: number;
|
||||||
@ -907,7 +911,7 @@ export default class BattleScene extends SceneBase {
|
|||||||
gender?: Gender,
|
gender?: Gender,
|
||||||
shiny?: boolean,
|
shiny?: boolean,
|
||||||
variant?: Variant,
|
variant?: Variant,
|
||||||
ivs?: number[],
|
ivs?: IVTuple,
|
||||||
nature?: Nature,
|
nature?: Nature,
|
||||||
dataSource?: Pokemon | PokemonData,
|
dataSource?: Pokemon | PokemonData,
|
||||||
postProcess?: (playerPokemon: PlayerPokemon) => void,
|
postProcess?: (playerPokemon: PlayerPokemon) => void,
|
||||||
@ -955,28 +959,22 @@ export default class BattleScene extends SceneBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (boss && !dataSource) {
|
if (boss && !dataSource) {
|
||||||
|
// Generate a 2nd higher roll and linearly interpolate between the two.
|
||||||
const secondaryIvs = getIvsFromId(randSeedInt(4294967296));
|
const secondaryIvs = getIvsFromId(randSeedInt(4294967296));
|
||||||
|
|
||||||
for (let s = 0; s < pokemon.ivs.length; s++) {
|
pokemon.ivs = pokemon.ivs.map(
|
||||||
pokemon.ivs[s] = Math.round(
|
(iv, i) =>
|
||||||
Phaser.Math.Linear(
|
Math.round(Phaser.Math.Linear(Math.min(iv, secondaryIvs[i]), Math.max(iv, secondaryIvs[i]), 0.75)) as IVType, // ts doesn't know the number will be between 0-31
|
||||||
Math.min(pokemon.ivs[s], secondaryIvs[s]),
|
);
|
||||||
Math.max(pokemon.ivs[s], secondaryIvs[s]),
|
|
||||||
0.75,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postProcess) {
|
if (postProcess) {
|
||||||
postProcess(pokemon);
|
postProcess(pokemon);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < pokemon.ivs.length; i++) {
|
if (OPP_IVS_OVERRIDE_VALIDATED !== null) {
|
||||||
if (OPP_IVS_OVERRIDE_VALIDATED[i] > -1) {
|
pokemon.ivs = OPP_IVS_OVERRIDE_VALIDATED;
|
||||||
pokemon.ivs[i] = OPP_IVS_OVERRIDE_VALIDATED[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pokemon.init();
|
pokemon.init();
|
||||||
return pokemon;
|
return pokemon;
|
||||||
}
|
}
|
||||||
@ -2084,7 +2082,7 @@ export default class BattleScene extends SceneBase {
|
|||||||
let scoreIncrease =
|
let scoreIncrease =
|
||||||
enemy.getSpeciesForm().getBaseExp() *
|
enemy.getSpeciesForm().getBaseExp() *
|
||||||
(enemy.level / this.getMaxExpLevel()) *
|
(enemy.level / this.getMaxExpLevel()) *
|
||||||
((enemy.ivs.reduce((iv: number, total: number) => (total += iv), 0) / 93) * 0.2 + 0.8);
|
((enemy.ivs.reduce((total, iv) => total + iv, 0) / 93) * 0.2 + 0.8);
|
||||||
this.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemy.id, false).map(
|
this.findModifiers(m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemy.id, false).map(
|
||||||
m => (scoreIncrease *= (m as PokemonHeldItemModifier).getScoreMultiplier()),
|
m => (scoreIncrease *= (m as PokemonHeldItemModifier).getScoreMultiplier()),
|
||||||
);
|
);
|
||||||
|
@ -38,6 +38,7 @@ import {
|
|||||||
HATCH_WAVES_LEGENDARY_EGG,
|
HATCH_WAVES_LEGENDARY_EGG,
|
||||||
} from "#app/data/balance/rates";
|
} from "#app/data/balance/rates";
|
||||||
import { speciesEggTiers } from "#app/data/balance/species-egg-tiers";
|
import { speciesEggTiers } from "#app/data/balance/species-egg-tiers";
|
||||||
|
import type { IVType } from "#app/@types/stat-types";
|
||||||
|
|
||||||
export const EGG_SEED = 1073741824;
|
export const EGG_SEED = 1073741824;
|
||||||
|
|
||||||
@ -270,9 +271,9 @@ export class Egg {
|
|||||||
|
|
||||||
const secondaryIvs = getIvsFromId(randSeedInt(4294967295));
|
const secondaryIvs = getIvsFromId(randSeedInt(4294967295));
|
||||||
|
|
||||||
for (let s = 0; s < ret.ivs.length; s++) {
|
ret.ivs = ret.ivs.map(
|
||||||
ret.ivs[s] = Math.max(ret.ivs[s], secondaryIvs[s]);
|
(iv, i) => Math.max(iv, secondaryIvs[i]) as IVType, // ts doesn't know the number will be between 0-31
|
||||||
}
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = ret!; // Tell TS compiler it's defined now
|
ret = ret!; // Tell TS compiler it's defined now
|
||||||
|
@ -512,7 +512,7 @@ async function postProcessTransformedPokemon(
|
|||||||
const hiddenAbilityChance = new NumberHolder(256);
|
const hiddenAbilityChance = new NumberHolder(256);
|
||||||
globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
|
globalScene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
|
||||||
|
|
||||||
const hasHiddenAbility = !randSeedInt(hiddenAbilityChance.value);
|
const hasHiddenAbility = randSeedInt(hiddenAbilityChance.value) === 0;
|
||||||
|
|
||||||
if (hasHiddenAbility) {
|
if (hasHiddenAbility) {
|
||||||
newPokemon.abilityIndex = hiddenIndex;
|
newPokemon.abilityIndex = hiddenIndex;
|
||||||
|
@ -53,6 +53,7 @@ import { PokemonType } from "#enums/pokemon-type";
|
|||||||
import { getNatureName } from "#app/data/nature";
|
import { getNatureName } from "#app/data/nature";
|
||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { timedEventManager } from "#app/global-event-manager";
|
import { timedEventManager } from "#app/global-event-manager";
|
||||||
|
import type { IVTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates exclamation sprite over trainer's head at start of encounter
|
* Animates exclamation sprite over trainer's head at start of encounter
|
||||||
@ -95,7 +96,7 @@ export interface EnemyPokemonConfig {
|
|||||||
passive?: boolean;
|
passive?: boolean;
|
||||||
moveSet?: MoveId[];
|
moveSet?: MoveId[];
|
||||||
nature?: Nature;
|
nature?: Nature;
|
||||||
ivs?: [number, number, number, number, number, number];
|
ivs?: IVTuple;
|
||||||
shiny?: boolean;
|
shiny?: boolean;
|
||||||
/** Is only checked if Pokemon is shiny */
|
/** Is only checked if Pokemon is shiny */
|
||||||
variant?: Variant;
|
variant?: Variant;
|
||||||
|
@ -190,6 +190,7 @@ import { AiType } from "#enums/ai-type";
|
|||||||
import type { MoveResult } from "#enums/move-result";
|
import type { MoveResult } from "#enums/move-result";
|
||||||
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
import { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||||
import type { AbAttrMap, AbAttrString } from "#app/@types/ability-types";
|
import type { AbAttrMap, AbAttrString } from "#app/@types/ability-types";
|
||||||
|
import type { IVTuple, PermanentStatTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
/** Base typeclass for damage parameter methods, used for DRY */
|
/** Base typeclass for damage parameter methods, used for DRY */
|
||||||
type damageParams = {
|
type damageParams = {
|
||||||
@ -244,8 +245,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
public levelExp: number;
|
public levelExp: number;
|
||||||
public gender: Gender;
|
public gender: Gender;
|
||||||
public hp: number;
|
public hp: number;
|
||||||
public stats: number[];
|
public stats: PermanentStatTuple;
|
||||||
public ivs: number[];
|
public ivs: IVTuple;
|
||||||
public nature: Nature;
|
public nature: Nature;
|
||||||
public moveset: PokemonMove[];
|
public moveset: PokemonMove[];
|
||||||
public status: Status | null;
|
public status: Status | null;
|
||||||
@ -314,7 +315,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
gender?: Gender,
|
gender?: Gender,
|
||||||
shiny?: boolean,
|
shiny?: boolean,
|
||||||
variant?: Variant,
|
variant?: Variant,
|
||||||
ivs?: number[],
|
ivs?: IVTuple,
|
||||||
nature?: Nature,
|
nature?: Nature,
|
||||||
dataSource?: Pokemon | PokemonData,
|
dataSource?: Pokemon | PokemonData,
|
||||||
) {
|
) {
|
||||||
@ -5492,7 +5493,7 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
gender?: Gender,
|
gender?: Gender,
|
||||||
shiny?: boolean,
|
shiny?: boolean,
|
||||||
variant?: Variant,
|
variant?: Variant,
|
||||||
ivs?: number[],
|
ivs?: IVTuple,
|
||||||
nature?: Nature,
|
nature?: Nature,
|
||||||
dataSource?: Pokemon | PokemonData,
|
dataSource?: Pokemon | PokemonData,
|
||||||
) {
|
) {
|
||||||
@ -6091,10 +6092,12 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
|
|
||||||
if (this.hasTrainer() && globalScene.currentBattle) {
|
if (this.hasTrainer() && globalScene.currentBattle) {
|
||||||
const { waveIndex } = globalScene.currentBattle;
|
const { waveIndex } = globalScene.currentBattle;
|
||||||
const ivs: number[] = [];
|
const ivs = Array.from(
|
||||||
while (ivs.length < 6) {
|
{
|
||||||
ivs.push(randSeedIntRange(Math.floor(waveIndex / 10), 31));
|
length: 6,
|
||||||
}
|
},
|
||||||
|
() => randSeedIntRange(Math.floor(waveIndex / 10), 31),
|
||||||
|
) as IVTuple;
|
||||||
this.ivs = ivs;
|
this.ivs = ivs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import { TimeOfDay } from "#enums/time-of-day";
|
|||||||
import { TrainerType } from "#enums/trainer-type";
|
import { TrainerType } from "#enums/trainer-type";
|
||||||
import { VariantTier } from "#enums/variant-tier";
|
import { VariantTier } from "#enums/variant-tier";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
|
import type { IVTuple, IVType } from "#app/@types/stat-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This comment block exists to prevent IDEs from automatically removing unused imports
|
* This comment block exists to prevent IDEs from automatically removing unused imports
|
||||||
@ -181,7 +182,11 @@ class DefaultOverrides {
|
|||||||
readonly OPP_MOVESET_OVERRIDE: MoveId | Array<MoveId> = [];
|
readonly OPP_MOVESET_OVERRIDE: MoveId | Array<MoveId> = [];
|
||||||
readonly OPP_SHINY_OVERRIDE: boolean | null = null;
|
readonly OPP_SHINY_OVERRIDE: boolean | null = null;
|
||||||
readonly OPP_VARIANT_OVERRIDE: Variant | null = null;
|
readonly OPP_VARIANT_OVERRIDE: Variant | null = null;
|
||||||
readonly OPP_IVS_OVERRIDE: number | number[] = [];
|
/**
|
||||||
|
* An array of IVs to give the opposing pokemon.
|
||||||
|
* Specifying a single number will use it for all 6 IVs, while `null` will disable the override.
|
||||||
|
*/
|
||||||
|
readonly OPP_IVS_OVERRIDE: IVType | IVTuple | null = null;
|
||||||
readonly OPP_FORM_OVERRIDES: Partial<Record<SpeciesId, number>> = {};
|
readonly OPP_FORM_OVERRIDES: Partial<Record<SpeciesId, number>> = {};
|
||||||
/**
|
/**
|
||||||
* Override to give the enemy Pokemon a given amount of health segments
|
* Override to give the enemy Pokemon a given amount of health segments
|
||||||
|
@ -121,7 +121,8 @@ export class EncounterPhase extends BattlePhase {
|
|||||||
!!globalScene.getEncounterBossSegments(battle.waveIndex, level, enemySpecies),
|
!!globalScene.getEncounterBossSegments(battle.waveIndex, level, enemySpecies),
|
||||||
);
|
);
|
||||||
if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
if (globalScene.currentBattle.battleSpec === BattleSpec.FINAL_BOSS) {
|
||||||
battle.enemyParty[e].ivs = new Array(6).fill(31);
|
// max IVs for eternatus
|
||||||
|
battle.enemyParty[e].ivs = [31, 31, 31, 31, 31, 31];
|
||||||
}
|
}
|
||||||
globalScene
|
globalScene
|
||||||
.getPlayerParty()
|
.getPlayerParty()
|
||||||
|
@ -69,6 +69,7 @@ import { DexAttr } from "#enums/dex-attr";
|
|||||||
import { AbilityAttr } from "#enums/ability-attr";
|
import { AbilityAttr } from "#enums/ability-attr";
|
||||||
import { defaultStarterSpecies, saveKey } from "#app/constants";
|
import { defaultStarterSpecies, saveKey } from "#app/constants";
|
||||||
import { encrypt, decrypt } from "#app/utils/data";
|
import { encrypt, decrypt } from "#app/utils/data";
|
||||||
|
import type { IVTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
function getDataTypeKey(dataType: GameDataType, slotId = 0): string {
|
function getDataTypeKey(dataType: GameDataType, slotId = 0): string {
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
@ -1946,7 +1947,13 @@ export class GameData {
|
|||||||
_unlockSpeciesNature(species.speciesId);
|
_unlockSpeciesNature(species.speciesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSpeciesDexIvs(speciesId: SpeciesId, ivs: number[]): void {
|
/**
|
||||||
|
* When a pokemon is caught or added, maximize its lowest pre-evolution's {@linkcode DexData}
|
||||||
|
* with the IVs of the newly caught pokemon.
|
||||||
|
* @param speciesId - The {@linkcode SpeciesId} to update dex data for.
|
||||||
|
* @param ivs - The {@linkcode IVTuple | IVs} of the caught pokemon.
|
||||||
|
*/
|
||||||
|
updateSpeciesDexIvs(speciesId: SpeciesId, ivs: IVTuple): void {
|
||||||
let dexEntry: DexEntry;
|
let dexEntry: DexEntry;
|
||||||
do {
|
do {
|
||||||
dexEntry = globalScene.gameData.dexData[speciesId];
|
dexEntry = globalScene.gameData.dexData[speciesId];
|
||||||
@ -1956,7 +1963,7 @@ export class GameData {
|
|||||||
dexIvs[i] = ivs[i];
|
dexIvs[i] = ivs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dexIvs.filter(iv => iv === 31).length === 6) {
|
if (dexIvs.every(iv => iv === 31)) {
|
||||||
globalScene.validateAchv(achvs.PERFECT_IVS);
|
globalScene.validateAchv(achvs.PERFECT_IVS);
|
||||||
}
|
}
|
||||||
} while (pokemonPrevolutions.hasOwnProperty(speciesId) && (speciesId = pokemonPrevolutions[speciesId]));
|
} while (pokemonPrevolutions.hasOwnProperty(speciesId) && (speciesId = pokemonPrevolutions[speciesId]));
|
||||||
|
@ -15,6 +15,7 @@ import type { MoveId } from "#enums/move-id";
|
|||||||
import type { SpeciesId } from "#enums/species-id";
|
import type { SpeciesId } from "#enums/species-id";
|
||||||
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
||||||
import type { PokemonType } from "#enums/pokemon-type";
|
import type { PokemonType } from "#enums/pokemon-type";
|
||||||
|
import type { IVTuple, PermanentStatTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
export default class PokemonData {
|
export default class PokemonData {
|
||||||
public id: number;
|
public id: number;
|
||||||
@ -32,8 +33,8 @@ export default class PokemonData {
|
|||||||
public levelExp: number;
|
public levelExp: number;
|
||||||
public gender: Gender;
|
public gender: Gender;
|
||||||
public hp: number;
|
public hp: number;
|
||||||
public stats: number[];
|
public stats: PermanentStatTuple;
|
||||||
public ivs: number[];
|
public ivs: IVTuple;
|
||||||
public nature: Nature;
|
public nature: Nature;
|
||||||
public moveset: PokemonMove[];
|
public moveset: PokemonMove[];
|
||||||
public status: Status | null;
|
public status: Status | null;
|
||||||
|
@ -14,6 +14,7 @@ import ConfirmUiHandler from "./confirm-ui-handler";
|
|||||||
import { StatsContainer } from "./stats-container";
|
import { StatsContainer } from "./stats-container";
|
||||||
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
|
import { TextStyle, addBBCodeTextObject, addTextObject, getTextColor } from "./text";
|
||||||
import { addWindow } from "./ui-theme";
|
import { addWindow } from "./ui-theme";
|
||||||
|
import type { IVTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
interface LanguageSetting {
|
interface LanguageSetting {
|
||||||
infoContainerTextSize: string;
|
infoContainerTextSize: string;
|
||||||
@ -383,7 +384,7 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const starterSpeciesId = pokemon.species.getRootSpeciesId();
|
const starterSpeciesId = pokemon.species.getRootSpeciesId();
|
||||||
const originalIvs: number[] | null = eggInfo
|
const originalIvs: IVTuple | null = eggInfo
|
||||||
? dexEntry.caughtAttr
|
? dexEntry.caughtAttr
|
||||||
? dexEntry.ivs
|
? dexEntry.ivs
|
||||||
: null
|
: null
|
||||||
|
@ -3,6 +3,7 @@ import { MoveId } from "#enums/move-id";
|
|||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
|
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
|
||||||
import type { Variant } from "#app/sprites/variant";
|
import type { Variant } from "#app/sprites/variant";
|
||||||
|
import type { IVTuple, IVType } from "#app/@types/stat-types";
|
||||||
|
|
||||||
export type nil = null | undefined;
|
export type nil = null | undefined;
|
||||||
|
|
||||||
@ -87,6 +88,8 @@ export function randInt(range: number, min = 0): number {
|
|||||||
return Math.floor(Math.random() * range) + min;
|
return Math.floor(Math.random() * range) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function randSeedInt(range: 31, min?: IVType): IVType;
|
||||||
|
export function randSeedInt(range: number, min?: number): number;
|
||||||
/**
|
/**
|
||||||
* Generate a random integer using the global seed, or the current battle's seed if called via `Battle.randSeedInt`
|
* Generate a random integer using the global seed, or the current battle's seed if called via `Battle.randSeedInt`
|
||||||
* @param range - How large of a range of random numbers to choose from. If {@linkcode range} <= 1, returns {@linkcode min}
|
* @param range - How large of a range of random numbers to choose from. If {@linkcode range} <= 1, returns {@linkcode min}
|
||||||
@ -182,7 +185,7 @@ export function getPlayTimeString(totalSeconds: number): string {
|
|||||||
* @param id 32-bit number
|
* @param id 32-bit number
|
||||||
* @returns An array of six numbers corresponding to 5-bit chunks from {@linkcode id}
|
* @returns An array of six numbers corresponding to 5-bit chunks from {@linkcode id}
|
||||||
*/
|
*/
|
||||||
export function getIvsFromId(id: number): number[] {
|
export function getIvsFromId(id: number): IVTuple {
|
||||||
return [
|
return [
|
||||||
(id & 0x3e000000) >>> 25,
|
(id & 0x3e000000) >>> 25,
|
||||||
(id & 0x01f00000) >>> 20,
|
(id & 0x01f00000) >>> 20,
|
||||||
@ -190,7 +193,7 @@ export function getIvsFromId(id: number): number[] {
|
|||||||
(id & 0x00007c00) >>> 10,
|
(id & 0x00007c00) >>> 10,
|
||||||
(id & 0x000003e0) >>> 5,
|
(id & 0x000003e0) >>> 5,
|
||||||
id & 0x0000001f,
|
id & 0x0000001f,
|
||||||
];
|
] as IVTuple; // TS doesn't know the numbers are between 0-31
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatLargeNumber(count: number, threshold: number): string {
|
export function formatLargeNumber(count: number, threshold: number): string {
|
||||||
|
@ -11,6 +11,7 @@ import { SpeciesId } from "#enums/species-id";
|
|||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
import type { PermanentStatTuple } from "#app/@types/stat-types";
|
||||||
|
|
||||||
describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -156,6 +157,7 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||||||
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
|
expect(fusionFlare.calculateBattlePower).toHaveLastReturnedWith(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: Clean these tests up
|
||||||
it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves", async () => {
|
it("FUSION_FLARE and FUSION_BOLT alternating throughout turn should double power of subsequent moves", async () => {
|
||||||
game.override.enemyMoveset(fusionFlare.id);
|
game.override.enemyMoveset(fusionFlare.id);
|
||||||
await game.classicMode.startBattle([SpeciesId.ZEKROM, SpeciesId.ZEKROM]);
|
await game.classicMode.startBattle([SpeciesId.ZEKROM, SpeciesId.ZEKROM]);
|
||||||
@ -168,7 +170,10 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||||||
game.scene.clearEnemyModifiers();
|
game.scene.clearEnemyModifiers();
|
||||||
|
|
||||||
// Mock stats by replacing entries in copy with desired values for specific stats
|
// Mock stats by replacing entries in copy with desired values for specific stats
|
||||||
const stats = {
|
const stats: {
|
||||||
|
enemy: [PermanentStatTuple, PermanentStatTuple];
|
||||||
|
player: [PermanentStatTuple, PermanentStatTuple];
|
||||||
|
} = {
|
||||||
enemy: [[...enemyParty[0].stats], [...enemyParty[1].stats]],
|
enemy: [[...enemyParty[0].stats], [...enemyParty[1].stats]],
|
||||||
player: [[...party[0].stats], [...party[1].stats]],
|
player: [[...party[0].stats], [...party[1].stats]],
|
||||||
};
|
};
|
||||||
@ -222,7 +227,10 @@ describe("Moves - Fusion Flare and Fusion Bolt", () => {
|
|||||||
game.scene.clearEnemyModifiers();
|
game.scene.clearEnemyModifiers();
|
||||||
|
|
||||||
// Mock stats by replacing entries in copy with desired values for specific stats
|
// Mock stats by replacing entries in copy with desired values for specific stats
|
||||||
const stats = {
|
const stats: {
|
||||||
|
enemy: [PermanentStatTuple, PermanentStatTuple];
|
||||||
|
player: [PermanentStatTuple, PermanentStatTuple];
|
||||||
|
} = {
|
||||||
enemy: [[...enemyParty[0].stats], [...enemyParty[1].stats]],
|
enemy: [[...enemyParty[0].stats], [...enemyParty[1].stats]],
|
||||||
player: [[...party[0].stats], [...party[1].stats]],
|
player: [[...party[0].stats], [...party[1].stats]],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user