From f9bae3aa4b9a9d7ca08f328aa1922b4c26e89003 Mon Sep 17 00:00:00 2001 From: PrabbyDD Date: Wed, 20 Nov 2024 14:37:12 -0800 Subject: [PATCH] beginning immplementation of lunar dance --- src/data/move.ts | 33 +++++++++++++++++++++++++++++--- src/phases/pokemon-heal-phase.ts | 11 ++++++++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 2ac4d74b712..d93d17f114f 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1884,6 +1884,34 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr { } } +export class SacrificialFullRestoreAndPPRestoreAttr extends SacrificialAttr { + constructor() { + super(); + } + + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + if (!super.apply(user, target, move, args)) { + return false; + } + + // We don't know which party member will be chosen, so pick the highest max HP in the party + const maxPartyMemberHp = user.scene.getPlayerParty().map(p => p.getMaxHp()).reduce((maxHp: integer, hp: integer) => Math.max(hp, maxHp), 0); + + user.scene.pushPhase(new PokemonHealPhase(user.scene, user.getBattlerIndex(), + maxPartyMemberHp, i18next.t("moveTriggers:sacrificialFullRestore", { pokemonName: getPokemonNameWithAffix(user) }), true, false, false, true, false, true), true); + + return true; + } + + getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { + return -20; + } + + getCondition(): MoveConditionFunc { + return (user, _target, _move) => user.scene.getPlayerParty().filter(p => p.isActive()).length > user.scene.currentBattle.getBattlerCount(); + } +} + /** * Attribute used for moves which ignore type-based debuffs from weather, namely Hydro Steam. * Called during damage calculation after getting said debuff from getAttackTypeMultiplier in the Pokemon class. @@ -9069,10 +9097,9 @@ export function initMoves() { new AttackMove(Moves.SPACIAL_REND, Type.DRAGON, MoveCategory.SPECIAL, 100, 95, 5, -1, 0, 4) .attr(HighCritAttr), new SelfStatusMove(Moves.LUNAR_DANCE, Type.PSYCHIC, -1, 10, -1, 0, 4) - .attr(SacrificialAttrOnHit) + .attr(SacrificialFullRestoreAndPPRestoreAttr) .danceMove() - .triageMove() - .unimplemented(), + .triageMove(), new AttackMove(Moves.CRUSH_GRIP, Type.NORMAL, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 4) .attr(OpponentHighHpPowerAttr, 120), new AttackMove(Moves.MAGMA_STORM, Type.FIRE, MoveCategory.SPECIAL, 100, 75, 5, -1, 0, 4) diff --git a/src/phases/pokemon-heal-phase.ts b/src/phases/pokemon-heal-phase.ts index dc0bd235bb5..c95b92e3b64 100644 --- a/src/phases/pokemon-heal-phase.ts +++ b/src/phases/pokemon-heal-phase.ts @@ -21,8 +21,9 @@ export class PokemonHealPhase extends CommonAnimPhase { private revive: boolean; private healStatus: boolean; private preventFullHeal: boolean; + private fullRestorePP: boolean; - constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: integer, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: integer, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false, fullRestorePP: boolean = false) { super(scene, battlerIndex, undefined, CommonAnim.HEALTH_UP); this.hpHealed = hpHealed; @@ -32,6 +33,7 @@ export class PokemonHealPhase extends CommonAnimPhase { this.revive = revive; this.healStatus = healStatus; this.preventFullHeal = preventFullHeal; + this.fullRestorePP = fullRestorePP; } start() { @@ -86,6 +88,13 @@ export class PokemonHealPhase extends CommonAnimPhase { lastStatusEffect = pokemon.status.effect; pokemon.resetStatus(); } + if (this.fullRestorePP) { + for (const move of this.getPokemon().getMoveset()) { + if (move) { + move.ppUsed = 0; + } + } + } pokemon.updateInfo().then(() => super.end()); } else if (this.healStatus && !this.revive && pokemon.status) { lastStatusEffect = pokemon.status.effect;