From 89356fbfda7b8988376a84837b0c75cb2c51144b Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 18 Apr 2023 22:23:06 -0400 Subject: [PATCH] Add full heal modifier --- src/modifier-type.ts | 16 ++++++++++++++++ src/modifier.ts | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/modifier-type.ts b/src/modifier-type.ts index 133fa8aa1..66aaa051b 100644 --- a/src/modifier-type.ts +++ b/src/modifier-type.ts @@ -99,6 +99,18 @@ export class PokemonReviveModifierType extends PokemonHpRestoreModifierType { } } +export class PokemonStatusHealModifierType extends PokemonModifierType { + constructor(name: string) { + super(name, `Heal any status ailment for one POKéMON`, + ((_type, args) => new Modifiers.PokemonStatusHealModifier(this, (args[0] as PlayerPokemon).id)), + ((pokemon: PlayerPokemon) => { + if (!pokemon.hp || !pokemon.status) + return PartyUiHandler.NoEffectMessage; + return null; + })); + } +} + export abstract class PokemonMoveModifierType extends PokemonModifierType { public moveSelectFilter: PokemonMoveSelectFilter; @@ -481,6 +493,10 @@ const modifierPool = { ].map(m => { m.setTier(ModifierTier.COMMON); return m; }), [ModifierTier.GREAT]: [ new WeightedModifierType(new AddPokeballModifierType(PokeballType.GREAT_BALL, 5, 'gb'), 12), + new WeightedModifierType(new PokemonStatusHealModifierType('FULL HEAL'), (party: PlayerPokemon[]) => { + const statusEffectPartyMemberCount = party.filter(p => p.hp && !!p.status).length; + return statusEffectPartyMemberCount * 8; + }), new WeightedModifierType(new PokemonReviveModifierType('REVIVE', 50), (party: PlayerPokemon[]) => { const faintedPartyMemberCount = party.filter(p => !p.hp).length; return faintedPartyMemberCount * 6; diff --git a/src/modifier.ts b/src/modifier.ts index 7a992e82c..15ee6387f 100644 --- a/src/modifier.ts +++ b/src/modifier.ts @@ -409,6 +409,20 @@ export class PokemonHpRestoreModifier extends ConsumablePokemonModifier { } } +export class PokemonStatusHealModifier extends ConsumablePokemonModifier { + + constructor(type: ModifierType, pokemonId: integer) { + super(type, pokemonId); + } + + apply(args: any[]): boolean { + const pokemon = args[0] as Pokemon; + pokemon.resetStatus(); + + return true; + } +} + export abstract class ConsumablePokemonMoveModifier extends ConsumablePokemonModifier { public moveIndex: integer;