From 8fabcba235fb4a64f8b2f65373579c2c73013abd Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:34:17 -0800 Subject: [PATCH] Pokemon movesets no longer allow `null` values --- src/field/pokemon.ts | 27 ++++++++++++++++++++++----- src/system/pokemon-data.ts | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 217d5fa699b..8b13b462469 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -96,7 +96,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public stats: integer[]; public ivs: integer[]; public nature: Nature; - public moveset: (PokemonMove | null)[]; + public moveset: (PokemonMove)[]; public status: Status | null; public friendship: integer; public metLevel: integer; @@ -138,7 +138,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { private shinySparkle: Phaser.GameObjects.Sprite; - constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData) { + constructor( + scene: BattleScene, + x: number, + y: number, + species: PokemonSpecies, + level: integer, + abilityIndex?: integer, + formIndex?: integer, + gender?: Gender, + shiny?: boolean, + variant?: Variant, + ivs?: integer[], + nature?: Nature, + dataSource?: Pokemon | PokemonData + ) { super(scene, x, y); if (!species.isObtainable() && this.isPlayer()) { @@ -1157,7 +1171,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { abstract isBoss(): boolean; - getMoveset(ignoreOverride?: boolean): (PokemonMove | null)[] { + getMoveset(ignoreOverride?: boolean): (PokemonMove)[] { const ret = !ignoreOverride && this.summonData?.moveset ? this.summonData.moveset : this.moveset; @@ -1914,7 +1928,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } setMove(moveIndex: integer, moveId: Moves): void { - const move = moveId ? new PokemonMove(moveId) : null; + if (moveId === Moves.NONE) { + return; + } + const move = new PokemonMove(moveId); this.moveset[moveIndex] = move; if (this.summonData?.moveset) { this.summonData.moveset[moveIndex] = move; @@ -5235,7 +5252,7 @@ export class PokemonSummonData { public gender: Gender; public fusionGender: Gender; public stats: number[] = [ 0, 0, 0, 0, 0, 0 ]; - public moveset: (PokemonMove | null)[]; + public moveset: (PokemonMove)[]; // If not initialized this value will not be populated from save data. public types: Type[] = []; public addedType: Type | null = null; diff --git a/src/system/pokemon-data.ts b/src/system/pokemon-data.ts index 443382186c7..1861099c44b 100644 --- a/src/system/pokemon-data.ts +++ b/src/system/pokemon-data.ts @@ -33,7 +33,7 @@ export default class PokemonData { public stats: integer[]; public ivs: integer[]; public nature: Nature; - public moveset: (PokemonMove | null)[]; + public moveset: (PokemonMove)[]; public status: Status | null; public friendship: integer; public metLevel: integer;