2024-07-25 15:51:05 -07:00
|
|
|
import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
|
|
|
|
import { Stat } from "#app/data/pokemon-stat";
|
2024-08-06 07:06:25 -07:00
|
|
|
import { CommandPhase, MoveEffectPhase } from "#app/phases";
|
|
|
|
import GameManager from "#test/utils/gameManager";
|
|
|
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
2024-07-25 15:51:05 -07:00
|
|
|
import { Command } from "#app/ui/command-ui-handler";
|
|
|
|
import { Mode } from "#app/ui/ui";
|
2024-06-17 18:30:42 -06:00
|
|
|
import * as Utils from "#app/utils";
|
2024-07-25 15:51:05 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-08-07 05:52:20 -07:00
|
|
|
import { BattlerIndex } from "#app/battle.js";
|
2024-08-08 11:15:45 +08:00
|
|
|
import { mockTurnOrder } from "../utils/testUtils";
|
2024-06-17 18:30:42 -06:00
|
|
|
|
|
|
|
|
|
|
|
describe("Abilities - Shield Dust", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
const movesToUse = [Moves.AIR_SLASH];
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.ONIX);
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.SHIELD_DUST);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset(movesToUse);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]);
|
2024-06-17 18:30:42 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Shield Dust", async() => {
|
|
|
|
const moveToUse = Moves.AIR_SLASH;
|
|
|
|
await game.startBattle([
|
|
|
|
Species.PIDGEOT
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
|
|
|
|
expect(game.scene.getParty()[0].formIndex).toBe(0);
|
|
|
|
|
|
|
|
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
|
|
|
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
|
|
|
});
|
|
|
|
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
|
|
|
|
const movePosition = getMovePosition(game.scene, 0, moveToUse);
|
|
|
|
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
|
|
|
});
|
|
|
|
|
2024-08-08 11:15:45 +08:00
|
|
|
await mockTurnOrder(game, [BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
|
2024-06-17 18:30:42 -06:00
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
|
|
|
|
|
|
|
// Shield Dust negates secondary effect
|
|
|
|
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
|
|
|
const move = phase.move.getMove();
|
|
|
|
expect(move.id).toBe(Moves.AIR_SLASH);
|
|
|
|
|
|
|
|
const chance = new Utils.IntegerHolder(move.chance);
|
2024-08-07 09:23:12 -07:00
|
|
|
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, chance, move, phase.getTarget(), false);
|
|
|
|
applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getTarget()!, phase.getUserPokemon()!, null!, null!, chance);
|
2024-06-17 18:30:42 -06:00
|
|
|
expect(chance.value).toBe(0);
|
|
|
|
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
//TODO King's Rock Interaction Unit Test
|
|
|
|
});
|