Created new Modifier class MoveEffectModifier

This commit is contained in:
frutescens 2024-11-17 11:01:04 -08:00
parent e381162096
commit 0e57ed03ff
1 changed files with 28 additions and 2 deletions

View File

@ -756,6 +756,32 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
abstract getMaxHeldItemCount(pokemon?: Pokemon): number; abstract getMaxHeldItemCount(pokemon?: Pokemon): number;
} }
export class MoveEffectModifier extends PokemonHeldItemModifier {
constructor(type: ModifierType, pokemonId: number, stackCount?: number) {
super(type, pokemonId, stackCount);
}
matchType(modifier: Modifier): boolean {
return this.matchType(modifier);
}
shouldApply(pokemon?: Pokemon, ..._args: unknown[]): boolean {
return pokemon?.hasAbility(Abilities.SHEER_FORCE, true) ?? false;
}
apply(pokemon: Pokemon): boolean {
return this.apply(pokemon);
}
getMaxHeldItemCount(pokemon?: Pokemon): number {
return this.getMaxHeldItemCount(pokemon);
}
clone() {
return this.clone();
}
}
export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModifier { export abstract class LapsingPokemonHeldItemModifier extends PokemonHeldItemModifier {
protected battlesLeft: number; protected battlesLeft: number;
public isTransferable: boolean = false; public isTransferable: boolean = false;
@ -1750,7 +1776,7 @@ export class TurnStatusEffectModifier extends PokemonHeldItemModifier {
} }
} }
export class HitHealModifier extends PokemonHeldItemModifier { export class HitHealModifier extends MoveEffectModifier {
constructor(type: ModifierType, pokemonId: number, stackCount?: number) { constructor(type: ModifierType, pokemonId: number, stackCount?: number) {
super(type, pokemonId, stackCount); super(type, pokemonId, stackCount);
} }
@ -1769,7 +1795,7 @@ export class HitHealModifier extends PokemonHeldItemModifier {
* @returns `true` if the {@linkcode Pokemon} was healed * @returns `true` if the {@linkcode Pokemon} was healed
*/ */
override apply(pokemon: Pokemon): boolean { override apply(pokemon: Pokemon): boolean {
if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp() && !pokemon.hasAbility(Abilities.SHEER_FORCE, true)) { if (pokemon.turnData.totalDamageDealt && !pokemon.isFullHp()) {
const scene = pokemon.scene; const scene = pokemon.scene;
scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(), scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.getBattlerIndex(),
toDmgValue(pokemon.turnData.totalDamageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true)); toDmgValue(pokemon.turnData.totalDamageDealt / 8) * this.stackCount, i18next.t("modifier:hitHealApply", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), typeName: this.type.name }), true));