mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23:24 +02:00
make IVs use Uint8Array
This commit is contained in:
parent
cffbafe4bd
commit
0ebdc1b0ef
@ -866,7 +866,7 @@ export class BattleScene extends SceneBase {
|
|||||||
gender?: Gender,
|
gender?: Gender,
|
||||||
shiny?: boolean,
|
shiny?: boolean,
|
||||||
variant?: Variant,
|
variant?: Variant,
|
||||||
ivs?: number[],
|
ivs?: Uint8Array,
|
||||||
nature?: Nature,
|
nature?: Nature,
|
||||||
dataSource?: Pokemon | PokemonData,
|
dataSource?: Pokemon | PokemonData,
|
||||||
postProcess?: (playerPokemon: PlayerPokemon) => void,
|
postProcess?: (playerPokemon: PlayerPokemon) => void,
|
||||||
@ -897,12 +897,12 @@ export class BattleScene extends SceneBase {
|
|||||||
if (Overrides.IVS_OVERRIDE.some(value => !isBetween(value, 0, 31))) {
|
if (Overrides.IVS_OVERRIDE.some(value => !isBetween(value, 0, 31))) {
|
||||||
throw new Error("All IVs in the player IV override must be between 0 and 31!");
|
throw new Error("All IVs in the player IV override must be between 0 and 31!");
|
||||||
}
|
}
|
||||||
pokemon.ivs = Overrides.IVS_OVERRIDE;
|
pokemon.ivs = new Uint8Array(Overrides.IVS_OVERRIDE);
|
||||||
} else {
|
} else {
|
||||||
if (!isBetween(Overrides.IVS_OVERRIDE, 0, 31)) {
|
if (!isBetween(Overrides.IVS_OVERRIDE, 0, 31)) {
|
||||||
throw new Error("The Player IV override must be a value between 0 and 31!");
|
throw new Error("The Player IV override must be a value between 0 and 31!");
|
||||||
}
|
}
|
||||||
pokemon.ivs = new Array(6).fill(Overrides.IVS_OVERRIDE);
|
pokemon.ivs = new Uint8Array(6).fill(Overrides.IVS_OVERRIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Overrides.NATURE_OVERRIDE !== null) {
|
if (Overrides.NATURE_OVERRIDE !== null) {
|
||||||
@ -962,12 +962,12 @@ export class BattleScene extends SceneBase {
|
|||||||
if (Overrides.ENEMY_IVS_OVERRIDE.some(value => !isBetween(value, 0, 31))) {
|
if (Overrides.ENEMY_IVS_OVERRIDE.some(value => !isBetween(value, 0, 31))) {
|
||||||
throw new Error("All IVs in the enemy IV override must be between 0 and 31!");
|
throw new Error("All IVs in the enemy IV override must be between 0 and 31!");
|
||||||
}
|
}
|
||||||
pokemon.ivs = Overrides.ENEMY_IVS_OVERRIDE;
|
pokemon.ivs = new Uint8Array(Overrides.ENEMY_IVS_OVERRIDE);
|
||||||
} else {
|
} else {
|
||||||
if (!isBetween(Overrides.ENEMY_IVS_OVERRIDE, 0, 31)) {
|
if (!isBetween(Overrides.ENEMY_IVS_OVERRIDE, 0, 31)) {
|
||||||
throw new Error("The Enemy IV override must be a value between 0 and 31!");
|
throw new Error("The Enemy IV override must be a value between 0 and 31!");
|
||||||
}
|
}
|
||||||
pokemon.ivs = new Array(6).fill(Overrides.ENEMY_IVS_OVERRIDE);
|
pokemon.ivs = new Uint8Array(6).fill(Overrides.ENEMY_IVS_OVERRIDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Overrides.ENEMY_NATURE_OVERRIDE !== null) {
|
if (Overrides.ENEMY_NATURE_OVERRIDE !== null) {
|
||||||
|
@ -318,7 +318,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig):
|
|||||||
|
|
||||||
// Set IVs
|
// Set IVs
|
||||||
if (config.ivs) {
|
if (config.ivs) {
|
||||||
enemyPokemon.ivs = config.ivs;
|
enemyPokemon.ivs = new Uint8Array(config.ivs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Status
|
// Set Status
|
||||||
|
@ -204,7 +204,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
public gender: Gender;
|
public gender: Gender;
|
||||||
public hp: number;
|
public hp: number;
|
||||||
public stats: number[];
|
public stats: number[];
|
||||||
public ivs: number[];
|
public ivs: Uint8Array;
|
||||||
public nature: Nature;
|
public nature: Nature;
|
||||||
public moveset: PokemonMove[];
|
public moveset: PokemonMove[];
|
||||||
/**
|
/**
|
||||||
@ -311,7 +311,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
gender?: Gender,
|
gender?: Gender,
|
||||||
shiny?: boolean,
|
shiny?: boolean,
|
||||||
variant?: Variant,
|
variant?: Variant,
|
||||||
ivs?: number[],
|
ivs?: Uint8Array,
|
||||||
nature?: Nature,
|
nature?: Nature,
|
||||||
dataSource?: Pokemon | PokemonData,
|
dataSource?: Pokemon | PokemonData,
|
||||||
) {
|
) {
|
||||||
@ -346,7 +346,8 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
this.id = dataSource.id;
|
this.id = dataSource.id;
|
||||||
this.hp = dataSource.hp;
|
this.hp = dataSource.hp;
|
||||||
this.stats = dataSource.stats;
|
this.stats = dataSource.stats;
|
||||||
this.ivs = dataSource.ivs;
|
|
||||||
|
this.ivs = new Uint8Array(dataSource.ivs);
|
||||||
this.passive = !!dataSource.passive;
|
this.passive = !!dataSource.passive;
|
||||||
if (this.variant === undefined) {
|
if (this.variant === undefined) {
|
||||||
this.variant = 0;
|
this.variant = 0;
|
||||||
@ -385,7 +386,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
this.stellarTypesBoosted = dataSource.stellarTypesBoosted ?? [];
|
this.stellarTypesBoosted = dataSource.stellarTypesBoosted ?? [];
|
||||||
} else {
|
} else {
|
||||||
this.id = randSeedInt(4294967296);
|
this.id = randSeedInt(4294967296);
|
||||||
this.ivs = ivs || getIvsFromId(this.id);
|
this.ivs = new Uint8Array(ivs || getIvsFromId(this.id));
|
||||||
|
|
||||||
if (this.gender === undefined) {
|
if (this.gender === undefined) {
|
||||||
this.gender = this.species.generateGender();
|
this.gender = this.species.generateGender();
|
||||||
@ -5704,7 +5705,7 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
gender?: Gender,
|
gender?: Gender,
|
||||||
shiny?: boolean,
|
shiny?: boolean,
|
||||||
variant?: Variant,
|
variant?: Variant,
|
||||||
ivs?: number[],
|
ivs?: Uint8Array,
|
||||||
nature?: Nature,
|
nature?: Nature,
|
||||||
dataSource?: Pokemon | PokemonData,
|
dataSource?: Pokemon | PokemonData,
|
||||||
) {
|
) {
|
||||||
@ -6324,9 +6325,9 @@ 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 = new Uint8Array(6);
|
||||||
while (ivs.length < 6) {
|
for (let i = 0; i < 6; i++) {
|
||||||
ivs.push(randSeedIntRange(Math.floor(waveIndex / 10), 31));
|
ivs[i] = this.randBattleSeedIntRange(Math.floor(waveIndex / 10), 31);
|
||||||
}
|
}
|
||||||
this.ivs = ivs;
|
this.ivs = ivs;
|
||||||
}
|
}
|
||||||
|
@ -1914,7 +1914,7 @@ export class GameData {
|
|||||||
_unlockSpeciesNature(species.speciesId);
|
_unlockSpeciesNature(species.speciesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSpeciesDexIvs(speciesId: SpeciesId, ivs: number[]): void {
|
updateSpeciesDexIvs(speciesId: SpeciesId, ivs: Uint8Array): void {
|
||||||
let dexEntry: DexEntry;
|
let dexEntry: DexEntry;
|
||||||
do {
|
do {
|
||||||
dexEntry = globalScene.gameData.dexData[speciesId];
|
dexEntry = globalScene.gameData.dexData[speciesId];
|
||||||
|
Loading…
Reference in New Issue
Block a user