From 97e19f04070f514dc531f6102ea524f2de74bbb5 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 24 Feb 2025 17:58:50 -0800 Subject: [PATCH] Add ResetStatusPhase --- src/phases/reset-status-phase.ts | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/phases/reset-status-phase.ts diff --git a/src/phases/reset-status-phase.ts b/src/phases/reset-status-phase.ts new file mode 100644 index 00000000000..733f8021125 --- /dev/null +++ b/src/phases/reset-status-phase.ts @@ -0,0 +1,39 @@ +import type Pokemon from "#app/field/pokemon"; +import { BattlePhase } from "#app/phases/battle-phase"; +import { BattlerTagType } from "#enums/battler-tag-type"; +import { StatusEffect } from "#enums/status-effect"; + +export class ResetStatusPhase extends BattlePhase { + private pokemon: Pokemon; + private affectConfusion: boolean; + private reloadAssets: boolean; + + constructor(pokemon: Pokemon, affectConfusion: boolean, reloadAssets: boolean) { + super(); + + this.pokemon = pokemon; + this.affectConfusion = affectConfusion; + this.reloadAssets = reloadAssets; + } + + public override start() { + const lastStatus = this.pokemon.status?.effect; + this.pokemon.status = null; + if (lastStatus === StatusEffect.SLEEP) { + this.pokemon.setFrameRate(10); + if (this.pokemon.getTag(BattlerTagType.NIGHTMARE)) { + this.pokemon.lapseTag(BattlerTagType.NIGHTMARE); + } + } + if (this.affectConfusion) { + if (this.pokemon.getTag(BattlerTagType.CONFUSED)) { + this.pokemon.lapseTag(BattlerTagType.CONFUSED); + } + } + if (this.reloadAssets) { + this.pokemon.loadAssets(false).then(() => this.pokemon.playAnim()); + } + this.pokemon.updateInfo(true); + this.end(); + } +}