[Move] False Swipe/Hold Back don't fail if the target has 1 HP (#5577)

* Remove condition from `SurviveDamageAttr`

* Add test for False Swipe

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: EmberCM <kooly213@hotmail.com>
This commit is contained in:
damocleas 2025-03-29 13:10:07 -04:00 committed by GitHub
parent 25b9fa7933
commit 4f19e4a126
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 53 additions and 4 deletions

View File

@ -1580,10 +1580,6 @@ export class SurviveDamageAttr extends ModifiedDamageAttr {
return Math.min(damage, target.hp - 1);
}
getCondition(): MoveConditionFunc {
return (user, target, move) => target.hp > 1;
}
getUserBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
return target.hp > 1 ? 0 : -20;
}

View File

@ -0,0 +1,53 @@
import { MoveResult } from "#app/field/pokemon";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - False Swipe", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([Moves.FALSE_SWIPE])
.ability(Abilities.BALL_FETCH)
.startingLevel(1000)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH);
});
it("should reduce the target to 1 HP", async () => {
await game.classicMode.startBattle([Species.MILOTIC]);
const player = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!;
game.move.select(Moves.FALSE_SWIPE);
await game.toNextTurn();
game.move.select(Moves.FALSE_SWIPE);
await game.phaseInterceptor.to("BerryPhase");
expect(enemy.hp).toBe(1);
const falseSwipeHistory = player
.getMoveHistory()
.every(turnMove => turnMove.move === Moves.FALSE_SWIPE && turnMove.result === MoveResult.SUCCESS);
expect(falseSwipeHistory).toBe(true);
});
});