From 293895f86f7612607d9f3352eb6bea67bf149463 Mon Sep 17 00:00:00 2001 From: frutescens Date: Sun, 13 Oct 2024 19:50:39 -0700 Subject: [PATCH] test --- src/data/move.ts | 125 ++++++++++++++-------------- src/test/moves/secret_power.test.ts | 58 +++++++++++++ 2 files changed, 120 insertions(+), 63 deletions(-) create mode 100644 src/test/moves/secret_power.test.ts diff --git a/src/data/move.ts b/src/data/move.ts index 118f51592c7..bbcd7a4c217 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -2898,71 +2898,70 @@ export class SecretPowerAttr extends MoveEffectAttr { secondaryEffect = new StatStageChangeAttr([ Stat.SPD ], -1, false); break; } - } - const biome = user.scene.arena.biomeType; - switch (biome) { - case Biome.TOWN: - case Biome.METROPOLIS: - case Biome.SLUM: - case Biome.DOJO: - case Biome.FACTORY: - case Biome.CONSTRUCTION_SITE: - case Biome.LABORATORY: - case Biome.POWER_PLANT: - secondaryEffect = new StatusEffectAttr(StatusEffect.PARALYSIS, false); - break; - case Biome.PLAINS: - case Biome.GRASS: - case Biome.TALL_GRASS: - case Biome.FOREST: - case Biome.JUNGLE: - case Biome.MEADOW: - secondaryEffect = new StatusEffectAttr(StatusEffect.SLEEP, false); - break; - case Biome.SWAMP: - secondaryEffect = new StatStageChangeAttr([ Stat.SPD ], -1, false); - break; - case Biome.ICE_CAVE: - case Biome.SNOWY_FOREST: - secondaryEffect = new StatusEffectAttr(StatusEffect.FREEZE, false); - break; - case Biome.VOLCANO: - secondaryEffect = new StatusEffectAttr(StatusEffect.BURN, false); - break; - case Biome.FAIRY_CAVE: - secondaryEffect = new StatStageChangeAttr([ Stat.SPATK ], -1, false); - break; - case Biome.DESERT: - secondaryEffect = new StatStageChangeAttr([ Stat.ACC ], -1, false); - break; - case Biome.SEA: - case Biome.BEACH: - case Biome.LAKE: - case Biome.ISLAND: - case Biome.SEABED: - secondaryEffect = new StatStageChangeAttr([ Stat.ATK ], -1, false); - break; - case Biome.MOUNTAIN: - case Biome.BADLANDS: - case Biome.CAVE: - case Biome.WASTELAND: - secondaryEffect = new AddBattlerTagAttr(BattlerTagType.FLINCHED, false, true); - break; - case Biome.SPACE: - secondaryEffect = new StatStageChangeAttr([ Stat.DEF ], -1, false); - break; - case Biome.GRAVEYARD: - case Biome.RUINS: - case Biome.ABYSS: - - case Biome.TEMPLE: - case Biome.END: - default: - return true; + } else { + const biome = user.scene.arena.biomeType; + switch (biome) { + case Biome.TOWN: + case Biome.METROPOLIS: + case Biome.SLUM: + case Biome.DOJO: + case Biome.FACTORY: + case Biome.CONSTRUCTION_SITE: + case Biome.LABORATORY: + case Biome.POWER_PLANT: + secondaryEffect = new StatusEffectAttr(StatusEffect.PARALYSIS, false); + break; + case Biome.PLAINS: + case Biome.GRASS: + case Biome.TALL_GRASS: + case Biome.FOREST: + case Biome.JUNGLE: + case Biome.MEADOW: + secondaryEffect = new StatusEffectAttr(StatusEffect.SLEEP, false); + break; + case Biome.SWAMP: + secondaryEffect = new StatStageChangeAttr([ Stat.SPD ], -1, false); + break; + case Biome.ICE_CAVE: + case Biome.SNOWY_FOREST: + secondaryEffect = new StatusEffectAttr(StatusEffect.FREEZE, false); + break; + case Biome.VOLCANO: + secondaryEffect = new StatusEffectAttr(StatusEffect.BURN, false); + break; + case Biome.FAIRY_CAVE: + secondaryEffect = new StatStageChangeAttr([ Stat.SPATK ], -1, false); + break; + case Biome.DESERT: + secondaryEffect = new StatStageChangeAttr([ Stat.ACC ], -1, false); + break; + case Biome.SEA: + case Biome.BEACH: + case Biome.LAKE: + case Biome.ISLAND: + case Biome.SEABED: + secondaryEffect = new StatStageChangeAttr([ Stat.ATK ], -1, false); + break; + case Biome.MOUNTAIN: + case Biome.BADLANDS: + case Biome.CAVE: + case Biome.WASTELAND: + secondaryEffect = new AddBattlerTagAttr(BattlerTagType.FLINCHED, false, true); + break; + case Biome.SPACE: + secondaryEffect = new StatStageChangeAttr([ Stat.DEF ], -1, false); + break; + case Biome.GRAVEYARD: + case Biome.RUINS: + case Biome.ABYSS: + case Biome.TEMPLE: + case Biome.END: + default: + return true; + } } return secondaryEffect.apply(user, target, move, []); } - } export class PostVictoryStatStageChangeAttr extends MoveAttr { @@ -7981,7 +7980,7 @@ export function initMoves() { .unimplemented(), new SelfStatusMove(Moves.SNATCH, Type.DARK, -1, 10, -1, 4, 3) .unimplemented(), - new AttackMove(Moves.SECRET_POWER, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 20, 30, 0, 3) + new AttackMove(Moves.SECRET_POWER, Type.NORMAL, MoveCategory.PHYSICAL, 70, 100, 20, 100, 0, 3) .makesContact(false) .attr(SecretPowerAttr), new AttackMove(Moves.DIVE, Type.WATER, MoveCategory.PHYSICAL, 80, 100, 10, -1, 0, 3) diff --git a/src/test/moves/secret_power.test.ts b/src/test/moves/secret_power.test.ts new file mode 100644 index 00000000000..1f5146da5dc --- /dev/null +++ b/src/test/moves/secret_power.test.ts @@ -0,0 +1,58 @@ +import { Abilities } from "#enums/abilities"; +import { Biome } from "#app/enums/biome"; +import { Moves } from "#enums/moves"; +import { Stat } from "#enums/stat"; +import { allMoves } from "#app/data/move"; +import { Species } from "#enums/species"; +import GameManager from "#test/utils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import { StatusEffect } from "#app/enums/status-effect"; + +describe("Moves - Secret Power", () => { + 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.SECRET_POWER ]) + .ability(Abilities.BALL_FETCH) + .battleType("single") + .disableCrits() + .enemySpecies(Species.MAGIKARP) + .enemyLevel(60) + .enemyAbility(Abilities.BALL_FETCH) + .enemyMoveset([ Moves.SPLASH, Moves.MISTY_TERRAIN ]); + vi.spyOn(allMoves[Moves.SECRET_POWER], "chance", "get").mockReturnValue(100); + }); + + it("Secret Power checks for an active terrain first then looks at the biome for its secondary effect", async () => { + game.override.startingBiome(Biome.METROPOLIS); + await game.classicMode.startBattle([ Species.FEEBAS ]); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + + // No Terrain + Biome.METROPOLIS --> Paralysis + game.move.select(Moves.SECRET_POWER); + await game.forceEnemyMove(Moves.SPLASH); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemyPokemon.status?.effect).toBe(StatusEffect.PARALYSIS); + + // Misty Terrain --> SpAtk -1 + game.move.select(Moves.SECRET_POWER); + await game.forceEnemyMove(Moves.MISTY_TERRAIN); + await game.phaseInterceptor.to("TurnEndPhase"); + expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1); + }); +});