From e99af6f148d787d015a759b16cb79b6974dc3d7a Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Mon, 11 Mar 2024 18:13:07 -0400 Subject: [PATCH] Implement Healing Wish --- src/battle-scene.ts | 10 ++++++++-- src/data/move.ts | 10 ++++------ src/phases.ts | 6 +++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index b21ae7b29..a4c5bb7ef 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -109,6 +109,7 @@ export default class BattleScene extends Phaser.Scene { private phaseQueue: Phase[]; private phaseQueuePrepend: Phase[]; private phaseQueuePrependSpliceIndex: integer; + private nextCommandPhaseQueue: Phase[]; private currentPhase: Phase; private standbyPhase: Phase; public field: Phaser.GameObjects.Container; @@ -171,6 +172,7 @@ export default class BattleScene extends Phaser.Scene { this.phaseQueue = []; this.phaseQueuePrepend = []; this.phaseQueuePrependSpliceIndex = -1; + this.nextCommandPhaseQueue = []; } loadImage(key: string, folder: string, filename?: string) { @@ -1450,8 +1452,8 @@ export default class BattleScene extends Phaser.Scene { return this.standbyPhase; } - pushPhase(phase: Phase): void { - this.phaseQueue.push(phase); + pushPhase(phase: Phase, defer: boolean = false): void { + (!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase); } unshiftPhase(phase: Phase): void { @@ -1525,6 +1527,10 @@ export default class BattleScene extends Phaser.Scene { } populatePhaseQueue(): void { + if (this.nextCommandPhaseQueue.length) { + this.phaseQueue.push(...this.nextCommandPhaseQueue); + this.nextCommandPhaseQueue.splice(0, this.nextCommandPhaseQueue.length); + } this.phaseQueue.push(new TurnInitPhase(this)); } diff --git a/src/data/move.ts b/src/data/move.ts index 650e61e85..3654ab8a8 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -624,10 +624,8 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr { // We don't know which party member will be chosen, so pick the highest max HP in the party const maxPartyMemberHp = user.scene.getParty().map(p => p.getMaxHp()).reduce((maxHp: integer, hp: integer) => Math.max(hp, maxHp), 0); - console.log(maxPartyMemberHp); - user.scene.pushPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(), - maxPartyMemberHp, getPokemonMessage(user, '\'s Healing Wish\nwas granted!'), true, false, false, true)); + maxPartyMemberHp, getPokemonMessage(user, '\'s Healing Wish\nwas granted!'), true, false, false, true), true); return true; } @@ -2098,11 +2096,11 @@ export class FirstMoveTypeAttr extends MoveEffectAttr { if (!super.apply(user, target, move, args)) return false; - const firstMoveType = target.moveset[0].getMove().type + const firstMoveType = target.getMoveset()[0].getMove().type user.summonData.types = [ firstMoveType ]; - user.scene.queueMessage(getPokemonMessage(user, ` converted\ninto the ${Utils.toReadableString(Type[firstMoveType])} type!`)); + user.scene.queueMessage(getPokemonMessage(user, ` transformed\ninto to the ${Utils.toReadableString(Type[firstMoveType])} type!`)); return true; } @@ -3394,7 +3392,7 @@ export function initMoves() { new AttackMove(Moves.GYRO_BALL, "Gyro Ball", Type.STEEL, MoveCategory.PHYSICAL, -1, 100, 5, -1, "The user tackles the target with a high-speed spin. The slower the user compared to the target, the greater the move's power.", -1, 0, 4) .attr(BattleStatRatioPowerAttr, Stat.SPD, true) .ballBombMove(), - new SelfStatusMove(Moves.HEALING_WISH, "Healing Wish (N)", Type.PSYCHIC, -1, 10, -1, "The user faints. In return, the Pokémon taking its place will have its HP restored and status conditions cured.", -1, 0, 4) + new SelfStatusMove(Moves.HEALING_WISH, "Healing Wish", Type.PSYCHIC, -1, 10, -1, "The user faints. In return, the Pokémon taking its place will have its HP restored and status conditions cured.", -1, 0, 4) .attr(SacrificialFullRestoreAttr), new AttackMove(Moves.BRINE, "Brine", Type.WATER, MoveCategory.SPECIAL, 65, 100, 10, -1, "If the target's HP is half or less, this attack will hit with double the power.", -1, 0, 4) .attr(MovePowerMultiplierAttr, (user, target, move) => target.getHpRatio() < 0.5 ? 2 : 1), diff --git a/src/phases.ts b/src/phases.ts index 5fb87a91c..064e866e3 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3369,6 +3369,10 @@ export class PokemonHealPhase extends CommonAnimPhase { pokemon.resetStatus(); } pokemon.updateInfo().then(() => super.end()); + } else if (this.healStatus && !this.revive && pokemon.status) { + lastStatusEffect = pokemon.status.effect; + pokemon.resetStatus(); + pokemon.updateInfo().then(() => super.end()); } else if (this.showFullHpMessage) this.message = getPokemonMessage(pokemon, `'s\nHP is full!`); @@ -3378,7 +3382,7 @@ export class PokemonHealPhase extends CommonAnimPhase { if (this.healStatus && lastStatusEffect && !hasMessage) this.scene.queueMessage(getPokemonMessage(pokemon, getStatusEffectHealText(lastStatusEffect))); - if (fullHp) + if (fullHp && !lastStatusEffect) super.end(); } }