From e95824106910cdeb0ae55d5c167a77f1daff5442 Mon Sep 17 00:00:00 2001 From: frutescens Date: Mon, 14 Oct 2024 20:13:57 -0700 Subject: [PATCH] secret power atr --- src/data/move.ts | 2 +- src/test/moves/secret_power.test.ts | 42 +++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index d2eff3d4019..73792d2d3bb 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -1024,7 +1024,7 @@ export class MoveEffectAttr extends MoveAttr { applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, false, moveChance, move, target, selfEffect, showAbility); - if (!move.hasAttr(FlinchAttr) || moveChance.value <= move.chance) { + if ((!move.hasAttr(FlinchAttr) || moveChance.value <= move.chance) && !move.hasAttr(SecretPowerAttr)) { const userSide = user.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; user.scene.arena.applyTagsForSide(ArenaTagType.WATER_FIRE_PLEDGE, userSide, moveChance); } diff --git a/src/test/moves/secret_power.test.ts b/src/test/moves/secret_power.test.ts index 416d0e84f22..bde3c4585d2 100644 --- a/src/test/moves/secret_power.test.ts +++ b/src/test/moves/secret_power.test.ts @@ -2,12 +2,15 @@ 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 { allMoves, SecretPowerAttr } 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"; +import { BattlerIndex } from "#app/battle"; +import { ArenaTagType } from "#app/enums/arena-tag-type"; +import { ArenaTagSide } from "#app/data/arena-tag"; describe("Moves - Secret Power", () => { let phaserGame: Phaser.Game; @@ -32,13 +35,14 @@ describe("Moves - Secret Power", () => { .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); + .enemyAbility(Abilities.BALL_FETCH); }); it("Secret Power checks for an active terrain first then looks at the biome for its secondary effect", async () => { - game.override.startingBiome(Biome.VOLCANO); + game.override + .startingBiome(Biome.VOLCANO) + .enemyMoveset([ Moves.SPLASH, Moves.MISTY_TERRAIN ]); + vi.spyOn(allMoves[Moves.SECRET_POWER], "chance", "get").mockReturnValue(100); await game.classicMode.startBattle([ Species.FEEBAS ]); const enemyPokemon = game.scene.getEnemyPokemon()!; @@ -55,4 +59,32 @@ describe("Moves - Secret Power", () => { await game.phaseInterceptor.to("TurnEndPhase"); expect(enemyPokemon.getStatStage(Stat.SPATK)).toBe(-1); }); + + it("the 'rainbow' effect of fire+water pledge does not double the chance of secret power's secondary effect", + async () => { + game.override + .moveset([ Moves.FIRE_PLEDGE, Moves.WATER_PLEDGE, Moves.SECRET_POWER, Moves.SPLASH ]) + .enemyMoveset([ Moves.SPLASH ]) + .battleType("double"); + + await game.classicMode.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]); + + const secretPowerAttr = allMoves[Moves.SECRET_POWER].getAttrs(SecretPowerAttr)[0]; + vi.spyOn(secretPowerAttr, "getMoveChance"); + + game.move.select(Moves.WATER_PLEDGE, 0, BattlerIndex.ENEMY); + game.move.select(Moves.FIRE_PLEDGE, 1, BattlerIndex.ENEMY_2); + + await game.phaseInterceptor.to("TurnEndPhase"); + + expect(game.scene.arena.getTagOnSide(ArenaTagType.WATER_FIRE_PLEDGE, ArenaTagSide.PLAYER)).toBeDefined(); + + game.move.select(Moves.SECRET_POWER, 0, BattlerIndex.ENEMY); + game.move.select(Moves.SPLASH, 1); + + await game.phaseInterceptor.to("BerryPhase", false); + + expect(secretPowerAttr.getMoveChance).toHaveLastReturnedWith(30); + } + ); });