mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 00:52:47 +02:00
https://github.com/pagefaultgames/pokerogue/pull/5513
* Add prependToPhaseWithCondition and use it in SummonPhase to determine speed order
* Move logic to PostSummonPhase
* Add test base
* Pivot to using sort strategy instead
* Add and update tests
* Support priority ability activations
* Ensure priority abilities are still activated on switch in
* Add test for priority
* Update to use priority numbers instead of a boolean
* Add ability priorities to constructors
* Move sorting to BattleScene
* Rename phase file
* Update import
* Move application to applyPostSummonAbAttrs and stop assuming no other phases in queue
* Ensure all PostSummonPhases from encounters are added at the same time
* Switch to priority queue approach
* Ensure that zero/negative priority activations happen after postsummonphase
* Revert 07646fe
(not needed due to stable sort)
* Always create separate ability phases for passive and use boolean instead of priority number when applying
* Add test for dynamic updates
* Add BattlerIndex import
* Clear queues for testing
* Benjie suggestion
* Split files
* Update import in battlescene
* Remove extra spaces added by VSCode
* Fix other conflicts
* Update PhaseManager
* Update to use PhaseManager
* Immediately start postsummons
* Fix test
* Fix BattlerIndex import
* Remove unused imports
* Fix postsummon application
* Make priority readonly
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
import { AbilityId } from "#enums/ability-id";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import { Stat } from "#enums/stat";
|
|
import { WeatherType } from "#enums/weather-type";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
describe("Ability Activation Order", () => {
|
|
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([MoveId.SPLASH])
|
|
.ability(AbilityId.BALL_FETCH)
|
|
.battleStyle("single")
|
|
.disableCrits()
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyAbility(AbilityId.BALL_FETCH)
|
|
.enemyMoveset(MoveId.SPLASH);
|
|
});
|
|
|
|
it("should activate the ability of the faster Pokemon first", async () => {
|
|
game.override.enemyLevel(100).ability(AbilityId.DRIZZLE).enemyAbility(AbilityId.DROUGHT);
|
|
await game.classicMode.startBattle([SpeciesId.SLOWPOKE]);
|
|
|
|
// Enemy's ability should activate first, so sun ends up replaced with rain
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.RAIN);
|
|
});
|
|
|
|
it("should consider base stat boosting items in determining order", async () => {
|
|
game.override
|
|
.startingLevel(25)
|
|
.enemyLevel(50)
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyAbility(AbilityId.DROUGHT)
|
|
.ability(AbilityId.DRIZZLE)
|
|
.startingHeldItems([{ name: "BASE_STAT_BOOSTER", type: Stat.SPD, count: 100 }]);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SUNNY);
|
|
});
|
|
|
|
it("should consider stat boosting items in determining order", async () => {
|
|
game.override
|
|
.startingLevel(35)
|
|
.enemyLevel(50)
|
|
.enemySpecies(SpeciesId.DITTO)
|
|
.enemyAbility(AbilityId.DROUGHT)
|
|
.ability(AbilityId.DRIZZLE)
|
|
.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "QUICK_POWDER" }]);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.DITTO]);
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SUNNY);
|
|
});
|
|
|
|
it("should activate priority abilities first", async () => {
|
|
game.override
|
|
.startingLevel(1)
|
|
.enemyLevel(100)
|
|
.enemySpecies(SpeciesId.ACCELGOR)
|
|
.enemyAbility(AbilityId.DROUGHT)
|
|
.ability(AbilityId.NEUTRALIZING_GAS);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.SLOWPOKE]);
|
|
expect(game.scene.arena.weather).toBeUndefined();
|
|
});
|
|
|
|
it("should update dynamically based on speed order", async () => {
|
|
game.override
|
|
.startingLevel(35)
|
|
.enemyLevel(50)
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyAbility(AbilityId.SLOW_START)
|
|
.enemyPassiveAbility(AbilityId.DROUGHT)
|
|
.ability(AbilityId.DRIZZLE);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
|
// Slow start activates and makes enemy slower, so drought activates after drizzle
|
|
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SUNNY);
|
|
});
|
|
});
|