From 0d71b7008a5631e0e395cfa29dd7cb35ac6762a6 Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 5 Sep 2024 18:41:41 -0700 Subject: [PATCH] Fix merge issues --- src/data/ability.ts | 12 ++++++++---- src/phases/move-effect-phase.ts | 4 ++-- src/test/abilities/aftermath.test.ts | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index b8dc422eaac..cec9970f999 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -4053,8 +4053,10 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr { export class PreventPostFaintContactDamageAbAttr extends AbAttr { showAbility: boolean = false; - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { - cancelled.value = true; + override apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise { + if (cancelled) { + cancelled.value = true; + } return true; } } @@ -4131,9 +4133,11 @@ export class FieldPreventMovesAbAttr extends AbAttr { } /** @param args See {@linkcode FieldPreventMovesAbAttr}. */ - apply(pokemon: Pokemon, passive: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean { + override apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder | null, args: any[]): boolean | Promise { if (this.preventedMoves.includes((args[0] as Move).id)) { - cancelled.value = true; + if (cancelled) { + cancelled.value = true; + } return true; } diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 697c54f3644..aba5d5b46e0 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -1,6 +1,6 @@ import BattleScene from "#app/battle-scene.js"; import { BattlerIndex } from "#app/battle.js"; -import { applyPreAttackAbAttrs, AddSecondStrikeAbAttr, IgnoreMoveEffectsAbAttr, applyPostDefendAbAttrs, PostDefendAbAttr, applyPostAttackAbAttrs, PostAttackAbAttr, MaxMultiHitAbAttr, AlwaysHitAbAttr } from "#app/data/ability.js"; +import { applyPreAttackAbAttrs, AddSecondStrikeAbAttr, IgnoreMoveEffectsAbAttr, applyPostDefendAbAttrs, PostDefendAbAttr, applyPostAttackAbAttrs, PostAttackAbAttr, MaxMultiHitAbAttr, AlwaysHitAbAttr, applyAbAttrs, FieldPreventMovesAbAttr } from "#app/data/ability.js"; import { ArenaTagSide, ConditionalProtectTag } from "#app/data/arena-tag.js"; import { MoveAnim } from "#app/data/battle-anims.js"; import { BattlerTagLapseType, ProtectedTag, SemiInvulnerableTag } from "#app/data/battler-tags.js"; @@ -117,7 +117,7 @@ export class MoveEffectPhase extends PokemonPhase { } const prevented = new Utils.BooleanHolder(false); - this.scene.getField(true).forEach(p => applyAbAttrs(FieldPreventMovesAbAttr, p, prevented, move, user)); + this.scene.getField(true).forEach(p => applyAbAttrs(FieldPreventMovesAbAttr, p, prevented, false, move, user)); if (prevented.value) { moveHistoryEntry.result = MoveResult.FAIL; return this.end(); diff --git a/src/test/abilities/aftermath.test.ts b/src/test/abilities/aftermath.test.ts index 6385cab958b..d70e441c258 100644 --- a/src/test/abilities/aftermath.test.ts +++ b/src/test/abilities/aftermath.test.ts @@ -42,11 +42,11 @@ describe("Abilities - Aftermath", () => { game.move.select(Moves.TACKLE); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("VictoryPhase"); expect(game.phaseInterceptor.log).toContain("FaintPhase"); expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase"); - expect(player.hp).toBeCloseTo(Math.floor(player.getMaxHp() * 0.75)); + expect(player.hp).toBe(Math.ceil(player.getMaxHp() * 0.75)); }, TIMEOUT); it("does not activate on non-contact moves", async () => { @@ -59,7 +59,7 @@ describe("Abilities - Aftermath", () => { game.move.select(Moves.WATER_GUN); - await game.phaseInterceptor.to("TurnEndPhase"); + await game.phaseInterceptor.to("VictoryPhase"); expect(game.phaseInterceptor.log).toContain("FaintPhase"); expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");