From 4edcdc91921fd0dd7d4e9ca22ae85ebe928e6391 Mon Sep 17 00:00:00 2001 From: thisPieonFire Date: Wed, 6 Aug 2025 14:48:11 +0200 Subject: [PATCH] [Bug] [Move] Court Change now swaps Safeguard and Pledge Effects (#6069) * Add unit test for the "Court Change" move * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Add unit test for the "Court Change" move * Improve formatting in the "Court Change" move unit test * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update test/moves/court-change.test.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Added missing import * Added missing import (ArenaTagSide) * Update court-change.test.ts --------- Co-authored-by: PieonFire Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/data/moves/move.ts | 2 +- test/moves/court-change.test.ts | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 test/moves/court-change.test.ts diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 0dfbc78d7ae..757f57e0b1f 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -10888,7 +10888,7 @@ export function initMoves() { .attr(MovePowerMultiplierAttr, (_user, target) => target.turnData.acted ? 1 : 2) .bitingMove(), new StatusMove(MoveId.COURT_CHANGE, PokemonType.NORMAL, 100, 10, -1, 0, 8) - .attr(SwapArenaTagsAttr, [ ArenaTagType.AURORA_VEIL, ArenaTagType.LIGHT_SCREEN, ArenaTagType.MIST, ArenaTagType.REFLECT, ArenaTagType.SPIKES, ArenaTagType.STEALTH_ROCK, ArenaTagType.STICKY_WEB, ArenaTagType.TAILWIND, ArenaTagType.TOXIC_SPIKES ]), + .attr(SwapArenaTagsAttr, [ ArenaTagType.AURORA_VEIL, ArenaTagType.LIGHT_SCREEN, ArenaTagType.MIST, ArenaTagType.REFLECT, ArenaTagType.SPIKES, ArenaTagType.STEALTH_ROCK, ArenaTagType.STICKY_WEB, ArenaTagType.TAILWIND, ArenaTagType.TOXIC_SPIKES, ArenaTagType.SAFEGUARD, ArenaTagType.FIRE_GRASS_PLEDGE, ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagType.GRASS_WATER_PLEDGE ]), /* Unused */ new AttackMove(MoveId.MAX_FLARE, PokemonType.FIRE, MoveCategory.PHYSICAL, 10, -1, 10, -1, 0, 8) .target(MoveTarget.NEAR_ENEMY) diff --git a/test/moves/court-change.test.ts b/test/moves/court-change.test.ts new file mode 100644 index 00000000000..a27854c12be --- /dev/null +++ b/test/moves/court-change.test.ts @@ -0,0 +1,85 @@ +import { AbilityId } from "#enums/ability-id"; +import { ArenaTagSide } from "#enums/arena-tag-side"; +import { ArenaTagType } from "#enums/arena-tag-type"; +import { MoveId } from "#enums/move-id"; +import { SpeciesId } from "#enums/species-id"; +import { Stat } from "#enums/stat"; +import { StatusEffect } from "#enums/status-effect"; +import { GameManager } from "#test/test-utils/game-manager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +describe("Move - Court Change", () => { + 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 + .ability(AbilityId.BALL_FETCH) + .criticalHits(false) + .enemyAbility(AbilityId.STURDY) + .startingLevel(100) + .battleStyle("single") + .enemySpecies(SpeciesId.MAGIKARP) + .enemyMoveset(MoveId.SPLASH); + }); + + it("should swap combined Pledge effects to the opposite side", async () => { + game.override.battleStyle("double"); + await game.classicMode.startBattle([SpeciesId.REGIELEKI, SpeciesId.SHUCKLE]); + + const regieleki = game.field.getPlayerPokemon(); + const enemyPokemon = game.field.getEnemyPokemon(); + + game.move.use(MoveId.WATER_PLEDGE); + game.move.use(MoveId.GRASS_PLEDGE, 1); + await game.toNextTurn(); + + // enemy team will be in the swamp and slowed + expect(game.scene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, ArenaTagSide.ENEMY)).toBeDefined(); + expect(enemyPokemon.getEffectiveStat(Stat.SPD)).toBe(enemyPokemon.getStat(Stat.SPD) / 4); + + game.move.use(MoveId.COURT_CHANGE); + game.move.use(MoveId.SPLASH, 1); + await game.toEndOfTurn(); + + // own team should now be in the swamp and slowed + expect(game.scene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, ArenaTagSide.ENEMY)).toBeUndefined(); + expect(game.scene.arena.getTagOnSide(ArenaTagType.GRASS_WATER_PLEDGE, ArenaTagSide.PLAYER)).toBeDefined(); + expect(regieleki.getEffectiveStat(Stat.SPD)).toBe(regieleki.getStat(Stat.SPD) / 4); + }); + + it("should swap safeguard to the enemy side ", async () => { + game.override.enemyMoveset(MoveId.TOXIC_THREAD); + await game.classicMode.startBattle([SpeciesId.NINJASK]); + + const ninjask = game.field.getPlayerPokemon(); + + game.move.use(MoveId.SAFEGUARD); + await game.move.forceEnemyMove(MoveId.TOXIC_THREAD); + await game.toNextTurn(); + + // Ninjask will not be poisoned because of Safeguard + expect(game.scene.arena.getTagOnSide(ArenaTagType.SAFEGUARD, ArenaTagSide.PLAYER)).toBeDefined(); + expect(ninjask.status?.effect).toBeUndefined(); + + game.move.use(MoveId.COURT_CHANGE); + await game.toEndOfTurn(); + + // Ninjask should now be poisoned due to lack of Safeguard + expect(game.scene.arena.getTagOnSide(ArenaTagType.SAFEGUARD, ArenaTagSide.PLAYER)).toBeUndefined(); + expect(game.scene.arena.getTagOnSide(ArenaTagType.SAFEGUARD, ArenaTagSide.ENEMY)).toBeDefined(); + expect(ninjask.status?.effect).toBe(StatusEffect.POISON); + }); +});