diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index 76449cb1467..b48b018a046 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -113,7 +113,7 @@ export class TurnStartPhase extends FieldPhase { if (isSameBracket && battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) { return battlerBypassSpeed[a].value ? -1 : 1; } - return aPriority < bPriority ? 1 : -1; + return (aPriority < bPriority) ? 1 : -1; } } diff --git a/src/test/moves/upper_hand.test.ts b/src/test/moves/upper_hand.test.ts index 5fb7418a929..d2fa365d3fc 100644 --- a/src/test/moves/upper_hand.test.ts +++ b/src/test/moves/upper_hand.test.ts @@ -1,10 +1,11 @@ +import { allMoves } from "#app/data/move"; 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/utils/gameManager"; import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; describe("Moves - Upper Hand", () => { let phaserGame: Phaser.Game; @@ -50,7 +51,7 @@ describe("Moves - Upper Hand", () => { it.each([ { descriptor: "non-priority attack", move: Moves.TACKLE }, - { descriptor: "status move", move: Moves.SPLASH } + { descriptor: "status move", move: Moves.BABY_DOLL_EYES } ])("should fail when the opponent selects a $descriptor", async ({ move }) => { game.override.enemyMoveset(move); @@ -81,4 +82,19 @@ describe("Moves - Upper Hand", () => { expect(magikarp.isFullHp()).toBeFalsy(); expect(feebas.isFullHp()).toBeTruthy(); }); + + it("should fail if the target has already moved", async () => { + game.override.enemyMoveset(Moves.TACKLE); + vi.spyOn(allMoves[Moves.TACKLE], "priority", "get").mockReturnValue(4); + + await game.classicMode.startBattle([ Species.FEEBAS ]); + + const feebas = game.scene.getPlayerPokemon()!; + + game.move.select(Moves.UPPER_HAND); + await game.phaseInterceptor.to("BerryPhase"); + + expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.FAIL); + expect(feebas.isFullHp()).toBeFalsy(); + }); });