diff --git a/src/data/move.ts b/src/data/move.ts index e27fd9ac764..b78ad474729 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1881,8 +1881,14 @@ export class FlameBurstAttr extends MoveEffectAttr { } export class SacrificialFullRestoreAttr extends SacrificialAttr { - constructor() { + protected restorePP: boolean; + protected moveMessage: string; + + constructor(restorePP: boolean, moveMessage: string) { super(); + + this.restorePP = restorePP; + this.moveMessage = moveMessage; } apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { @@ -1893,36 +1899,19 @@ 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.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), 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(); - } -} - -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:lunarDanceRestore", { pokemonName: getPokemonNameWithAffix(user) }), false, false, false, true, false, true), true); + user.scene.pushPhase( + new PokemonHealPhase( + user.scene, + user.getBattlerIndex(), + maxPartyMemberHp, + i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }), + true, + false, + false, + true, + false, + this.restorePP), + true); return true; } @@ -9030,7 +9019,7 @@ export function initMoves() { .attr(GyroBallPowerAttr) .ballBombMove(), new SelfStatusMove(Moves.HEALING_WISH, Type.PSYCHIC, -1, 10, -1, 0, 4) - .attr(SacrificialFullRestoreAttr) + .attr(SacrificialFullRestoreAttr, false, "moveTriggers:sacrificialFullRestore") .triageMove(), new AttackMove(Moves.BRINE, Type.WATER, MoveCategory.SPECIAL, 65, 100, 10, -1, 0, 4) .attr(MovePowerMultiplierAttr, (user, target, move) => target.getHpRatio() < 0.5 ? 2 : 1), @@ -9307,7 +9296,7 @@ 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(SacrificialFullRestoreAndPPRestoreAttr) + .attr(SacrificialFullRestoreAttr, true, "moveTriggers:lunarDanceRestore") .danceMove() .triageMove(), new AttackMove(Moves.CRUSH_GRIP, Type.NORMAL, MoveCategory.PHYSICAL, -1, 100, 5, -1, 0, 4) diff --git a/src/test/moves/lunar_dance.test.ts b/src/test/moves/lunar_dance.test.ts index aa7bf9c0f89..603247298ac 100644 --- a/src/test/moves/lunar_dance.test.ts +++ b/src/test/moves/lunar_dance.test.ts @@ -24,16 +24,19 @@ describe("Moves - Lunar Dance", () => { beforeEach(() => { game = new GameManager(phaserGame); game.override - .moveset([ Moves.LUNAR_DANCE, Moves.SPLASH ]) .statusEffect(StatusEffect.BURN) .battleType("double") .enemyAbility(Abilities.BALL_FETCH) .enemyMoveset(Moves.SPLASH); }); - it("should full restore HP, PP and status of switched in pokemon, using lunar dance after should fail because no pokemon in party", async () => { + it("should full restore HP, PP and status of switched in pokemon, then fail second use because no remaining backup pokemon in party", async () => { await game.classicMode.startBattle([ Species.BULBASAUR, Species.ODDISH, Species.RATTATA ]); - let leftPlayer = game.scene.getPlayerParty()[0]; + + const [ bulbasaur, oddish, rattata ] = game.scene.getPlayerParty(); + game.move.changeMoveset(bulbasaur, [ Moves.LUNAR_DANCE, Moves.SPLASH ]); + game.move.changeMoveset(oddish, [ Moves.LUNAR_DANCE, Moves.SPLASH ]); + game.move.changeMoveset(rattata, [ Moves.LUNAR_DANCE, Moves.SPLASH ]); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.SPLASH, 1); @@ -41,9 +44,9 @@ describe("Moves - Lunar Dance", () => { await game.toNextTurn(); // Bulbasaur should still be burned and have used a PP for splash and not at max hp - expect(leftPlayer.status?.effect).toBe(StatusEffect.BURN); - expect(leftPlayer.moveset[1]?.ppUsed).toBe(1); - expect(leftPlayer.hp).toBeLessThan(leftPlayer.getMaxHp()); + expect(bulbasaur.status?.effect).toBe(StatusEffect.BURN); + expect(bulbasaur.moveset[1]?.ppUsed).toBe(1); + expect(bulbasaur.hp).toBeLessThan(bulbasaur.getMaxHp()); // Switch out Bulbasaur for Rattata so we can swtich bulbasaur back in with lunar dance game.doSwitchPokemon(2); @@ -58,19 +61,17 @@ describe("Moves - Lunar Dance", () => { await game.toNextTurn(); // Bulbasaur should NOT have any status and have full PP for splash and be at max hp - expect(leftPlayer.status?.effect).toBeUndefined(); - expect(leftPlayer.moveset[1]?.ppUsed).toBe(0); - expect(leftPlayer.hp).toBe(leftPlayer.getMaxHp()); + expect(bulbasaur.status?.effect).toBeUndefined(); + expect(bulbasaur.moveset[1]?.ppUsed).toBe(0); + expect(bulbasaur.isFullHp()).toBe(true); game.move.select(Moves.SPLASH, 0); game.move.select(Moves.LUNAR_DANCE); await game.phaseInterceptor.to(CommandPhase); await game.toNextTurn(); - leftPlayer = game.scene.getPlayerParty()[0]; - // Using Lunar dance again should fail because nothing in party and rattata should be alive - expect(leftPlayer.status?.effect).toBe(StatusEffect.BURN); - expect(leftPlayer.hp).toBeLessThan(leftPlayer.getMaxHp()); + expect(rattata.status?.effect).toBe(StatusEffect.BURN); + expect(rattata.hp).toBeLessThan(rattata.getMaxHp()); }); });