From aee3dd8b244028aaa54f8f6628f641d190eaf071 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Wed, 5 Feb 2025 23:49:07 +1100 Subject: [PATCH] Cleanup species inclusivity check --- src/data/move.ts | 27 +-------------------------- src/field/pokemon.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index e4320b3b6d8..efd1e3e67bd 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4644,30 +4644,6 @@ export class VariableMoveTypeAttr extends MoveAttr { } } -/** - * Attribute used for Tera Starstorm that changes the move type to Stellar - * @extends VariableMoveTypeAttr - */ -export class TeraStarstormTypeAttr extends VariableMoveTypeAttr { - /** - * - * @param user the {@linkcode Pokemon} using the move - * @param target n/a - * @param move n/a - * @param args[0] {@linkcode Utils.NumberHolder} the move type - * @returns `true` if the move type is changed to {@linkcode Type.STELLAR}, `false` otherwise - */ - override apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { - if (user.isTerastallized && (user.hasFusionSpecies(Species.TERAPAGOS) || user.species.speciesId === Species.TERAPAGOS)) { - const moveType = args[0] as Utils.NumberHolder; - - moveType.value = Type.STELLAR; - return true; - } - return false; - } -} - export class FormChangeItemTypeAttr extends VariableMoveTypeAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { const moveType = args[0]; @@ -11102,8 +11078,7 @@ export function initMoves() { .chargeAttr(WeatherInstantChargeAttr, [ WeatherType.RAIN, WeatherType.HEAVY_RAIN ]), new AttackMove(Moves.TERA_STARSTORM, Type.NORMAL, MoveCategory.SPECIAL, 120, 100, 5, -1, 0, 9) .attr(TeraMoveCategoryAttr) - .attr(TeraStarstormTypeAttr) - .attr(VariableTargetAttr, (user, target, move) => (user.hasFusionSpecies(Species.TERAPAGOS) || user.species.speciesId === Species.TERAPAGOS) && user.isTerastallized ? MoveTarget.ALL_NEAR_ENEMIES : MoveTarget.NEAR_OTHER) + .attr(VariableTargetAttr, (user, target, move) => user.hasSpecies(Species.TERAPAGOS) && user.isTerastallized ? MoveTarget.ALL_NEAR_ENEMIES : MoveTarget.NEAR_OTHER) .partial(), /** Does not ignore abilities that affect stats, relevant in determining the move's category {@see TeraMoveCategoryAttr} */ new AttackMove(Moves.FICKLE_BEAM, Type.DRAGON, MoveCategory.SPECIAL, 80, 100, 5, 30, 0, 9) .attr(PreMoveMessageAttr, doublePowerChanceMessageFunc) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index e34c09102cd..7cd4bdb96d2 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1182,6 +1182,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.fusionSpecies?.speciesId === species; } + /** + * Checks if the {@linkcode Pokemon} has is the specified {@linkcode Species} or is fused with it. + * @param species the pokemon {@linkcode Species} to check + * @returns `true` if the pokemon is the species or is fused with it, `false` otherwise + */ + hasSpecies(species: Species): boolean { + return this.species.speciesId === species || this.fusionSpecies?.speciesId === species; + } + abstract isBoss(): boolean; getMoveset(ignoreOverride?: boolean): (PokemonMove | null)[] { @@ -1553,9 +1562,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @returns the pokemon's current tera {@linkcode Type}, or `Type.UNKNOWN` if the pokemon is not terastallized */ getTeraType(): Type { - if (this.species.speciesId === Species.TERAPAGOS || this.fusionSpecies?.speciesId === Species.TERAPAGOS) { + if (this.hasSpecies(Species.TERAPAGOS)) { return Type.STELLAR; - } else if (this.species.speciesId === Species.OGERPON || this.fusionSpecies?.speciesId === Species.OGERPON) { + } else if (this.hasSpecies(Species.OGERPON)) { const ogerponForm = this.species.speciesId === Species.OGERPON ? this.formIndex : this.fusionFormIndex; switch (ogerponForm) { case 0: @@ -1571,7 +1580,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { case 7: return Type.ROCK; } - } else if (this.species.speciesId === Species.SHEDINJA || this.fusionSpecies?.speciesId === Species.SHEDINJA) { + } else if (this.hasSpecies(Species.SHEDINJA)) { return Type.BUG; } return this.teraType;