diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index bbba644f70f0..1af9481ed5fe 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -1,6 +1,6 @@ import BattleScene from "#app/battle-scene.js"; import { BattlerIndex } from "#app/battle.js"; -import { applyPreStatStageChangeAbAttrs, ProtectStatAbAttr, applyAbAttrs, StatMultiplierAbAttr, StatStageChangeCopyAbAttr, applyPostStatStageChangeAbAttrs, PostStatStageChangeAbAttr } from "#app/data/ability.js"; +import { applyPreStatStageChangeAbAttrs, ProtectStatAbAttr, applyAbAttrs, StatStageChangeMultiplierAbAttr, StatStageChangeCopyAbAttr, applyPostStatStageChangeAbAttrs, PostStatStageChangeAbAttr } from "#app/data/ability.js"; import { MistTag, ArenaTagSide } from "#app/data/arena-tag.js"; import Pokemon from "#app/field/pokemon.js"; import { getPokemonNameWithAffix } from "#app/messages.js"; @@ -59,7 +59,7 @@ export class StatStageChangePhase extends PokemonPhase { const stages = new Utils.IntegerHolder(this.stages); if (!this.ignoreAbilities) { - applyAbAttrs(StatMultiplierAbAttr, pokemon, null, stages); + applyAbAttrs(StatStageChangeMultiplierAbAttr, pokemon, null, stages); } const relLevels = filteredStats.map(s => (stages.value >= 1 ? Math.min(pokemon.getStatStage(s) + stages.value, 6) : Math.max(pokemon.getStatStage(s) + stages.value, -6)) - pokemon.getStatStage(s)); diff --git a/src/test/abilities/contrary.test.ts b/src/test/abilities/contrary.test.ts new file mode 100644 index 000000000000..75085874fb60 --- /dev/null +++ b/src/test/abilities/contrary.test.ts @@ -0,0 +1,41 @@ +import { Stat } from "#enums/stat"; +import GameManager from "#test/utils/gameManager"; +import { Abilities } from "#enums/abilities"; +import { Species } from "#enums/species"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { SPLASH_ONLY } from "../utils/testUtils"; + +describe("Abilities - Contrary", () => { + 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.battleType("single"); + game.override.enemySpecies(Species.BULBASAUR); + game.override.enemyAbility(Abilities.CONTRARY); + game.override.ability(Abilities.INTIMIDATE); + game.override.enemyMoveset(SPLASH_ONLY); + }); + + it("should invert stat changes when applied", async() => { + await game.startBattle([ + Species.SLOWBRO + ]); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + + expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(1); + }, 20000); +}); diff --git a/src/test/abilities/simple.test.ts b/src/test/abilities/simple.test.ts new file mode 100644 index 000000000000..45d2cc34b39f --- /dev/null +++ b/src/test/abilities/simple.test.ts @@ -0,0 +1,41 @@ +import { Stat } from "#enums/stat"; +import GameManager from "#test/utils/gameManager"; +import { Abilities } from "#enums/abilities"; +import { Species } from "#enums/species"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { SPLASH_ONLY } from "../utils/testUtils"; + +describe("Abilities - Simple", () => { + 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.battleType("single"); + game.override.enemySpecies(Species.BULBASAUR); + game.override.enemyAbility(Abilities.SIMPLE); + game.override.ability(Abilities.INTIMIDATE); + game.override.enemyMoveset(SPLASH_ONLY); + }); + + it("should double stat changes when applied", async() => { + await game.startBattle([ + Species.SLOWBRO + ]); + + const enemyPokemon = game.scene.getEnemyPokemon()!; + + expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(-2); + }, 20000); +});