mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 08:22:16 +02:00
Fix Contrary & Simple, Verify with Unit Tests
This commit is contained in:
parent
e3059fd3e7
commit
27a971e908
@ -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));
|
||||
|
41
src/test/abilities/contrary.test.ts
Normal file
41
src/test/abilities/contrary.test.ts
Normal file
@ -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);
|
||||
});
|
41
src/test/abilities/simple.test.ts
Normal file
41
src/test/abilities/simple.test.ts
Normal file
@ -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);
|
||||
});
|
Loading…
Reference in New Issue
Block a user