[Test] Replace `doAttack()` with `move.select()` in tests (#3567)

* Consolidate `doSelectTarget()` into `doAttack()`

* Fix ternary

* Add error message to aid in debugging tests

* Update docs

* [Test] Change `doAttack()` to `selectMove()`

* Add `select()` to `src/test/utils/helpers/moveHelper.ts`

* Replace instances of `game.selectMove()` with `game.move.select()`

* Fix imports

* Replace `selectMove()` with `move.select()` helper

Fix broken tests for Pastel Veil and Sweet Veil

* Update tsdocs
This commit is contained in:
NightKev 2024-08-22 06:49:33 -07:00 committed by GitHub
parent 10f1a96ed6
commit 828897316e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
167 changed files with 1827 additions and 2378 deletions

View File

@ -1,15 +1,15 @@
import { CommandPhase } from "#app/phases/command-phase";
import { MessagePhase } from "#app/phases/message-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import i18next, { initI18n } from "#app/plugins/i18n"; import i18next, { initI18n } from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MessagePhase } from "#app/phases/message-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
describe("Ability Timing", () => { describe("Ability Timing", () => {

View File

@ -1,19 +1,18 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
describe("Abilities - Aura Break", () => { describe("Abilities - Aura Break", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
const auraBreakMultiplier = 9/16 * 4/3; const auraBreakMultiplier = 9 / 16 * 4 / 3;
beforeAll(() => { beforeAll(() => {
phaserGame = new Phaser.Game({ phaserGame = new Phaser.Game({
@ -42,7 +41,7 @@ describe("Abilities - Aura Break", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.MOONBLAST)); game.move.select(Moves.MOONBLAST);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(expect.closeTo(basePower * auraBreakMultiplier)); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(expect.closeTo(basePower * auraBreakMultiplier));
@ -56,7 +55,7 @@ describe("Abilities - Aura Break", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DARK_PULSE)); game.move.select(Moves.DARK_PULSE);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(expect.closeTo(basePower * auraBreakMultiplier)); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(expect.closeTo(basePower * auraBreakMultiplier));

View File

@ -1,14 +1,13 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Battery", () => { describe("Abilities - Battery", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -43,8 +42,8 @@ describe("Abilities - Battery", () => {
await game.startBattle([Species.PIKACHU, Species.CHARJABUG]); await game.startBattle([Species.PIKACHU, Species.CHARJABUG]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); game.move.select(Moves.DAZZLING_GLEAM);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * batteryMultiplier); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * batteryMultiplier);
@ -58,8 +57,8 @@ describe("Abilities - Battery", () => {
await game.startBattle([Species.PIKACHU, Species.CHARJABUG]); await game.startBattle([Species.PIKACHU, Species.CHARJABUG]);
game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); game.move.select(Moves.BREAKING_SWIPE);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower);
@ -73,8 +72,8 @@ describe("Abilities - Battery", () => {
await game.startBattle([Species.CHARJABUG, Species.PIKACHU]); await game.startBattle([Species.CHARJABUG, Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); game.move.select(Moves.DAZZLING_GLEAM);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower);

View File

@ -1,11 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect.js"; import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -53,7 +52,7 @@ describe("Abilities - BATTLE BOND", () => {
greninja!.status = new Status(StatusEffect.FAINT); greninja!.status = new Status(StatusEffect.FAINT);
expect(greninja!.isFainted()).toBe(true); expect(greninja!.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();

View File

@ -1,14 +1,13 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves.js"; import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { CommandPhase } from "#app/phases/command-phase";
import { MessagePhase } from "#app/phases/message-phase";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MessagePhase } from "#app/phases/message-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -44,15 +43,15 @@ describe("Abilities - COSTAR", () => {
let [leftPokemon, rightPokemon] = game.scene.getPlayerField(); let [leftPokemon, rightPokemon] = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.NASTY_PLOT)); game.move.select(Moves.NASTY_PLOT);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.toNextTurn(); await game.toNextTurn();
expect(leftPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2); expect(leftPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2);
expect(rightPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(0); expect(rightPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doSwitchPokemon(2); game.doSwitchPokemon(2);
await game.phaseInterceptor.to(MessagePhase); await game.phaseInterceptor.to(MessagePhase);
@ -76,7 +75,7 @@ describe("Abilities - COSTAR", () => {
expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2); expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2);
expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2); expect(leftPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-2);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doSwitchPokemon(2); game.doSwitchPokemon(2);
await game.phaseInterceptor.to(MessagePhase); await game.phaseInterceptor.to(MessagePhase);

View File

@ -1,18 +1,17 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { BattleStat } from "#app/data/battle-stat";
import GameManager from "#test/utils/gameManager"; import { StatusEffect } from "#app/data/status-effect";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { CommandPhase } from "#app/phases/command-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Mode } from "#app/ui/ui";
import { toDmgValue } from "#app/utils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { StatusEffect } from "#app/data/status-effect.js"; import GameManager from "#test/utils/gameManager";
import { BattleStat } from "#app/data/battle-stat.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { toDmgValue } from "#app/utils";
import { Mode } from "#app/ui/ui.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
import { CommandPhase } from "#app/phases/command-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -52,7 +51,7 @@ describe("Abilities - Disguise", () => {
expect(mimikyu.formIndex).toBe(disguisedForm); expect(mimikyu.formIndex).toBe(disguisedForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SHADOW_SNEAK)); game.move.select(Moves.SHADOW_SNEAK);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -67,7 +66,7 @@ describe("Abilities - Disguise", () => {
expect(mimikyu.formIndex).toBe(disguisedForm); expect(mimikyu.formIndex).toBe(disguisedForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.VACUUM_WAVE)); game.move.select(Moves.VACUUM_WAVE);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -85,7 +84,7 @@ describe("Abilities - Disguise", () => {
expect(mimikyu.formIndex).toBe(disguisedForm); expect(mimikyu.formIndex).toBe(disguisedForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURGING_STRIKES)); game.move.select(Moves.SURGING_STRIKES);
// First hit // First hit
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
@ -104,7 +103,7 @@ describe("Abilities - Disguise", () => {
const mimikyu = game.scene.getEnemyPokemon()!; const mimikyu = game.scene.getEnemyPokemon()!;
expect(mimikyu.hp).toBe(mimikyu.getMaxHp()); expect(mimikyu.hp).toBe(mimikyu.getMaxHp());
game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC_THREAD)); game.move.select(Moves.TOXIC_THREAD);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -124,7 +123,7 @@ describe("Abilities - Disguise", () => {
const maxHp = mimikyu.getMaxHp(); const maxHp = mimikyu.getMaxHp();
const disguiseDamage = toDmgValue(maxHp / 8); const disguiseDamage = toDmgValue(maxHp / 8);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -149,7 +148,7 @@ describe("Abilities - Disguise", () => {
const mimikyu = game.scene.getParty()[1]!; const mimikyu = game.scene.getParty()[1]!;
expect(mimikyu.formIndex).toBe(bustedForm); expect(mimikyu.formIndex).toBe(bustedForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.toNextWave(); await game.toNextWave();
@ -169,7 +168,7 @@ describe("Abilities - Disguise", () => {
expect(mimikyu.formIndex).toBe(bustedForm); expect(mimikyu.formIndex).toBe(bustedForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.toNextWave(); await game.toNextWave();
@ -189,11 +188,11 @@ describe("Abilities - Disguise", () => {
expect(mimikyu1.formIndex).toBe(bustedForm); expect(mimikyu1.formIndex).toBe(bustedForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.killPokemon(mimikyu1); await game.killPokemon(mimikyu1);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { // TODO: Make tests run in set mode instead of switch mode game.onNextPrompt("CheckSwitchPhase", Mode.CONFIRM, () => { // TODO: Make tests run in set mode instead of switch mode
game.setMode(Mode.MESSAGE); game.setMode(Mode.MESSAGE);

View File

@ -1,12 +1,11 @@
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import GameManager from "#test/utils/gameManager"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Dry Skin", () => { describe("Abilities - Dry Skin", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -43,13 +42,13 @@ describe("Abilities - Dry Skin", () => {
// first turn // first turn
let previousEnemyHp = enemy.hp; let previousEnemyHp = enemy.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.SUNNY_DAY)); game.move.select(Moves.SUNNY_DAY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.hp).toBeLessThan(previousEnemyHp); expect(enemy.hp).toBeLessThan(previousEnemyHp);
// second turn // second turn
previousEnemyHp = enemy.hp; previousEnemyHp = enemy.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.hp).toBeLessThan(previousEnemyHp); expect(enemy.hp).toBeLessThan(previousEnemyHp);
}); });
@ -66,13 +65,13 @@ describe("Abilities - Dry Skin", () => {
// first turn // first turn
let previousEnemyHp = enemy.hp; let previousEnemyHp = enemy.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.RAIN_DANCE)); game.move.select(Moves.RAIN_DANCE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.hp).toBeGreaterThan(previousEnemyHp); expect(enemy.hp).toBeGreaterThan(previousEnemyHp);
// second turn // second turn
previousEnemyHp = enemy.hp; previousEnemyHp = enemy.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.hp).toBeGreaterThan(previousEnemyHp); expect(enemy.hp).toBeGreaterThan(previousEnemyHp);
}); });
@ -87,7 +86,7 @@ describe("Abilities - Dry Skin", () => {
enemy.hp = initialHP; enemy.hp = initialHP;
// first turn // first turn
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); game.move.select(Moves.FLAMETHROWER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const fireDamageTakenWithDrySkin = initialHP - enemy.hp; const fireDamageTakenWithDrySkin = initialHP - enemy.hp;
@ -96,7 +95,7 @@ describe("Abilities - Dry Skin", () => {
game.override.enemyAbility(Abilities.NONE); game.override.enemyAbility(Abilities.NONE);
// second turn // second turn
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); game.move.select(Moves.FLAMETHROWER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const fireDamageTakenWithoutDrySkin = initialHP - enemy.hp; const fireDamageTakenWithoutDrySkin = initialHP - enemy.hp;
@ -113,7 +112,7 @@ describe("Abilities - Dry Skin", () => {
enemy.hp = 1; enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); game.move.select(Moves.WATER_GUN);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.hp).toBeGreaterThan(1); expect(enemy.hp).toBeGreaterThan(1);
}); });
@ -129,7 +128,7 @@ describe("Abilities - Dry Skin", () => {
enemy.hp = 1; enemy.hp = 1;
game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]); game.override.enemyMoveset([Moves.PROTECT, Moves.PROTECT, Moves.PROTECT, Moves.PROTECT]);
game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); game.move.select(Moves.WATER_GUN);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.hp).toBe(1); expect(enemy.hp).toBe(1);
}); });
@ -145,14 +144,14 @@ describe("Abilities - Dry Skin", () => {
enemy.hp = 1; enemy.hp = 1;
// first turn // first turn
game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_SHURIKEN)); game.move.select(Moves.WATER_SHURIKEN);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const healthGainedFromWaterShuriken = enemy.hp - 1; const healthGainedFromWaterShuriken = enemy.hp - 1;
enemy.hp = 1; enemy.hp = 1;
// second turn // second turn
game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); game.move.select(Moves.WATER_GUN);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const healthGainedFromWaterGun = enemy.hp - 1; const healthGainedFromWaterGun = enemy.hp - 1;

View File

@ -1,16 +1,15 @@
import { Species } from "#app/enums/species.js"; import { BattlerIndex } from "#app/battle";
import GameManager from "#test/utils/gameManager"; import { StatusEffect } from "#app/data/status-effect";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Species } from "#app/enums/species";
import { MovePhase } from "#app/phases/move-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { StatusEffect } from "#app/data/status-effect.js";
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
import { BattlerIndex } from "#app/battle.js";
import { MovePhase } from "#app/phases/move-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Flash Fire", () => { describe("Abilities - Flash Fire", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -38,35 +37,35 @@ describe("Abilities - Flash Fire", () => {
}); });
it("immune to Fire-type moves", async() => { it("immune to Fire-type moves", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset(SPLASH_ONLY); game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset(SPLASH_ONLY);
await game.startBattle([Species.BLISSEY]); await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!; const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(blissey.hp).toBe(blissey.getMaxHp()); expect(blissey.hp).toBe(blissey.getMaxHp());
}, 20000); }, 20000);
it("not activate if the Pokémon is protected from the Fire-type move", async() => { it("not activate if the Pokémon is protected from the Fire-type move", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset([Moves.PROTECT]); game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset([Moves.PROTECT]);
await game.startBattle([Species.BLISSEY]); await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!; const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT)); game.move.select(Moves.PROTECT);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined(); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined();
}, 20000); }, 20000);
it("activated by Will-O-Wisp", async() => { it("activated by Will-O-Wisp", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.WILL_O_WISP)).moveset(SPLASH_ONLY); game.override.enemyMoveset(Array(4).fill(Moves.WILL_O_WISP)).moveset(SPLASH_ONLY);
await game.startBattle([Species.BLISSEY]); await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!; const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
await game.move.forceHit(); await game.move.forceHit();
@ -75,25 +74,25 @@ describe("Abilities - Flash Fire", () => {
expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined(); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined();
}, 20000); }, 20000);
it("activated after being frozen", async() => { it("activated after being frozen", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset(SPLASH_ONLY); game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset(SPLASH_ONLY);
game.override.statusEffect(StatusEffect.FREEZE); game.override.statusEffect(StatusEffect.FREEZE);
await game.startBattle([Species.BLISSEY]); await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!; const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined(); expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined();
}, 20000); }, 20000);
it("not passing with baton pass", async() => { it("not passing with baton pass", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset([Moves.BATON_PASS]); game.override.enemyMoveset(Array(4).fill(Moves.EMBER)).moveset([Moves.BATON_PASS]);
await game.startBattle([Species.BLISSEY, Species.CHANSEY]); await game.startBattle([Species.BLISSEY, Species.CHANSEY]);
// ensure use baton pass after enemy moved // ensure use baton pass after enemy moved
game.doAttack(getMovePosition(game.scene, 0, Moves.BATON_PASS)); game.move.select(Moves.BATON_PASS);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
@ -104,7 +103,7 @@ describe("Abilities - Flash Fire", () => {
expect(chansey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined(); expect(chansey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined();
}, 20000); }, 20000);
it("boosts Fire-type move when the ability is activated", async() => { it("boosts Fire-type move when the ability is activated", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.FIRE_PLEDGE)).moveset([Moves.EMBER, Moves.SPLASH]); game.override.enemyMoveset(Array(4).fill(Moves.FIRE_PLEDGE)).moveset([Moves.EMBER, Moves.SPLASH]);
game.override.enemyAbility(Abilities.FLASH_FIRE).ability(Abilities.NONE); game.override.enemyAbility(Abilities.FLASH_FIRE).ability(Abilities.NONE);
await game.startBattle([Species.BLISSEY]); await game.startBattle([Species.BLISSEY]);
@ -113,7 +112,7 @@ describe("Abilities - Flash Fire", () => {
blissey.hp = initialHP; blissey.hp = initialHP;
// first turn // first turn
game.doAttack(getMovePosition(game.scene, 0, Moves.EMBER)); game.move.select(Moves.EMBER);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const originalDmg = initialHP - blissey.hp; const originalDmg = initialHP - blissey.hp;
@ -122,7 +121,7 @@ describe("Abilities - Flash Fire", () => {
blissey.hp = initialHP; blissey.hp = initialHP;
// second turn // second turn
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const flashFireDmg = initialHP - blissey.hp; const flashFireDmg = initialHP - blissey.hp;

View File

@ -1,19 +1,18 @@
import { BattlerTagType } from "#app/enums/battler-tag-type.js"; import { BattleStat } from "#app/data/battle-stat";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { StatusEffect } from "#app/enums/status-effect";
import Pokemon from "#app/field/pokemon";
import { BerryPhase } from "#app/phases/berry-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { TurnStartPhase } from "#app/phases/turn-start-phase";
import GameManager from "#app/test/utils/gameManager"; import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { BattleStat } from "#app/data/battle-stat.js";
import { StatusEffect } from "#app/enums/status-effect.js";
import Pokemon from "#app/field/pokemon.js";
import { BerryPhase } from "#app/phases/berry-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { TurnStartPhase } from "#app/phases/turn-start-phase.js";
describe("Abilities - Gulp Missile", () => { describe("Abilities - Gulp Missile", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -30,7 +29,7 @@ describe("Abilities - Gulp Missile", () => {
* @returns The effect damage of Gulp Missile * @returns The effect damage of Gulp Missile
*/ */
const getEffectDamage = (pokemon: Pokemon): number => { const getEffectDamage = (pokemon: Pokemon): number => {
return Math.max(1, Math.floor(pokemon.getMaxHp() * 1/4)); return Math.max(1, Math.floor(pokemon.getMaxHp() * 1 / 4));
}; };
beforeAll(() => { beforeAll(() => {
@ -58,9 +57,9 @@ describe("Abilities - Gulp Missile", () => {
await game.startBattle([Species.CRAMORANT]); await game.startBattle([Species.CRAMORANT]);
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); game.move.select(Moves.DIVE);
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); game.move.select(Moves.DIVE);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getHpRatio()).toBeGreaterThanOrEqual(.5); expect(cramorant.getHpRatio()).toBeGreaterThanOrEqual(.5);
@ -75,7 +74,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.49); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.49);
expect(cramorant.getHpRatio()).toBe(.49); expect(cramorant.getHpRatio()).toBe(.49);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined();
@ -86,7 +85,7 @@ describe("Abilities - Gulp Missile", () => {
await game.startBattle([Species.CRAMORANT, Species.MAGIKARP]); await game.startBattle([Species.CRAMORANT, Species.MAGIKARP]);
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.toNextTurn(); await game.toNextTurn();
game.doSwitchPokemon(1); game.doSwitchPokemon(1);
@ -101,7 +100,7 @@ describe("Abilities - Gulp Missile", () => {
await game.startBattle([Species.CRAMORANT]); await game.startBattle([Species.CRAMORANT]);
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); game.move.select(Moves.DIVE);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -115,7 +114,7 @@ describe("Abilities - Gulp Missile", () => {
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "damageAndUpdate"); vi.spyOn(enemy, "damageAndUpdate");
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.damageAndUpdate).toHaveReturnedWith(getEffectDamage(enemy)); expect(enemy.damageAndUpdate).toHaveReturnedWith(getEffectDamage(enemy));
@ -128,7 +127,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -150,7 +149,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(enemy, "damageAndUpdate"); vi.spyOn(enemy, "damageAndUpdate");
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -174,7 +173,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(enemy, "damageAndUpdate"); vi.spyOn(enemy, "damageAndUpdate");
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.45); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.45);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined();
@ -194,7 +193,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE)); game.move.select(Moves.DIVE);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -210,7 +209,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
const enemyHpPreEffect = enemy.hp; const enemyHpPreEffect = enemy.hp;
@ -232,7 +231,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -252,7 +251,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!; const cramorant = game.scene.getPlayerPokemon()!;
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55); vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined(); expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -269,7 +268,7 @@ describe("Abilities - Gulp Missile", () => {
game.override.enemyAbility(Abilities.TRACE); game.override.enemyAbility(Abilities.TRACE);
await game.startBattle([Species.CRAMORANT]); await game.startBattle([Species.CRAMORANT]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnStartPhase); await game.phaseInterceptor.to(TurnStartPhase);
expect(game.scene.getEnemyPokemon()?.hasAbility(Abilities.GULP_MISSILE)).toBe(false); expect(game.scene.getEnemyPokemon()?.hasAbility(Abilities.GULP_MISSILE)).toBe(false);

View File

@ -1,14 +1,13 @@
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { StatusEffect } from "#app/enums/status-effect";
import GameManager from "#test/utils/gameManager"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { toDmgValue } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { StatusEffect } from "#app/enums/status-effect.js";
import { toDmgValue } from "#app/utils";
describe("Abilities - Heatproof", () => { describe("Abilities - Heatproof", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -46,14 +45,14 @@ describe("Abilities - Heatproof", () => {
const initialHP = 1000; const initialHP = 1000;
enemy.hp = initialHP; enemy.hp = initialHP;
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); game.move.select(Moves.FLAMETHROWER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const heatproofDamage = initialHP - enemy.hp; const heatproofDamage = initialHP - enemy.hp;
enemy.hp = initialHP; enemy.hp = initialHP;
game.override.enemyAbility(Abilities.BALL_FETCH); game.override.enemyAbility(Abilities.BALL_FETCH);
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); game.move.select(Moves.FLAMETHROWER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const regularDamage = initialHP - enemy.hp; const regularDamage = initialHP - enemy.hp;
@ -69,7 +68,7 @@ describe("Abilities - Heatproof", () => {
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
// Normal burn damage is /16 // Normal burn damage is /16

View File

@ -1,15 +1,14 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { Stat } from "#app/enums/stat.js"; import { Stat } from "#app/enums/stat";
import GameManager from "#test/utils/gameManager"; import { DamagePhase } from "#app/phases/damage-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
describe("Abilities - Hustle", () => { describe("Abilities - Hustle", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -44,7 +43,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getBattleStat"); vi.spyOn(pikachu, "getBattleStat");
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -57,7 +56,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getAccuracyMultiplier"); vi.spyOn(pikachu, "getAccuracyMultiplier");
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(0.8); expect(pikachu.getAccuracyMultiplier).toHaveReturnedWith(0.8);
@ -71,7 +70,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getBattleStat"); vi.spyOn(pikachu, "getBattleStat");
vi.spyOn(pikachu, "getAccuracyMultiplier"); vi.spyOn(pikachu, "getAccuracyMultiplier");
game.doAttack(getMovePosition(game.scene, 0, Moves.GIGA_DRAIN)); game.move.select(Moves.GIGA_DRAIN);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
expect(pikachu.getBattleStat).toHaveReturnedWith(spatk); expect(pikachu.getBattleStat).toHaveReturnedWith(spatk);
@ -89,7 +88,7 @@ describe("Abilities - Hustle", () => {
vi.spyOn(pikachu, "getAccuracyMultiplier"); vi.spyOn(pikachu, "getAccuracyMultiplier");
vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy"); vi.spyOn(allMoves[Moves.FISSURE], "calculateBattleAccuracy");
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp()); expect(enemyPokemon.turnData.damageTaken).toBe(enemyPokemon.getMaxHp());

View File

@ -3,7 +3,6 @@ import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -40,16 +39,16 @@ describe("Abilities - Hyper Cutter", () => {
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.OCTOLOCK)); game.move.select(Moves.OCTOLOCK);
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.DEFOG)); game.move.select(Moves.DEFOG);
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.NOBLE_ROAR)); game.move.select(Moves.NOBLE_ROAR);
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.SAND_ATTACK)); game.move.select(Moves.SAND_ATTACK);
await game.toNextTurn(); await game.toNextTurn();
game.override.moveset([Moves.STRING_SHOT]); game.override.moveset([Moves.STRING_SHOT]);
game.doAttack(getMovePosition(game.scene, 0, Moves.STRING_SHOT)); game.move.select(Moves.STRING_SHOT);
await game.toNextTurn(); await game.toNextTurn();
expect(enemy.summonData.battleStats[BattleStat.ATK]).toEqual(0); expect(enemy.summonData.battleStats[BattleStat.ATK]).toEqual(0);

View File

@ -1,16 +1,15 @@
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { MoveEndPhase } from "#app/phases/move-end-phase";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
describe("Abilities - Ice Face", () => { describe("Abilities - Ice Face", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -39,7 +38,7 @@ describe("Abilities - Ice Face", () => {
it("takes no damage from physical move and transforms to Noice", async () => { it("takes no damage from physical move and transforms to Noice", async () => {
await game.startBattle([Species.HITMONLEE]); await game.startBattle([Species.HITMONLEE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -55,7 +54,7 @@ describe("Abilities - Ice Face", () => {
game.override.enemyLevel(1); game.override.enemyLevel(1);
await game.startBattle([Species.HITMONLEE]); await game.startBattle([Species.HITMONLEE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURGING_STRIKES)); game.move.select(Moves.SURGING_STRIKES);
const eiscue = game.scene.getEnemyPokemon()!; const eiscue = game.scene.getEnemyPokemon()!;
expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeDefined(); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeDefined();
@ -81,7 +80,7 @@ describe("Abilities - Ice Face", () => {
it("takes damage from special moves", async () => { it("takes damage from special moves", async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); game.move.select(Moves.ICE_BEAM);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -95,7 +94,7 @@ describe("Abilities - Ice Face", () => {
it("takes effects from status moves", async () => { it("takes effects from status moves", async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.TOXIC_THREAD)); game.move.select(Moves.TOXIC_THREAD);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -111,7 +110,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); game.move.select(Moves.QUICK_ATTACK);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -133,7 +132,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.EISCUE, Species.NINJASK]); await game.startBattle([Species.EISCUE, Species.NINJASK]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SNOWSCAPE)); game.move.select(Moves.SNOWSCAPE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
let eiscue = game.scene.getPlayerPokemon()!; let eiscue = game.scene.getPlayerPokemon()!;
@ -160,7 +159,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.EISCUE]); await game.startBattle([Species.EISCUE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.HAIL)); game.move.select(Moves.HAIL);
const eiscue = game.scene.getPlayerPokemon()!; const eiscue = game.scene.getPlayerPokemon()!;
await game.phaseInterceptor.to(QuietFormChangePhase); await game.phaseInterceptor.to(QuietFormChangePhase);
@ -179,7 +178,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.EISCUE, Species.MAGIKARP]); await game.startBattle([Species.EISCUE, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); game.move.select(Moves.ICE_BEAM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
let eiscue = game.scene.getPlayerPokemon()!; let eiscue = game.scene.getPlayerPokemon()!;
@ -213,7 +212,7 @@ describe("Abilities - Ice Face", () => {
expect(eiscue.formIndex).toBe(noiceForm); expect(eiscue.formIndex).toBe(noiceForm);
expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined(); expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeUndefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); game.move.select(Moves.ICE_BEAM);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();
@ -228,7 +227,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.GASTRO_ACID)); game.move.select(Moves.GASTRO_ACID);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -244,7 +243,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SKILL_SWAP)); game.move.select(Moves.SKILL_SWAP);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -260,7 +259,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SIMPLE_BEAM)); game.move.select(Moves.SIMPLE_BEAM);
await game.phaseInterceptor.to(TurnInitPhase); await game.phaseInterceptor.to(TurnInitPhase);

View File

@ -1,22 +1,21 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { Mode } from "#app/ui/ui";
import { BattleStat } from "#app/data/battle-stat"; import { BattleStat } from "#app/data/battle-stat";
import { generateStarter, getMovePosition } from "#test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Status, StatusEffect } from "#app/data/status-effect"; import { Status, StatusEffect } from "#app/data/status-effect";
import { GameModes, getGameMode } from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode";
import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase";
import { EncounterPhase } from "#app/phases/encounter-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { SelectStarterPhase } from "#app/phases/select-starter-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { generateStarter } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js"; import Phaser from "phaser";
import { DamagePhase } from "#app/phases/damage-phase.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { EncounterPhase } from "#app/phases/encounter-phase.js";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
import { SelectStarterPhase } from "#app/phases/select-starter-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
describe("Abilities - Intimidate", () => { describe("Abilities - Intimidate", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -217,13 +216,7 @@ describe("Abilities - Intimidate", () => {
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.AERIAL_ACE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(DamagePhase); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(DamagePhase);
await game.killPokemon(game.scene.currentBattle.enemyParty[0]); await game.killPokemon(game.scene.currentBattle.enemyParty[0]);
expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true);
@ -243,13 +236,7 @@ describe("Abilities - Intimidate", () => {
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.AERIAL_ACE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
console.log("===to new turn==="); console.log("===to new turn===");
await game.toNextTurn(); await game.toNextTurn();
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -268,13 +255,7 @@ describe("Abilities - Intimidate", () => {
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.AERIAL_ACE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
console.log("===to new turn==="); console.log("===to new turn===");
await game.toNextTurn(); await game.toNextTurn();
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -282,13 +263,7 @@ describe("Abilities - Intimidate", () => {
battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(0); expect(battleStatsOpponent[BattleStat.ATK]).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.AERIAL_ACE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
console.log("===to new turn==="); console.log("===to new turn===");
await game.toNextTurn(); await game.toNextTurn();
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -307,13 +282,7 @@ describe("Abilities - Intimidate", () => {
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1); expect(battleStatsPokemon[BattleStat.ATK]).toBe(-1);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.AERIAL_ACE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
console.log("===to new turn==="); console.log("===to new turn===");
await game.toNextTurn(); await game.toNextTurn();
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
@ -321,13 +290,7 @@ describe("Abilities - Intimidate", () => {
battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats; battleStatsOpponent = game.scene.currentBattle.enemyParty[0].summonData.battleStats;
expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1); expect(battleStatsOpponent[BattleStat.ATK]).toBe(-1);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.AERIAL_ACE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.AERIAL_ACE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
console.log("===to new turn==="); console.log("===to new turn===");
await game.toNextTurn(); await game.toNextTurn();
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;

View File

@ -1,10 +1,10 @@
import { BattleStat } from "#app/data/battle-stat"; import { BattleStat } from "#app/data/battle-stat";
import GameManager from "#test/utils/gameManager"; import { CommandPhase } from "#app/phases/command-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { CommandPhase } from "#app/phases/command-phase.js";
describe("Abilities - Intrepid Sword", () => { describe("Abilities - Intrepid Sword", () => {

View File

@ -1,18 +1,17 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Type } from "#app/data/type.js"; import { Type } from "#app/data/type";
import { Weather, WeatherType } from "#app/data/weather.js"; import { Weather, WeatherType } from "#app/data/weather";
import { PlayerPokemon } from "#app/field/pokemon.js"; import { PlayerPokemon } from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -49,7 +48,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
@ -67,12 +66,12 @@ describe("Abilities - Libero", () => {
let leadPokemon = game.scene.getPlayerPokemon()!; let leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 0, Moves.AGILITY)); game.move.select(Moves.AGILITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.LIBERO)).toHaveLength(1); expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.LIBERO)).toHaveLength(1);
@ -89,7 +88,7 @@ describe("Abilities - Libero", () => {
leadPokemon = game.scene.getPlayerPokemon()!; leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
@ -108,7 +107,7 @@ describe("Abilities - Libero", () => {
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.scene.arena.weather = new Weather(WeatherType.SUNNY); game.scene.arena.weather = new Weather(WeatherType.SUNNY);
game.doAttack(getMovePosition(game.scene, 0, Moves.WEATHER_BALL)); game.move.select(Moves.WEATHER_BALL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO);
@ -131,7 +130,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO);
@ -154,7 +153,7 @@ describe("Abilities - Libero", () => {
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.scene.arena.biomeType = Biome.MOUNTAIN; game.scene.arena.biomeType = Biome.MOUNTAIN;
game.doAttack(getMovePosition(game.scene, 0, Moves.NATURE_POWER)); game.move.select(Moves.NATURE_POWER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH);
@ -172,7 +171,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.DIG)); game.move.select(Moves.DIG);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG);
@ -191,7 +190,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.move.forceMiss(); await game.move.forceMiss();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -213,7 +212,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE);
@ -232,7 +231,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE);
@ -251,7 +250,7 @@ describe("Abilities - Libero", () => {
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
leadPokemon.summonData.types = [allMoves[Moves.SPLASH].defaultType]; leadPokemon.summonData.types = [allMoves[Moves.SPLASH].defaultType];
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -271,7 +270,7 @@ describe("Abilities - Libero", () => {
vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true); vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -289,7 +288,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE)); game.move.select(Moves.STRUGGLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -307,7 +306,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.BURN_UP)); game.move.select(Moves.BURN_UP);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -326,7 +325,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TRICK_OR_TREAT)); game.move.select(Moves.TRICK_OR_TREAT);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT);
@ -344,7 +343,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE)); game.move.select(Moves.CURSE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE);

View File

@ -1,17 +1,16 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { Species } from "#enums/species";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { Moves } from "#enums/moves";
import { ArenaTagType } from "#enums/arena-tag-type";
import { ArenaTagSide, getArenaTag } from "#app/data/arena-tag"; import { ArenaTagSide, getArenaTag } from "#app/data/arena-tag";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities";
import { WeatherType } from "#app/data/weather.js";
import { StatusEffect, getStatusEffectCatchRateMultiplier } from "#app/data/status-effect"; import { StatusEffect, getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
import { WeatherType } from "#app/data/weather";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
const TIMEOUT = 20 * 1000; // 20 sec timeout const TIMEOUT = 20 * 1000; // 20 sec timeout
@ -58,7 +57,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).toBeDefined(); expect(enemyPokemon).toBeDefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -82,7 +81,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -99,14 +98,14 @@ describe("Abilities - Magic Guard", () => {
it( it(
"ability effect should not persist when the ability is replaced", "ability effect should not persist when the ability is replaced",
async () => { async () => {
game.override.enemyMoveset([Moves.WORRY_SEED,Moves.WORRY_SEED,Moves.WORRY_SEED,Moves.WORRY_SEED]); game.override.enemyMoveset([Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED, Moves.WORRY_SEED]);
game.override.statusEffect(StatusEffect.POISON); game.override.statusEffect(StatusEffect.POISON);
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -126,7 +125,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -150,7 +149,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -180,7 +179,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -206,7 +205,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -233,7 +232,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE)); game.move.select(Moves.CURSE);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -257,7 +256,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.HIGH_JUMP_KICK)); game.move.select(Moves.HIGH_JUMP_KICK);
await game.move.forceMiss(); await game.move.forceMiss();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -276,7 +275,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.TAKE_DOWN)); game.move.select(Moves.TAKE_DOWN);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -294,7 +293,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE)); game.move.select(Moves.STRUGGLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -313,7 +312,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.STEEL_BEAM)); game.move.select(Moves.STEEL_BEAM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -329,7 +328,7 @@ describe("Abilities - Magic Guard", () => {
it("Magic Guard does not prevent self-damage from confusion", async () => { it("Magic Guard does not prevent self-damage from confusion", async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); game.move.select(Moves.CHARM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
}); });
@ -341,7 +340,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -353,7 +352,7 @@ describe("Abilities - Magic Guard", () => {
}, TIMEOUT }, TIMEOUT
); );
it("Magic Guard prevents damage from abilities with PostTurnHurtIfSleepingAbAttr", async() => { it("Magic Guard prevents damage from abilities with PostTurnHurtIfSleepingAbAttr", async () => {
//Tests the ability Bad Dreams //Tests the ability Bad Dreams
game.override.statusEffect(StatusEffect.SLEEP); game.override.statusEffect(StatusEffect.SLEEP);
//enemy pokemon is given Spore just in case player pokemon somehow awakens during test //enemy pokemon is given Spore just in case player pokemon somehow awakens during test
@ -364,7 +363,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -378,7 +377,7 @@ describe("Abilities - Magic Guard", () => {
}, TIMEOUT }, TIMEOUT
); );
it("Magic Guard prevents damage from abilities with PostFaintContactDamageAbAttr", async() => { it("Magic Guard prevents damage from abilities with PostFaintContactDamageAbAttr", async () => {
//Tests the abilities Innards Out/Aftermath //Tests the abilities Innards Out/Aftermath
game.override.moveset([Moves.TACKLE]); game.override.moveset([Moves.TACKLE]);
game.override.enemyAbility(Abilities.AFTERMATH); game.override.enemyAbility(Abilities.AFTERMATH);
@ -390,7 +389,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.hp = 1; enemyPokemon.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
/** /**
@ -403,7 +402,7 @@ describe("Abilities - Magic Guard", () => {
}, TIMEOUT }, TIMEOUT
); );
it("Magic Guard prevents damage from abilities with PostDefendContactDamageAbAttr", async() => { it("Magic Guard prevents damage from abilities with PostDefendContactDamageAbAttr", async () => {
//Tests the abilities Iron Barbs/Rough Skin //Tests the abilities Iron Barbs/Rough Skin
game.override.moveset([Moves.TACKLE]); game.override.moveset([Moves.TACKLE]);
game.override.enemyAbility(Abilities.IRON_BARBS); game.override.enemyAbility(Abilities.IRON_BARBS);
@ -414,7 +413,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
/** /**
@ -427,7 +426,7 @@ describe("Abilities - Magic Guard", () => {
}, TIMEOUT }, TIMEOUT
); );
it("Magic Guard prevents damage from abilities with ReverseDrainAbAttr", async() => { it("Magic Guard prevents damage from abilities with ReverseDrainAbAttr", async () => {
//Tests the ability Liquid Ooze //Tests the ability Liquid Ooze
game.override.moveset([Moves.ABSORB]); game.override.moveset([Moves.ABSORB]);
game.override.enemyAbility(Abilities.LIQUID_OOZE); game.override.enemyAbility(Abilities.LIQUID_OOZE);
@ -438,7 +437,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.ABSORB)); game.move.select(Moves.ABSORB);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
/** /**
@ -451,14 +450,14 @@ describe("Abilities - Magic Guard", () => {
}, TIMEOUT }, TIMEOUT
); );
it("Magic Guard prevents HP loss from abilities with PostWeatherLapseDamageAbAttr", async() => { it("Magic Guard prevents HP loss from abilities with PostWeatherLapseDamageAbAttr", async () => {
//Tests the abilities Solar Power/Dry Skin //Tests the abilities Solar Power/Dry Skin
game.override.passiveAbility(Abilities.SOLAR_POWER); game.override.passiveAbility(Abilities.SOLAR_POWER);
game.override.weather(WeatherType.SUNNY); game.override.weather(WeatherType.SUNNY);
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
/** /**

View File

@ -1,17 +1,13 @@
import { BattleStat } from "#app/data/battle-stat"; import { BattleStat } from "#app/data/battle-stat";
import { Stat } from "#app/data/pokemon-stat"; import { Stat } from "#app/data/pokemon-stat";
import GameManager from "#test/utils/gameManager"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { VictoryPhase } from "#app/phases/victory-phase";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { CommandPhase } from "#app/phases/command-phase.js";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
import { VictoryPhase } from "#app/phases/victory-phase.js";
describe("Abilities - Moxie", () => { describe("Abilities - Moxie", () => {
@ -37,10 +33,10 @@ describe("Abilities - Moxie", () => {
game.override.ability(Abilities.MOXIE); game.override.ability(Abilities.MOXIE);
game.override.startingLevel(2000); game.override.startingLevel(2000);
game.override.moveset([moveToUse]); game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
}); });
it("MOXIE", async() => { it("MOXIE", async () => {
const moveToUse = Moves.AERIAL_ACE; const moveToUse = Moves.AERIAL_ACE;
await game.startBattle([ await game.startBattle([
Species.MIGHTYENA, Species.MIGHTYENA,
@ -50,13 +46,7 @@ describe("Abilities - Moxie", () => {
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[Stat.ATK]).toBe(0); expect(battleStatsPokemon[Stat.ATK]).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase);
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats; battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[BattleStat.ATK]).toBe(1); expect(battleStatsPokemon[BattleStat.ATK]).toBe(1);

View File

@ -1,11 +1,10 @@
import { MovePhase } from "#app/phases/move-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities";
import { BattleStat } from "#app/data/battle-stat"; import { BattleStat } from "#app/data/battle-stat";
import { MovePhase } from "#app/phases/move-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -42,14 +41,14 @@ describe("Abilities - Mycelium Might", () => {
* https://www.smogon.com/forums/threads/scarlet-violet-battle-mechanics-research.3709545/page-24 * https://www.smogon.com/forums/threads/scarlet-violet-battle-mechanics-research.3709545/page-24
**/ **/
it("If a Pokemon with Mycelium Might uses a status move, it will always move last but the status move will ignore protective abilities", async() => { it("will move last in its priority bracket and ignore protective abilities", async () => {
await game.startBattle([ Species.REGIELEKI ]); await game.startBattle([Species.REGIELEKI]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyPokemon = game.scene.getEnemyPokemon(); const enemyPokemon = game.scene.getEnemyPokemon();
const enemyIndex = enemyPokemon?.getBattlerIndex(); const enemyIndex = enemyPokemon?.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); game.move.select(Moves.BABY_DOLL_EYES);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
// The opponent Pokemon (without Mycelium Might) goes first despite having lower speed than the player Pokemon. // The opponent Pokemon (without Mycelium Might) goes first despite having lower speed than the player Pokemon.
@ -64,15 +63,15 @@ describe("Abilities - Mycelium Might", () => {
expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1); expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1);
}, 20000); }, 20000);
it("Pokemon with Mycelium Might will go first if a status move that is in a higher priority bracket than the opponent's move is used", async() => { it("will still go first if a status move that is in a higher priority bracket than the opponent's move is used", async () => {
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle([ Species.REGIELEKI ]); await game.startBattle([Species.REGIELEKI]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyPokemon = game.scene.getEnemyPokemon(); const enemyPokemon = game.scene.getEnemyPokemon();
const enemyIndex = enemyPokemon?.getBattlerIndex(); const enemyIndex = enemyPokemon?.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); game.move.select(Moves.BABY_DOLL_EYES);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
// The player Pokemon (with M.M.) goes first because its move is still within a higher priority bracket than its opponent. // The player Pokemon (with M.M.) goes first because its move is still within a higher priority bracket than its opponent.
@ -86,13 +85,13 @@ describe("Abilities - Mycelium Might", () => {
expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1); expect(enemyPokemon?.summonData.battleStats[BattleStat.ATK]).toBe(-1);
}, 20000); }, 20000);
it("Order is established normally if the Pokemon uses a non-status move", async() => { it("will not affect non-status moves", async () => {
await game.startBattle([ Species.REGIELEKI ]); await game.startBattle([Species.REGIELEKI]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); game.move.select(Moves.QUICK_ATTACK);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
// The player Pokemon (with M.M.) goes first because it has a higher speed and did not use a status move. // The player Pokemon (with M.M.) goes first because it has a higher speed and did not use a status move.

View File

@ -1,22 +1,21 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { StatusEffect } from "#app/data/status-effect.js"; import { StatusEffect } from "#app/data/status-effect";
import { Type } from "#app/data/type.js"; import { Type } from "#app/data/type";
import { BattlerTagType } from "#app/enums/battler-tag-type.js"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { BerryPhase } from "#app/phases/berry-phase";
import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { toDmgValue } from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { BerryPhase } from "#app/phases/berry-phase.js";
import { CommandPhase } from "#app/phases/command-phase.js";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { toDmgValue } from "#app/utils";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -61,7 +60,7 @@ describe("Abilities - Parental Bond", () => {
let enemyStartingHp = enemyPokemon.hp; let enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -92,7 +91,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.POWER_UP_PUNCH)); game.move.select(Moves.POWER_UP_PUNCH);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -114,7 +113,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.BABY_DOLL_EYES)); game.move.select(Moves.BABY_DOLL_EYES);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
expect(enemyPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-1); expect(enemyPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-1);
@ -134,7 +133,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.DOUBLE_HIT)); game.move.select(Moves.DOUBLE_HIT);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -156,7 +155,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SELF_DESTRUCT)); game.move.select(Moves.SELF_DESTRUCT);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
@ -177,7 +176,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.ROLLOUT)); game.move.select(Moves.ROLLOUT);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
@ -201,7 +200,7 @@ describe("Abilities - Parental Bond", () => {
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
expect(enemyPokemon.hp).toBe(enemyStartingHp - 80); expect(enemyPokemon.hp).toBe(enemyStartingHp - 80);
@ -212,7 +211,7 @@ describe("Abilities - Parental Bond", () => {
"ability should not apply multiplier to counter moves", "ability should not apply multiplier to counter moves",
async () => { async () => {
game.override.moveset([Moves.COUNTER]); game.override.moveset([Moves.COUNTER]);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle([Species.CHARIZARD]); await game.startBattle([Species.CHARIZARD]);
@ -225,14 +224,14 @@ describe("Abilities - Parental Bond", () => {
const playerStartingHp = leadPokemon.hp; const playerStartingHp = leadPokemon.hp;
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.COUNTER)); game.move.select(Moves.COUNTER);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
const playerDamage = playerStartingHp - leadPokemon.hp; const playerDamage = playerStartingHp - leadPokemon.hp;
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
expect(enemyPokemon.hp).toBe(enemyStartingHp - 4*playerDamage); expect(enemyPokemon.hp).toBe(enemyStartingHp - 4 * playerDamage);
}, TIMEOUT }, TIMEOUT
); );
@ -252,10 +251,10 @@ describe("Abilities - Parental Bond", () => {
expect(enemyPokemon.length).toBe(2); expect(enemyPokemon.length).toBe(2);
enemyPokemon.forEach(p => expect(p).not.toBe(undefined)); enemyPokemon.forEach(p => expect(p).not.toBe(undefined));
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.EARTHQUAKE)); game.move.select(Moves.EARTHQUAKE, 1);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
playerPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1)); playerPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1));
@ -275,7 +274,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
@ -295,7 +294,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.MIND_BLOWN)); game.move.select(Moves.MIND_BLOWN);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
@ -304,7 +303,7 @@ describe("Abilities - Parental Bond", () => {
// This test will time out if the user faints // This test will time out if the user faints
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
expect(leadPokemon.hp).toBe(toDmgValue(leadPokemon.getMaxHp()/2)); expect(leadPokemon.hp).toBe(toDmgValue(leadPokemon.getMaxHp() / 2));
}, TIMEOUT }, TIMEOUT
); );
@ -321,7 +320,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.BURN_UP)); game.move.select(Moves.BURN_UP);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -339,7 +338,7 @@ describe("Abilities - Parental Bond", () => {
"Moves boosted by this ability and Multi-Lens should strike 4 times", "Moves boosted by this ability and Multi-Lens should strike 4 times",
async () => { async () => {
game.override.moveset([Moves.TACKLE]); game.override.moveset([Moves.TACKLE]);
game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([Species.CHARIZARD]); await game.startBattle([Species.CHARIZARD]);
@ -349,7 +348,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -361,7 +360,7 @@ describe("Abilities - Parental Bond", () => {
"Super Fang boosted by this ability and Multi-Lens should strike twice", "Super Fang boosted by this ability and Multi-Lens should strike twice",
async () => { async () => {
game.override.moveset([Moves.SUPER_FANG]); game.override.moveset([Moves.SUPER_FANG]);
game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([Species.CHARIZARD]); await game.startBattle([Species.CHARIZARD]);
@ -373,7 +372,7 @@ describe("Abilities - Parental Bond", () => {
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.SUPER_FANG)); game.move.select(Moves.SUPER_FANG);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -390,7 +389,7 @@ describe("Abilities - Parental Bond", () => {
"Seismic Toss boosted by this ability and Multi-Lens should strike twice", "Seismic Toss boosted by this ability and Multi-Lens should strike twice",
async () => { async () => {
game.override.moveset([Moves.SEISMIC_TOSS]); game.override.moveset([Moves.SEISMIC_TOSS]);
game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([Species.CHARIZARD]); await game.startBattle([Species.CHARIZARD]);
@ -402,7 +401,7 @@ describe("Abilities - Parental Bond", () => {
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.SEISMIC_TOSS)); game.move.select(Moves.SEISMIC_TOSS);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -428,7 +427,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.HYPER_BEAM)); game.move.select(Moves.HYPER_BEAM);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -456,7 +455,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.ANCHOR_SHOT)); game.move.select(Moves.ANCHOR_SHOT);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -486,7 +485,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SMACK_DOWN)); game.move.select(Moves.SMACK_DOWN);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -513,7 +512,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.U_TURN)); game.move.select(Moves.U_TURN);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
@ -537,7 +536,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.WAKE_UP_SLAP)); game.move.select(Moves.WAKE_UP_SLAP);
await game.move.forceHit(); await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
@ -555,7 +554,7 @@ describe("Abilities - Parental Bond", () => {
"ability should not cause user to hit into King's Shield more than once", "ability should not cause user to hit into King's Shield more than once",
async () => { async () => {
game.override.moveset([Moves.TACKLE]); game.override.moveset([Moves.TACKLE]);
game.override.enemyMoveset([Moves.KINGS_SHIELD,Moves.KINGS_SHIELD,Moves.KINGS_SHIELD,Moves.KINGS_SHIELD]); game.override.enemyMoveset([Moves.KINGS_SHIELD, Moves.KINGS_SHIELD, Moves.KINGS_SHIELD, Moves.KINGS_SHIELD]);
await game.startBattle([Species.CHARIZARD]); await game.startBattle([Species.CHARIZARD]);
@ -565,7 +564,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -587,7 +586,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined); expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.WATER_GUN)); game.move.select(Moves.WATER_GUN);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -600,7 +599,7 @@ describe("Abilities - Parental Bond", () => {
async () => { async () => {
game.override.battleType("double"); game.override.battleType("double");
game.override.moveset([Moves.EARTHQUAKE, Moves.SPLASH]); game.override.moveset([Moves.EARTHQUAKE, Moves.SPLASH]);
game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([Species.CHARIZARD, Species.PIDGEOT]); await game.startBattle([Species.CHARIZARD, Species.PIDGEOT]);
@ -614,10 +613,10 @@ describe("Abilities - Parental Bond", () => {
const enemyStartingHp = enemyPokemon.map(p => p.hp); const enemyStartingHp = enemyPokemon.map(p => p.hp);
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -626,7 +625,7 @@ describe("Abilities - Parental Bond", () => {
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(2*enemyFirstHitDamage[i])); enemyPokemon.forEach((p, i) => expect(enemyStartingHp[i] - p.hp).toBe(2 * enemyFirstHitDamage[i]));
}, TIMEOUT }, TIMEOUT
); );

View File

@ -1,15 +1,14 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { BattlerIndex } from "#app/battle";
import Phaser from "phaser"; import { StatusEffect } from "#app/data/status-effect";
import GameManager from "#test/utils/gameManager"; import { Abilities } from "#app/enums/abilities";
import { Species } from "#enums/species"; import { CommandPhase } from "#app/phases/command-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { Species } from "#enums/species";
import { StatusEffect } from "#app/data/status-effect.js"; import GameManager from "#test/utils/gameManager";
import { allAbilities } from "#app/data/ability.js"; import Phaser from "phaser";
import { Abilities } from "#app/enums/abilities.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BattlerIndex } from "#app/battle.js"; import { SPLASH_ONLY } from "../utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Pastel Veil", () => { describe("Abilities - Pastel Veil", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,50 +26,49 @@ describe("Abilities - Pastel Veil", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override.battleType("double"); game.override
game.override.moveset([Moves.SPLASH]); .battleType("double")
game.override.enemyAbility(Abilities.BALL_FETCH); .moveset([Moves.TOXIC_THREAD, Moves.SPLASH])
game.override.enemySpecies(Species.MAGIKARP); .enemyAbility(Abilities.BALL_FETCH)
game.override.enemyMoveset([Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD]); .enemySpecies(Species.SUNKERN)
.enemyMoveset(SPLASH_ONLY);
}); });
it("prevents the user and its allies from being afflicted by poison", async () => { it("prevents the user and its allies from being afflicted by poison", async () => {
await game.startBattle([Species.GALAR_PONYTA, Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP, Species.GALAR_PONYTA]);
const ponyta = game.scene.getPlayerField()[0]; const ponyta = game.scene.getPlayerField()[1];
const magikarp = game.scene.getPlayerField()[0];
vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]); ponyta.abilityIndex = 1;
expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true); expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.TOXIC_THREAD, 1, BattlerIndex.PLAYER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); expect(magikarp.status?.effect).toBeUndefined();
}); });
it("it heals the poisoned status condition of allies if user is sent out into battle", async () => { it("it heals the poisoned status condition of allies if user is sent out into battle", async () => {
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.GALAR_PONYTA]); await game.startBattle([Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA]);
const ponyta = game.scene.getParty().find(p => p.species.speciesId === Species.GALAR_PONYTA)!; const ponyta = game.scene.getParty()[2];
const magikarp = game.scene.getPlayerField()[0];
vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]); ponyta.abilityIndex = 1;
expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true); expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.TOXIC_THREAD, 1, BattlerIndex.PLAYER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.getPlayerField().some(p => p.status?.effect === StatusEffect.POISON)).toBe(true); expect(magikarp.status?.effect).toBe(StatusEffect.POISON);
const poisonedMon = game.scene.getPlayerField().find(p => p.status?.effect === StatusEffect.POISON);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, (poisonedMon!.getBattlerIndex() as BattlerIndex.PLAYER | BattlerIndex.PLAYER_2), Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doSwitchPokemon(2); game.doSwitchPokemon(2);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); expect(magikarp.status?.effect).toBeUndefined();
}); });
}); });

View File

@ -1,11 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect.js"; import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -53,7 +52,7 @@ describe("Abilities - POWER CONSTRUCT", () => {
zygarde!.status = new Status(StatusEffect.FAINT); zygarde!.status = new Status(StatusEffect.FAINT);
expect(zygarde!.isFainted()).toBe(true); expect(zygarde!.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();

View File

@ -1,14 +1,13 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Power Spot", () => { describe("Abilities - Power Spot", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -42,8 +41,8 @@ describe("Abilities - Power Spot", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]); await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DAZZLING_GLEAM)); game.move.select(Moves.DAZZLING_GLEAM);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier);
@ -56,8 +55,8 @@ describe("Abilities - Power Spot", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]); await game.startBattle([Species.REGIELEKI, Species.STONJOURNER]);
game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); game.move.select(Moves.BREAKING_SWIPE);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower * powerSpotMultiplier);
@ -70,8 +69,8 @@ describe("Abilities - Power Spot", () => {
vi.spyOn(moveToCheck, "calculateBattlePower"); vi.spyOn(moveToCheck, "calculateBattlePower");
await game.startBattle([Species.STONJOURNER, Species.REGIELEKI]); await game.startBattle([Species.STONJOURNER, Species.REGIELEKI]);
game.doAttack(getMovePosition(game.scene, 0, Moves.BREAKING_SWIPE)); game.move.select(Moves.BREAKING_SWIPE);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower); expect(moveToCheck.calculateBattlePower).toHaveReturnedWith(basePower);

View File

@ -1,18 +1,17 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Type } from "#app/data/type.js"; import { Type } from "#app/data/type";
import { Weather, WeatherType } from "#app/data/weather.js"; import { Weather, WeatherType } from "#app/data/weather";
import { PlayerPokemon } from "#app/field/pokemon.js"; import { PlayerPokemon } from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome"; import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -49,7 +48,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
@ -67,12 +66,12 @@ describe("Abilities - Protean", () => {
let leadPokemon = game.scene.getPlayerPokemon()!; let leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 0, Moves.AGILITY)); game.move.select(Moves.AGILITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.PROTEAN)).toHaveLength(1); expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.PROTEAN)).toHaveLength(1);
@ -89,7 +88,7 @@ describe("Abilities - Protean", () => {
leadPokemon = game.scene.getPlayerPokemon()!; leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
@ -108,7 +107,7 @@ describe("Abilities - Protean", () => {
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.scene.arena.weather = new Weather(WeatherType.SUNNY); game.scene.arena.weather = new Weather(WeatherType.SUNNY);
game.doAttack(getMovePosition(game.scene, 0, Moves.WEATHER_BALL)); game.move.select(Moves.WEATHER_BALL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN);
@ -131,7 +130,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN); expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.PROTEAN);
@ -154,7 +153,7 @@ describe("Abilities - Protean", () => {
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.scene.arena.biomeType = Biome.MOUNTAIN; game.scene.arena.biomeType = Biome.MOUNTAIN;
game.doAttack(getMovePosition(game.scene, 0, Moves.NATURE_POWER)); game.move.select(Moves.NATURE_POWER);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH);
@ -172,7 +171,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.DIG)); game.move.select(Moves.DIG);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG);
@ -191,7 +190,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.move.forceMiss(); await game.move.forceMiss();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -213,7 +212,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE);
@ -232,7 +231,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE);
@ -251,7 +250,7 @@ describe("Abilities - Protean", () => {
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
leadPokemon.summonData.types = [allMoves[Moves.SPLASH].defaultType]; leadPokemon.summonData.types = [allMoves[Moves.SPLASH].defaultType];
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN);
@ -271,7 +270,7 @@ describe("Abilities - Protean", () => {
vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true); vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN);
@ -289,7 +288,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE)); game.move.select(Moves.STRUGGLE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN);
@ -307,7 +306,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.BURN_UP)); game.move.select(Moves.BURN_UP);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN); expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.PROTEAN);
@ -326,7 +325,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TRICK_OR_TREAT)); game.move.select(Moves.TRICK_OR_TREAT);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT);
@ -344,7 +343,7 @@ describe("Abilities - Protean", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE)); game.move.select(Moves.CURSE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE); testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.CURSE);

View File

@ -1,12 +1,11 @@
import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability"; import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability";
import GameManager from "#test/utils/gameManager"; import { FaintPhase } from "#app/phases/faint-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { FaintPhase } from "#app/phases/faint-phase.js";
describe("Abilities - Quick Draw", () => { describe("Abilities - Quick Draw", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -47,7 +46,7 @@ describe("Abilities - Quick Draw", () => {
pokemon.hp = 1; pokemon.hp = 1;
enemy.hp = 1; enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(FaintPhase, false); await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(false); expect(pokemon.isFainted()).toBe(false);
@ -67,7 +66,7 @@ describe("Abilities - Quick Draw", () => {
pokemon.hp = 1; pokemon.hp = 1;
enemy.hp = 1; enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TAIL_WHIP)); game.move.select(Moves.TAIL_WHIP);
await game.phaseInterceptor.to(FaintPhase, false); await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(true); expect(pokemon.isFainted()).toBe(true);
@ -87,7 +86,7 @@ describe("Abilities - Quick Draw", () => {
pokemon.hp = 1; pokemon.hp = 1;
enemy.hp = 1; enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(FaintPhase, false); await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(true); expect(pokemon.isFainted()).toBe(true);

View File

@ -1,11 +1,10 @@
import GameManager from "#test/utils/gameManager"; import { WeatherType } from "#app/enums/weather-type";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { WeatherType } from "#app/enums/weather-type.js";
describe("Abilities - Sand Spit", () => { describe("Abilities - Sand Spit", () => {
@ -35,21 +34,21 @@ describe("Abilities - Sand Spit", () => {
game.override.moveset([Moves.SPLASH, Moves.COIL]); game.override.moveset([Moves.SPLASH, Moves.COIL]);
}); });
it("should trigger when hit with damaging move", async() => { it("should trigger when hit with damaging move", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.TACKLE)); game.override.enemyMoveset(Array(4).fill(Moves.TACKLE));
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SANDSTORM); expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SANDSTORM);
}, 20000); }, 20000);
it("should not trigger when targetted with status moves", async() => { it("should not trigger when targetted with status moves", async () => {
game.override.enemyMoveset(Array(4).fill(Moves.GROWL)); game.override.enemyMoveset(Array(4).fill(Moves.GROWL));
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.COIL)); game.move.select(Moves.COIL);
await game.toNextTurn(); await game.toNextTurn();
expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SANDSTORM); expect(game.scene.arena.weather?.weatherType).not.toBe(WeatherType.SANDSTORM);

View File

@ -1,16 +1,15 @@
import { BattleStatMultiplierAbAttr, allAbilities } from "#app/data/ability.js"; import { BattleStatMultiplierAbAttr, allAbilities } from "#app/data/ability";
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { WeatherType } from "#app/data/weather.js"; import { WeatherType } from "#app/data/weather";
import { CommandPhase } from "#app/phases/command-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -64,11 +63,11 @@ describe("Abilities - Sand Veil", () => {
expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true); expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true);
expect(leadPokemon[1].hasAbility(Abilities.SAND_VEIL)).toBe(false); expect(leadPokemon[1].hasAbility(Abilities.SAND_VEIL)).toBe(false);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);

View File

@ -1,15 +1,14 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { TerrainType } from "#app/data/terrain.js"; import { TerrainType } from "#app/data/terrain";
import GameManager from "#test/utils/gameManager"; import { MoveEndPhase } from "#app/phases/move-end-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
// See also: TypeImmunityAbAttr // See also: TypeImmunityAbAttr
describe("Abilities - Sap Sipper", () => { describe("Abilities - Sap Sipper", () => {
@ -32,7 +31,7 @@ describe("Abilities - Sap Sipper", () => {
game.override.disableCrits(); game.override.disableCrits();
}); });
it("raise attack 1 level and block effects when activated against a grass attack", async() => { it("raise attack 1 level and block effects when activated against a grass attack", async () => {
const moveToUse = Moves.LEAFAGE; const moveToUse = Moves.LEAFAGE;
const enemyAbility = Abilities.SAP_SIPPER; const enemyAbility = Abilities.SAP_SIPPER;
@ -45,7 +44,7 @@ describe("Abilities - Sap Sipper", () => {
const startingOppHp = game.scene.currentBattle.enemyParty[0].hp; const startingOppHp = game.scene.currentBattle.enemyParty[0].hp;
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -53,7 +52,7 @@ describe("Abilities - Sap Sipper", () => {
expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1); expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1);
}); });
it("raise attack 1 level and block effects when activated against a grass status move", async() => { it("raise attack 1 level and block effects when activated against a grass status move", async () => {
const moveToUse = Moves.SPORE; const moveToUse = Moves.SPORE;
const enemyAbility = Abilities.SAP_SIPPER; const enemyAbility = Abilities.SAP_SIPPER;
@ -64,7 +63,7 @@ describe("Abilities - Sap Sipper", () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -72,7 +71,7 @@ describe("Abilities - Sap Sipper", () => {
expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1); expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1);
}); });
it("do not activate against status moves that target the field", async() => { it("do not activate against status moves that target the field", async () => {
const moveToUse = Moves.GRASSY_TERRAIN; const moveToUse = Moves.GRASSY_TERRAIN;
const enemyAbility = Abilities.SAP_SIPPER; const enemyAbility = Abilities.SAP_SIPPER;
@ -83,7 +82,7 @@ describe("Abilities - Sap Sipper", () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -92,7 +91,7 @@ describe("Abilities - Sap Sipper", () => {
expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(0); expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(0);
}); });
it("activate once against multi-hit grass attacks", async() => { it("activate once against multi-hit grass attacks", async () => {
const moveToUse = Moves.BULLET_SEED; const moveToUse = Moves.BULLET_SEED;
const enemyAbility = Abilities.SAP_SIPPER; const enemyAbility = Abilities.SAP_SIPPER;
@ -105,7 +104,7 @@ describe("Abilities - Sap Sipper", () => {
const startingOppHp = game.scene.currentBattle.enemyParty[0].hp; const startingOppHp = game.scene.currentBattle.enemyParty[0].hp;
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -113,7 +112,7 @@ describe("Abilities - Sap Sipper", () => {
expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1); expect(game.scene.getEnemyParty()[0].summonData.battleStats[BattleStat.ATK]).toBe(1);
}); });
it("do not activate against status moves that target the user", async() => { it("do not activate against status moves that target the user", async () => {
const moveToUse = Moves.SPIKY_SHIELD; const moveToUse = Moves.SPIKY_SHIELD;
const ability = Abilities.SAP_SIPPER; const ability = Abilities.SAP_SIPPER;
@ -125,7 +124,7 @@ describe("Abilities - Sap Sipper", () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
@ -139,7 +138,7 @@ describe("Abilities - Sap Sipper", () => {
// TODO Add METRONOME outcome override // TODO Add METRONOME outcome override
// To run this testcase, manually modify the METRONOME move to always give SAP_SIPPER, then uncomment // To run this testcase, manually modify the METRONOME move to always give SAP_SIPPER, then uncomment
it.todo("activate once against multi-hit grass attacks (metronome)", async() => { it.todo("activate once against multi-hit grass attacks (metronome)", async () => {
const moveToUse = Moves.METRONOME; const moveToUse = Moves.METRONOME;
const enemyAbility = Abilities.SAP_SIPPER; const enemyAbility = Abilities.SAP_SIPPER;
@ -152,7 +151,7 @@ describe("Abilities - Sap Sipper", () => {
const startingOppHp = game.scene.currentBattle.enemyParty[0].hp; const startingOppHp = game.scene.currentBattle.enemyParty[0].hp;
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);

View File

@ -1,11 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect.js"; import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -53,7 +52,7 @@ describe("Abilities - SCHOOLING", () => {
wishiwashi.status = new Status(StatusEffect.FAINT); wishiwashi.status = new Status(StatusEffect.FAINT);
expect(wishiwashi.isFainted()).toBe(true); expect(wishiwashi.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();

View File

@ -1,13 +1,12 @@
import { ArenaTagType } from "#app/enums/arena-tag-type.js"; import { ArenaTagType } from "#app/enums/arena-tag-type";
import GameManager from "#test/utils/gameManager"; import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { PostSummonPhase } from "#app/phases/post-summon-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Screen Cleaner", () => { describe("Abilities - Screen Cleaner", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -36,7 +35,7 @@ describe("Abilities - Screen Cleaner", () => {
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.HAIL)); game.move.select(Moves.HAIL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.AURORA_VEIL)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.AURORA_VEIL)).toBeDefined();
@ -53,7 +52,7 @@ describe("Abilities - Screen Cleaner", () => {
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.LIGHT_SCREEN)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.LIGHT_SCREEN)).toBeDefined();
@ -70,7 +69,7 @@ describe("Abilities - Screen Cleaner", () => {
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.REFLECT)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.REFLECT)).toBeDefined();

View File

@ -1,18 +1,14 @@
import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability"; import { applyAbAttrs, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
import { Stat } from "#app/data/pokemon-stat"; import { Stat } from "#app/data/pokemon-stat";
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BattlerIndex } from "#app/battle.js";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
describe("Abilities - Serene Grace", () => { describe("Abilities - Serene Grace", () => {
@ -36,10 +32,10 @@ describe("Abilities - Serene Grace", () => {
game.override.enemySpecies(Species.ONIX); game.override.enemySpecies(Species.ONIX);
game.override.startingLevel(100); game.override.startingLevel(100);
game.override.moveset(movesToUse); game.override.moveset(movesToUse);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
}); });
it("Move chance without Serene Grace", async() => { it("Move chance without Serene Grace", async () => {
const moveToUse = Moves.AIR_SLASH; const moveToUse = Moves.AIR_SLASH;
await game.startBattle([ await game.startBattle([
Species.PIDGEOT Species.PIDGEOT
@ -49,13 +45,7 @@ describe("Abilities - Serene Grace", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -72,7 +62,7 @@ describe("Abilities - Serene Grace", () => {
}, 20000); }, 20000);
it("Move chance with Serene Grace", async() => { it("Move chance with Serene Grace", async () => {
const moveToUse = Moves.AIR_SLASH; const moveToUse = Moves.AIR_SLASH;
game.override.ability(Abilities.SERENE_GRACE); game.override.ability(Abilities.SERENE_GRACE);
await game.startBattle([ await game.startBattle([
@ -82,13 +72,7 @@ describe("Abilities - Serene Grace", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);

View File

@ -1,18 +1,14 @@
import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability"; import { applyAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, MoveEffectChanceMultiplierAbAttr, MovePowerBoostAbAttr, PostDefendTypeChangeAbAttr } from "#app/data/ability";
import { Stat } from "#app/data/pokemon-stat"; import { Stat } from "#app/data/pokemon-stat";
import { CommandPhase } from "#app/phases/command-phase.js"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BattlerIndex } from "#app/battle.js";
describe("Abilities - Sheer Force", () => { describe("Abilities - Sheer Force", () => {
@ -36,10 +32,10 @@ describe("Abilities - Sheer Force", () => {
game.override.enemySpecies(Species.ONIX); game.override.enemySpecies(Species.ONIX);
game.override.startingLevel(100); game.override.startingLevel(100);
game.override.moveset(movesToUse); game.override.moveset(movesToUse);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
}); });
it("Sheer Force", async() => { it("Sheer Force", async () => {
const moveToUse = Moves.AIR_SLASH; const moveToUse = Moves.AIR_SLASH;
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.startBattle([
@ -50,13 +46,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -73,12 +63,12 @@ describe("Abilities - Sheer Force", () => {
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, false, power); applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, false, power);
expect(chance.value).toBe(0); expect(chance.value).toBe(0);
expect(power.value).toBe(move.power * 5461/4096); expect(power.value).toBe(move.power * 5461 / 4096);
}, 20000); }, 20000);
it("Sheer Force with exceptions including binding moves", async() => { it("Sheer Force with exceptions including binding moves", async () => {
const moveToUse = Moves.BIND; const moveToUse = Moves.BIND;
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.startBattle([
@ -89,13 +79,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -117,7 +101,7 @@ describe("Abilities - Sheer Force", () => {
}, 20000); }, 20000);
it("Sheer Force with moves with no secondary effect", async() => { it("Sheer Force with moves with no secondary effect", async () => {
const moveToUse = Moves.TACKLE; const moveToUse = Moves.TACKLE;
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.startBattle([
@ -128,13 +112,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -156,10 +134,10 @@ describe("Abilities - Sheer Force", () => {
}, 20000); }, 20000);
it("Sheer Force Disabling Specific Abilities", async() => { it("Sheer Force Disabling Specific Abilities", async () => {
const moveToUse = Moves.CRUSH_CLAW; const moveToUse = Moves.CRUSH_CLAW;
game.override.enemyAbility(Abilities.COLOR_CHANGE); game.override.enemyAbility(Abilities.COLOR_CHANGE);
game.override.startingHeldItems([{name: "KINGS_ROCK", count: 1}]); game.override.startingHeldItems([{ name: "KINGS_ROCK", count: 1 }]);
game.override.ability(Abilities.SHEER_FORCE); game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([ await game.startBattle([
Species.PIDGEOT Species.PIDGEOT
@ -169,13 +147,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -196,7 +168,7 @@ describe("Abilities - Sheer Force", () => {
applyPostDefendAbAttrs(PostDefendTypeChangeAbAttr, target, user, move, target.apply(user, move)); applyPostDefendAbAttrs(PostDefendTypeChangeAbAttr, target, user, move, target.apply(user, move));
expect(chance.value).toBe(0); expect(chance.value).toBe(0);
expect(power.value).toBe(move.power * 5461/4096); expect(power.value).toBe(move.power * 5461 / 4096);
expect(target.getTypes().length).toBe(2); expect(target.getTypes().length).toBe(2);
expect(target.getTypes()[0]).toBe(opponentType); expect(target.getTypes()[0]).toBe(opponentType);

View File

@ -1,18 +1,14 @@
import { BattlerIndex } from "#app/battle";
import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability"; import { applyAbAttrs, applyPreDefendAbAttrs, IgnoreMoveEffectsAbAttr, MoveEffectChanceMultiplierAbAttr } from "#app/data/ability";
import { Stat } from "#app/data/pokemon-stat"; import { Stat } from "#app/data/pokemon-stat";
import { CommandPhase } from "#app/phases/command-phase.js"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BattlerIndex } from "#app/battle.js";
describe("Abilities - Shield Dust", () => { describe("Abilities - Shield Dust", () => {
@ -37,10 +33,10 @@ describe("Abilities - Shield Dust", () => {
game.override.enemyAbility(Abilities.SHIELD_DUST); game.override.enemyAbility(Abilities.SHIELD_DUST);
game.override.startingLevel(100); game.override.startingLevel(100);
game.override.moveset(movesToUse); game.override.moveset(movesToUse);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
}); });
it("Shield Dust", async() => { it("Shield Dust", async () => {
const moveToUse = Moves.AIR_SLASH; const moveToUse = Moves.AIR_SLASH;
await game.startBattle([ await game.startBattle([
Species.PIDGEOT Species.PIDGEOT
@ -50,13 +46,7 @@ describe("Abilities - Shield Dust", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000; game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);

View File

@ -1,11 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect.js"; import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -53,7 +52,7 @@ describe("Abilities - SHIELDS DOWN", () => {
minior.status = new Status(StatusEffect.FAINT); minior.status = new Status(StatusEffect.FAINT);
expect(minior.isFainted()).toBe(true); expect(minior.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();

View File

@ -1,11 +1,10 @@
import GameManager from "#test/utils/gameManager"; import { MovePhase } from "#app/phases/move-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { MovePhase } from "#app/phases/move-phase.js";
describe("Abilities - Stall", () => { describe("Abilities - Stall", () => {
@ -38,13 +37,13 @@ describe("Abilities - Stall", () => {
* https://bulbapedia.bulbagarden.net/wiki/Priority * https://bulbapedia.bulbagarden.net/wiki/Priority
**/ **/
it("Pokemon with Stall should move last in its priority bracket regardless of speed", async() => { it("Pokemon with Stall should move last in its priority bracket regardless of speed", async () => {
await game.startBattle([ Species.SHUCKLE ]); await game.startBattle([Species.SHUCKLE]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK)); game.move.select(Moves.QUICK_ATTACK);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
// The player Pokemon (without Stall) goes first despite having lower speed than the opponent. // The player Pokemon (without Stall) goes first despite having lower speed than the opponent.
@ -56,13 +55,13 @@ describe("Abilities - Stall", () => {
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex); expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(enemyIndex);
}, 20000); }, 20000);
it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async() => { it("Pokemon with Stall will go first if a move that is in a higher priority bracket than the opponent's move is used", async () => {
await game.startBattle([ Species.SHUCKLE ]); await game.startBattle([Species.SHUCKLE]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
// The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent. // The opponent Pokemon (with Stall) goes first because its move is still within a higher priority bracket than its opponent.
@ -74,14 +73,14 @@ describe("Abilities - Stall", () => {
expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex); expect((game.scene.getCurrentPhase() as MovePhase).pokemon.getBattlerIndex()).toBe(leadIndex);
}, 20000); }, 20000);
it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async() => { it("If both Pokemon have stall and use the same move, speed is used to determine who goes first.", async () => {
game.override.ability(Abilities.STALL); game.override.ability(Abilities.STALL);
await game.startBattle([ Species.SHUCKLE ]); await game.startBattle([Species.SHUCKLE]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex(); const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex(); const enemyIndex = game.scene.getEnemyPokemon()!.getBattlerIndex();
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
// The opponent Pokemon (with Stall) goes first because it has a higher speed. // The opponent Pokemon (with Stall) goes first because it has a higher speed.

View File

@ -1,15 +1,13 @@
import { allAbilities } from "#app/data/ability.js"; import { allAbilities } from "#app/data/ability";
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { SelectTargetPhase } from "#app/phases/select-target-phase.js";
describe("Abilities - Steely Spirit", () => { describe("Abilities - Steely Spirit", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -47,10 +45,8 @@ describe("Abilities - Steely Spirit", () => {
expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(true); expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, moveToCheck)); game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex());
await game.phaseInterceptor.to(SelectTargetPhase, false); game.move.select(Moves.SPLASH, 1);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * steelySpiritMultiplier); expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * steelySpiritMultiplier);
@ -66,12 +62,8 @@ describe("Abilities - Steely Spirit", () => {
expect(game.scene.getPlayerField().every(p => p.hasAbility(Abilities.STEELY_SPIRIT))).toBe(true); expect(game.scene.getPlayerField().every(p => p.hasAbility(Abilities.STEELY_SPIRIT))).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, moveToCheck)); game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex());
await game.phaseInterceptor.to(SelectTargetPhase, false); game.move.select(moveToCheck, 1, enemyToCheck.getBattlerIndex());
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, moveToCheck));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * Math.pow(steelySpiritMultiplier, 2)); expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower * Math.pow(steelySpiritMultiplier, 2));
@ -90,10 +82,8 @@ describe("Abilities - Steely Spirit", () => {
expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(false); expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(false);
expect(boostSource.summonData.abilitySuppressed).toBe(true); expect(boostSource.summonData.abilitySuppressed).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, moveToCheck)); game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex());
await game.phaseInterceptor.to(SelectTargetPhase, false); game.move.select(Moves.SPLASH, 1);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower); expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower);

View File

@ -1,13 +1,12 @@
import { EnemyPokemon } from "#app/field/pokemon.js"; import { EnemyPokemon } from "#app/field/pokemon";
import GameManager from "#test/utils/gameManager"; import { DamagePhase } from "#app/phases/damage-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { MoveEndPhase } from "#app/phases/move-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -42,7 +41,7 @@ describe("Abilities - Sturdy", () => {
"Sturdy activates when user is at full HP", "Sturdy activates when user is at full HP",
async () => { async () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
expect(game.scene.getEnemyParty()[0].hp).toBe(1); expect(game.scene.getEnemyParty()[0].hp).toBe(1);
}, },
@ -57,7 +56,7 @@ describe("Abilities - Sturdy", () => {
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
enemyPokemon.hp = enemyPokemon.getMaxHp() - 1; enemyPokemon.hp = enemyPokemon.getMaxHp() - 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
expect(enemyPokemon.hp).toBe(0); expect(enemyPokemon.hp).toBe(0);
@ -70,7 +69,7 @@ describe("Abilities - Sturdy", () => {
"Sturdy pokemon should be immune to OHKO moves", "Sturdy pokemon should be immune to OHKO moves",
async () => { async () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(MoveEndPhase); await game.phaseInterceptor.to(MoveEndPhase);
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];
@ -85,7 +84,7 @@ describe("Abilities - Sturdy", () => {
game.override.ability(Abilities.MOLD_BREAKER); game.override.ability(Abilities.MOLD_BREAKER);
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.CLOSE_COMBAT)); game.move.select(Moves.CLOSE_COMBAT);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);
const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0]; const enemyPokemon: EnemyPokemon = game.scene.getEnemyParty()[0];

View File

@ -1,16 +1,14 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { BattlerIndex } from "#app/battle";
import Phaser from "phaser"; import { Abilities } from "#app/enums/abilities";
import GameManager from "#test/utils/gameManager"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { Species } from "#enums/species"; import { CommandPhase } from "#app/phases/command-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { Species } from "#enums/species";
import { BattlerTagType } from "#app/enums/battler-tag-type.js"; import GameManager from "#test/utils/gameManager";
import { Abilities } from "#app/enums/abilities.js";
import { BattlerIndex } from "#app/battle.js";
import { SPLASH_ONLY } from "#test/utils/testUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js"; import Phaser from "phaser";
import { MovePhase } from "#app/phases/move-phase.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Abilities - Sweet Veil", () => { describe("Abilities - Sweet Veil", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -29,7 +27,7 @@ describe("Abilities - Sweet Veil", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override.battleType("double"); game.override.battleType("double");
game.override.moveset([Moves.SPLASH, Moves.REST]); game.override.moveset([Moves.SPLASH, Moves.REST, Moves.YAWN]);
game.override.enemySpecies(Species.MAGIKARP); game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyAbility(Abilities.BALL_FETCH); game.override.enemyAbility(Abilities.BALL_FETCH);
game.override.enemyMoveset([Moves.POWDER, Moves.POWDER, Moves.POWDER, Moves.POWDER]); game.override.enemyMoveset([Moves.POWDER, Moves.POWDER, Moves.POWDER, Moves.POWDER]);
@ -38,8 +36,8 @@ describe("Abilities - Sweet Veil", () => {
it("prevents the user and its allies from falling asleep", async () => { it("prevents the user and its allies from falling asleep", async () => {
await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -50,8 +48,8 @@ describe("Abilities - Sweet Veil", () => {
game.override.enemyMoveset(SPLASH_ONLY); game.override.enemyMoveset(SPLASH_ONLY);
await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.REST)); game.move.select(Moves.REST, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -62,8 +60,8 @@ describe("Abilities - Sweet Veil", () => {
game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]); game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]);
await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]); await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -74,28 +72,19 @@ describe("Abilities - Sweet Veil", () => {
game.override.enemySpecies(Species.PIKACHU); game.override.enemySpecies(Species.PIKACHU);
game.override.enemyLevel(5); game.override.enemyLevel(5);
game.override.startingLevel(5); game.override.startingLevel(5);
game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]); game.override.enemyMoveset(SPLASH_ONLY);
await game.startBattle([Species.SHUCKLE, Species.SHUCKLE, Species.SWIRLIX]); await game.startBattle([Species.SHUCKLE, Species.SHUCKLE, Species.SWIRLIX]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.YAWN, 1, BattlerIndex.PLAYER);
// First pokemon move await game.phaseInterceptor.to("BerryPhase");
await game.move.forceHit();
// Second pokemon move
await game.phaseInterceptor.to(MovePhase, false);
await game.move.forceHit();
expect(game.scene.getPlayerField().some(p => !!p.getTag(BattlerTagType.DROWSY))).toBe(true); expect(game.scene.getPlayerField().some(p => !!p.getTag(BattlerTagType.DROWSY))).toBe(true);
await game.phaseInterceptor.to(TurnEndPhase);
const drowsyMon = game.scene.getPlayerField().find(p => !!p.getTag(BattlerTagType.DROWSY))!;
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, (drowsyMon.getBattlerIndex() as BattlerIndex.PLAYER | BattlerIndex.PLAYER_2), Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doSwitchPokemon(2); game.doSwitchPokemon(2);
expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false); expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false);

View File

@ -1,11 +1,10 @@
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -80,7 +79,7 @@ async function testUnseenFistHitResult(game: GameManager, attackMove: Moves, pro
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, attackMove)); game.move.select(attackMove);
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
if (shouldSucceed) { if (shouldSucceed) {

View File

@ -1,11 +1,10 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -42,7 +41,7 @@ describe("Abilities - Volt Absorb", () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);

View File

@ -1,13 +1,12 @@
import { BattlerTagType } from "#app/enums/battler-tag-type.js"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
describe("Abilities - Wind Power", () => { describe("Abilities - Wind Power", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -38,7 +37,7 @@ describe("Abilities - Wind Power", () => {
expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.PETAL_BLIZZARD)); game.move.select(Moves.PETAL_BLIZZARD);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined();
@ -53,7 +52,7 @@ describe("Abilities - Wind Power", () => {
expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined(); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeDefined();
@ -70,7 +69,7 @@ describe("Abilities - Wind Power", () => {
expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined();
expect(magikarp.getTag(BattlerTagType.CHARGED)).toBeUndefined(); expect(magikarp.getTag(BattlerTagType.CHARGED)).toBeUndefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -86,7 +85,7 @@ describe("Abilities - Wind Power", () => {
expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined(); expect(shiftry.getTag(BattlerTagType.CHARGED)).toBeUndefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.SANDSTORM)); game.move.select(Moves.SANDSTORM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);

View File

@ -1,13 +1,12 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
describe("Abilities - Wind Rider", () => { describe("Abilities - Wind Rider", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -38,7 +37,7 @@ describe("Abilities - Wind Rider", () => {
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.PETAL_BLIZZARD)); game.move.select(Moves.PETAL_BLIZZARD);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -55,7 +54,7 @@ describe("Abilities - Wind Rider", () => {
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -73,7 +72,7 @@ describe("Abilities - Wind Rider", () => {
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -91,7 +90,7 @@ describe("Abilities - Wind Rider", () => {
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(magikarp.summonData.battleStats[BattleStat.ATK]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.TAILWIND)); game.move.select(Moves.TAILWIND);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -108,7 +107,7 @@ describe("Abilities - Wind Rider", () => {
expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0); expect(shiftry.summonData.battleStats[BattleStat.ATK]).toBe(0);
expect(shiftry.isFullHp()).toBe(true); expect(shiftry.isFullHp()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SANDSTORM)); game.move.select(Moves.SANDSTORM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);

View File

@ -1,14 +1,13 @@
import { allAbilities } from "#app/data/ability.js"; import { allAbilities } from "#app/data/ability";
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
describe("Abilities - Wonder Skin", () => { describe("Abilities - Wonder Skin", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -40,7 +39,7 @@ describe("Abilities - Wonder Skin", () => {
vi.spyOn(moveToCheck, "calculateBattleAccuracy"); vi.spyOn(moveToCheck, "calculateBattleAccuracy");
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); game.move.select(Moves.CHARM);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(50); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(50);
@ -52,7 +51,7 @@ describe("Abilities - Wonder Skin", () => {
vi.spyOn(moveToCheck, "calculateBattleAccuracy"); vi.spyOn(moveToCheck, "calculateBattleAccuracy");
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100);
@ -68,7 +67,7 @@ describe("Abilities - Wonder Skin", () => {
vi.spyOn(moveToCheck, "calculateBattleAccuracy"); vi.spyOn(moveToCheck, "calculateBattleAccuracy");
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM)); game.move.select(Moves.CHARM);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100);

View File

@ -1,26 +1,23 @@
import { BattlerIndex } from "#app/battle";
import { Stat } from "#app/data/pokemon-stat"; import { Stat } from "#app/data/pokemon-stat";
import { Status, StatusEffect } from "#app/data/status-effect.js"; import { Status, StatusEffect } from "#app/data/status-effect";
import GameManager from "#test/utils/gameManager"; import { DamagePhase } from "#app/phases/damage-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { Command } from "#app/ui/command-ui-handler"; import { MessagePhase } from "#app/phases/message-phase";
import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { SwitchPhase } from "#app/phases/switch-phase";
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { TurnStartPhase } from "#app/phases/turn-start-phase";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import { BattlerIndex } from "#app/battle.js";
import { CommandPhase } from "#app/phases/command-phase.js";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
import { MessagePhase } from "#app/phases/message-phase.js";
import { PostSummonPhase } from "#app/phases/post-summon-phase.js";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js";
import { SwitchPhase } from "#app/phases/switch-phase.js";
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
import { TurnStartPhase } from "#app/phases/turn-start-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -59,13 +56,7 @@ describe("Abilities - ZEN MODE", () => {
game.scene.getParty()[0].hp = 100; game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
@ -88,13 +79,7 @@ describe("Abilities - ZEN MODE", () => {
game.scene.getParty()[0].hp = 100; game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(QuietFormChangePhase); await game.phaseInterceptor.to(QuietFormChangePhase);
@ -114,13 +99,7 @@ describe("Abilities - ZEN MODE", () => {
game.scene.getParty()[0].hp = 100; game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0); expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]); await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
@ -169,7 +148,7 @@ describe("Abilities - ZEN MODE", () => {
darmanitan.status = new Status(StatusEffect.FAINT); darmanitan.status = new Status(StatusEffect.FAINT);
expect(darmanitan.isFainted()).toBe(true); expect(darmanitan.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();

View File

@ -1,11 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect.js"; import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js"; import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
@ -52,7 +51,7 @@ describe("Abilities - ZERO TO HERO", () => {
palafin2.status = new Status(StatusEffect.FAINT); palafin2.status = new Status(StatusEffect.FAINT);
expect(palafin2.isFainted()).toBe(true); expect(palafin2.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.doKillOpponents(); await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier(); game.doSelectModifier();
@ -80,7 +79,7 @@ describe("Abilities - ZERO TO HERO", () => {
const palafin = game.scene.getPlayerPokemon()!; const palafin = game.scene.getPlayerPokemon()!;
expect(palafin.formIndex).toBe(baseForm); expect(palafin.formIndex).toBe(baseForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.killPokemon(palafin); await game.killPokemon(palafin);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.toNextTurn(); await game.toNextTurn();
@ -97,7 +96,7 @@ describe("Abilities - ZERO TO HERO", () => {
const palafin = game.scene.getPlayerPokemon()!; const palafin = game.scene.getPlayerPokemon()!;
expect(palafin.formIndex).toBe(heroForm); expect(palafin.formIndex).toBe(heroForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.killPokemon(palafin); await game.killPokemon(palafin);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.toNextTurn(); await game.toNextTurn();

View File

@ -1,4 +1,4 @@
import * as battleScene from "#app/battle-scene.js"; import * as battleScene from "#app/battle-scene";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
import { initLoggedInUser, loggedInUser, updateUserInfo } from "../account"; import { initLoggedInUser, loggedInUser, updateUserInfo } from "../account";
import * as utils from "../utils"; import * as utils from "../utils";

View File

@ -1,7 +1,7 @@
import { TurnHeldItemTransferModifier } from "#app/modifier/modifier.js"; import { TurnHeldItemTransferModifier } from "#app/modifier/modifier";
import { Achv, AchvTier, DamageAchv, HealAchv, LevelAchv, ModifierAchv, MoneyAchv, RibbonAchv, achvs } from "#app/system/achv"; import { Achv, AchvTier, DamageAchv, HealAchv, LevelAchv, ModifierAchv, MoneyAchv, RibbonAchv, achvs } from "#app/system/achv";
import { IntegerHolder, NumberHolder } from "#app/utils";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { IntegerHolder, NumberHolder } from "#app/utils.js";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import BattleScene from "../../battle-scene"; import BattleScene from "../../battle-scene";

View File

@ -6,7 +6,6 @@ import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
@ -45,14 +44,14 @@ describe("Arena - Gravity", () => {
// Setup Gravity on first turn // Setup Gravity on first turn
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY)); game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use non-OHKO move on second turn // Use non-OHKO move on second turn
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 1.67); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 1.67);
@ -69,14 +68,14 @@ describe("Arena - Gravity", () => {
// Setup Gravity on first turn // Setup Gravity on first turn
await game.startBattle([Species.PIKACHU]); await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY)); game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use OHKO move on second turn // Use OHKO move on second turn
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(30); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(30);
@ -96,21 +95,21 @@ describe("Arena - Gravity", () => {
vi.spyOn(pidgeot, "getAttackTypeEffectiveness"); vi.spyOn(pidgeot, "getAttackTypeEffectiveness");
// Try earthquake on 1st turn (fails!); // Try earthquake on 1st turn (fails!);
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(0); expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(0);
// Setup Gravity on 2nd turn // Setup Gravity on 2nd turn
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY)); game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use ground move on 3rd turn // Use ground move on 3rd turn
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE)); game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(1); expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(1);
@ -129,14 +128,14 @@ describe("Arena - Gravity", () => {
vi.spyOn(pidgeot, "getAttackTypeEffectiveness"); vi.spyOn(pidgeot, "getAttackTypeEffectiveness");
// Setup Gravity on 1st turn // Setup Gravity on 1st turn
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY)); game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined(); expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use electric move on 2nd turn // Use electric move on 2nd turn
await game.toNextTurn(); await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.THUNDERBOLT)); game.move.select(Moves.THUNDERBOLT);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(2); expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(2);

View File

@ -1,11 +1,10 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { WeatherType } from "#app/data/weather.js"; import { WeatherType } from "#app/data/weather";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -41,7 +40,7 @@ describe("Weather - Fog", () => {
vi.spyOn(moveToCheck, "calculateBattleAccuracy"); vi.spyOn(moveToCheck, "calculateBattleAccuracy");
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE)); game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 0.9); expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 0.9);

View File

@ -1,12 +1,11 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import GameManager from "#test/utils/gameManager"; import { TurnStartPhase } from "#app/phases/turn-start-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { TurnStartPhase } from "#app/phases/turn-start-phase.js";
describe("Weather - Strong Winds", () => { describe("Weather - Strong Winds", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -38,7 +37,7 @@ describe("Weather - Strong Winds", () => {
const pikachu = game.scene.getPlayerPokemon()!; const pikachu = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.THUNDERBOLT)); game.move.select(Moves.THUNDERBOLT);
await game.phaseInterceptor.to(TurnStartPhase); await game.phaseInterceptor.to(TurnStartPhase);
expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.THUNDERBOLT].type, pikachu)).toBe(0.5); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.THUNDERBOLT].type, pikachu)).toBe(0.5);
@ -49,7 +48,7 @@ describe("Weather - Strong Winds", () => {
const pikachu = game.scene.getPlayerPokemon()!; const pikachu = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.THUNDERBOLT)); game.move.select(Moves.THUNDERBOLT);
await game.phaseInterceptor.to(TurnStartPhase); await game.phaseInterceptor.to(TurnStartPhase);
expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.THUNDERBOLT].type, pikachu)).toBe(1); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.THUNDERBOLT].type, pikachu)).toBe(1);
@ -60,7 +59,7 @@ describe("Weather - Strong Winds", () => {
const pikachu = game.scene.getPlayerPokemon()!; const pikachu = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.ICE_BEAM)); game.move.select(Moves.ICE_BEAM);
await game.phaseInterceptor.to(TurnStartPhase); await game.phaseInterceptor.to(TurnStartPhase);
expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.ICE_BEAM].type, pikachu)).toBe(1); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.ICE_BEAM].type, pikachu)).toBe(1);
@ -71,7 +70,7 @@ describe("Weather - Strong Winds", () => {
const pikachu = game.scene.getPlayerPokemon()!; const pikachu = game.scene.getPlayerPokemon()!;
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.ROCK_SLIDE)); game.move.select(Moves.ROCK_SLIDE);
await game.phaseInterceptor.to(TurnStartPhase); await game.phaseInterceptor.to(TurnStartPhase);
expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.ROCK_SLIDE].type, pikachu)).toBe(1); expect(enemy.getAttackTypeEffectiveness(allMoves[Moves.ROCK_SLIDE].type, pikachu)).toBe(1);

View File

@ -1,4 +1,4 @@
import { LoadingScene } from "#app/loading-scene.js"; import { LoadingScene } from "#app/loading-scene";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "./utils/gameManager"; import GameManager from "./utils/gameManager";

View File

@ -1,4 +1,4 @@
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat.js"; import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat";
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { arrayOfRange, mockI18next } from "./utils/testUtils"; import { arrayOfRange, mockI18next } from "./utils/testUtils";

View File

@ -1,19 +1,13 @@
import { Stat } from "#app/data/pokemon-stat"; import { Stat } from "#app/data/pokemon-stat";
import GameManager from "#test/utils/gameManager"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { SelectTargetPhase } from "#app/phases/select-target-phase";
import { Command } from "#app/ui/command-ui-handler"; import { TurnStartPhase } from "#app/phases/turn-start-phase";
import TargetSelectUiHandler from "#app/ui/target-select-ui-handler";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Button } from "#enums/buttons";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { CommandPhase } from "#app/phases/command-phase.js";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
import { SelectTargetPhase } from "#app/phases/select-target-phase.js";
import { TurnStartPhase } from "#app/phases/turn-start-phase.js";
describe("Battle order", () => { describe("Battle order", () => {
@ -39,20 +33,14 @@ describe("Battle order", () => {
game.override.moveset([Moves.TACKLE]); game.override.moveset([Moves.TACKLE]);
}); });
it("opponent faster than player 50 vs 150", async() => { it("opponent faster than player 50 vs 150", async () => {
await game.startBattle([ await game.startBattle([
Species.BULBASAUR, Species.BULBASAUR,
]); ]);
game.scene.getParty()[0].stats[Stat.SPD] = 50; game.scene.getParty()[0].stats[Stat.SPD] = 50;
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150;
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
await game.phaseInterceptor.run(EnemyCommandPhase); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase; const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getOrder(); const order = phase.getOrder();
@ -60,20 +48,14 @@ describe("Battle order", () => {
expect(order[1]).toBe(0); expect(order[1]).toBe(0);
}, 20000); }, 20000);
it("Player faster than opponent 150 vs 50", async() => { it("Player faster than opponent 150 vs 50", async () => {
await game.startBattle([ await game.startBattle([
Species.BULBASAUR, Species.BULBASAUR,
]); ]);
game.scene.getParty()[0].stats[Stat.SPD] = 150; game.scene.getParty()[0].stats[Stat.SPD] = 150;
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 50; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 50;
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
await game.phaseInterceptor.run(EnemyCommandPhase); await game.phaseInterceptor.run(EnemyCommandPhase);
const phase = game.scene.getCurrentPhase() as TurnStartPhase; const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getOrder(); const order = phase.getOrder();
@ -81,7 +63,7 @@ describe("Battle order", () => {
expect(order[1]).toBe(2); expect(order[1]).toBe(2);
}, 20000); }, 20000);
it("double - both opponents faster than player 50/50 vs 150/150", async() => { it("double - both opponents faster than player 50/50 vs 150/150", async () => {
game.override.battleType("double"); game.override.battleType("double");
await game.startBattle([ await game.startBattle([
Species.BULBASAUR, Species.BULBASAUR,
@ -92,28 +74,8 @@ describe("Battle order", () => {
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 150;
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150; game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150;
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); game.move.select(Moves.TACKLE, 1);
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
const handler = game.scene.ui.getHandler() as TargetSelectUiHandler;
handler.processInput(Button.ACTION);
});
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, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
const handler = game.scene.ui.getHandler() as TargetSelectUiHandler;
handler.processInput(Button.ACTION);
});
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
const phase = game.scene.getCurrentPhase() as TurnStartPhase; const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getOrder(); const order = phase.getOrder();
@ -123,7 +85,7 @@ describe("Battle order", () => {
expect(order.indexOf(1)).toBeGreaterThan(order.indexOf(3)); expect(order.indexOf(1)).toBeGreaterThan(order.indexOf(3));
}, 20000); }, 20000);
it("double - speed tie except 1 - 100/100 vs 100/150", async() => { it("double - speed tie except 1 - 100/100 vs 100/150", async () => {
game.override.battleType("double"); game.override.battleType("double");
await game.startBattle([ await game.startBattle([
Species.BULBASAUR, Species.BULBASAUR,
@ -134,28 +96,8 @@ describe("Battle order", () => {
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 100; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 100;
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150; game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150;
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); game.move.select(Moves.TACKLE, 1);
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
const handler = game.scene.ui.getHandler() as TargetSelectUiHandler;
handler.processInput(Button.ACTION);
});
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, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
const handler = game.scene.ui.getHandler() as TargetSelectUiHandler;
handler.processInput(Button.ACTION);
});
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
const phase = game.scene.getCurrentPhase() as TurnStartPhase; const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getOrder(); const order = phase.getOrder();
@ -164,7 +106,7 @@ describe("Battle order", () => {
expect(order.indexOf(3)).toBeLessThan(order.indexOf(2)); expect(order.indexOf(3)).toBeLessThan(order.indexOf(2));
}, 20000); }, 20000);
it("double - speed tie 100/150 vs 100/150", async() => { it("double - speed tie 100/150 vs 100/150", async () => {
game.override.battleType("double"); game.override.battleType("double");
await game.startBattle([ await game.startBattle([
Species.BULBASAUR, Species.BULBASAUR,
@ -175,28 +117,8 @@ describe("Battle order", () => {
game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 100; game.scene.currentBattle.enemyParty[0].stats[Stat.SPD] = 100;
game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150; game.scene.currentBattle.enemyParty[1].stats[Stat.SPD] = 150;
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex()); game.move.select(Moves.TACKLE, 1);
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
const handler = game.scene.ui.getHandler() as TargetSelectUiHandler;
handler.processInput(Button.ACTION);
});
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, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.onNextPrompt("SelectTargetPhase", Mode.TARGET_SELECT, () => {
const handler = game.scene.ui.getHandler() as TargetSelectUiHandler;
handler.processInput(Button.ACTION);
});
await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false); await game.phaseInterceptor.runFrom(SelectTargetPhase).to(TurnStartPhase, false);
const phase = game.scene.getCurrentPhase() as TurnStartPhase; const phase = game.scene.getCurrentPhase() as TurnStartPhase;
const order = phase.getOrder(); const order = phase.getOrder();

View File

@ -1,10 +1,23 @@
import { allSpecies } from "#app/data/pokemon-species"; import { allSpecies } from "#app/data/pokemon-species";
import { TempBattleStat } from "#app/data/temp-battle-stat.js"; import { TempBattleStat } from "#app/data/temp-battle-stat";
import { GameModes } from "#app/game-mode"; import { GameModes, getGameMode } from "#app/game-mode";
import { getGameMode } from "#app/game-mode.js"; import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase";
import { EncounterPhase } from "#app/phases/encounter-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { LoginPhase } from "#app/phases/login-phase";
import { NextEncounterPhase } from "#app/phases/next-encounter-phase";
import { SelectGenderPhase } from "#app/phases/select-gender-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { SelectStarterPhase } from "#app/phases/select-starter-phase";
import { SummonPhase } from "#app/phases/summon-phase";
import { SwitchPhase } from "#app/phases/switch-phase";
import { TitlePhase } from "#app/phases/title-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { VictoryPhase } from "#app/phases/victory-phase";
import GameManager from "#app/test/utils/gameManager"; import GameManager from "#app/test/utils/gameManager";
import { generateStarter, getMovePosition, } from "#app/test/utils/gameManagerUtils"; import { generateStarter } from "#app/test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -13,21 +26,6 @@ import { Species } from "#enums/species";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { BattleEndPhase } from "#app/phases/battle-end-phase.js";
import { CommandPhase } from "#app/phases/command-phase.js";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { EncounterPhase } from "#app/phases/encounter-phase.js";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
import { LoginPhase } from "#app/phases/login-phase.js";
import { NextEncounterPhase } from "#app/phases/next-encounter-phase.js";
import { SelectGenderPhase } from "#app/phases/select-gender-phase.js";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase.js";
import { SelectStarterPhase } from "#app/phases/select-starter-phase.js";
import { SummonPhase } from "#app/phases/summon-phase.js";
import { SwitchPhase } from "#app/phases/switch-phase.js";
import { TitlePhase } from "#app/phases/title-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
import { VictoryPhase } from "#app/phases/victory-phase.js";
describe("Test Battle Phase", () => { describe("Test Battle Phase", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -47,7 +45,7 @@ describe("Test Battle Phase", () => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
}); });
it("test phase interceptor with prompt", async() => { it("test phase interceptor with prompt", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => {
@ -65,7 +63,7 @@ describe("Test Battle Phase", () => {
expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); expect(game.scene.gameData.gender).toBe(PlayerGender.MALE);
}, 20000); }, 20000);
it("test phase interceptor with prompt with preparation for a future prompt", async() => { it("test phase interceptor with prompt with preparation for a future prompt", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => {
@ -87,13 +85,13 @@ describe("Test Battle Phase", () => {
expect(game.scene.gameData.gender).toBe(PlayerGender.MALE); expect(game.scene.gameData.gender).toBe(PlayerGender.MALE);
}, 20000); }, 20000);
it("newGame one-liner", async() => { it("newGame one-liner", async () => {
await game.startBattle(); await game.startBattle();
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND); expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000); }, 20000);
it("do attack wave 3 - single battle - regular - OHKO", async() => { it("do attack wave 3 - single battle - regular - OHKO", async () => {
game.override.starterSpecies(Species.MEWTWO); game.override.starterSpecies(Species.MEWTWO);
game.override.enemySpecies(Species.RATTATA); game.override.enemySpecies(Species.RATTATA);
game.override.startingLevel(2000); game.override.startingLevel(2000);
@ -104,17 +102,11 @@ describe("Test Battle Phase", () => {
game.override.enemyAbility(Abilities.HYDRATION); game.override.enemyAbility(Abilities.HYDRATION);
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle(); await game.startBattle();
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(SelectModifierPhase, false); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(SelectModifierPhase, false);
}, 20000); }, 20000);
it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async() => { it("do attack wave 3 - single battle - regular - NO OHKO with opponent using non damage attack", async () => {
game.override.starterSpecies(Species.MEWTWO); game.override.starterSpecies(Species.MEWTWO);
game.override.enemySpecies(Species.RATTATA); game.override.enemySpecies(Species.RATTATA);
game.override.startingLevel(5); game.override.startingLevel(5);
@ -124,17 +116,11 @@ describe("Test Battle Phase", () => {
game.override.enemyMoveset([Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP]); game.override.enemyMoveset([Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP]);
game.override.battleType("single"); game.override.battleType("single");
await game.startBattle(); await game.startBattle();
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(Moves.TACKLE);
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, Moves.TACKLE);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase, false); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase, false);
}, 20000); }, 20000);
it("load 100% data file", async() => { it("load 100% data file", async () => {
await game.importData("src/test/utils/saves/everything.prsv"); await game.importData("src/test/utils/saves/everything.prsv");
const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => { const caughtCount = Object.keys(game.scene.gameData.dexData).filter((key) => {
const species = game.scene.gameData.dexData[key]; const species = game.scene.gameData.dexData[key];
@ -143,7 +129,7 @@ describe("Test Battle Phase", () => {
expect(caughtCount).toBe(Object.keys(allSpecies).length); expect(caughtCount).toBe(Object.keys(allSpecies).length);
}, 20000); }, 20000);
it("start battle with selected team", async() => { it("start battle with selected team", async () => {
await game.startBattle([ await game.startBattle([
Species.CHARIZARD, Species.CHARIZARD,
Species.CHANSEY, Species.CHANSEY,
@ -154,26 +140,26 @@ describe("Test Battle Phase", () => {
expect(game.scene.getParty()[2].species.speciesId).toBe(Species.MEW); expect(game.scene.getParty()[2].species.speciesId).toBe(Species.MEW);
}, 20000); }, 20000);
it("test remove random battle seed int", async() => { it("test remove random battle seed int", async () => {
for (let i=0; i<10; i++) { for (let i = 0; i < 10; i++) {
const rand = game.scene.randBattleSeedInt(16); const rand = game.scene.randBattleSeedInt(16);
expect(rand).toBe(15); expect(rand).toBe(15);
} }
}); });
it("wrong phase", async() => { it("wrong phase", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
await game.phaseInterceptor.run(LoginPhase).catch((e) => { await game.phaseInterceptor.run(LoginPhase).catch((e) => {
expect(e).toBe("Wrong phase: this is SelectGenderPhase and not LoginPhase"); expect(e).toBe("Wrong phase: this is SelectGenderPhase and not LoginPhase");
}); });
}, 20000); }, 20000);
it("wrong phase but skip", async() => { it("wrong phase but skip", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
await game.phaseInterceptor.run(LoginPhase, () => game.isCurrentPhase(SelectGenderPhase)); await game.phaseInterceptor.run(LoginPhase, () => game.isCurrentPhase(SelectGenderPhase));
}, 20000); }, 20000);
it("good run", async() => { it("good run", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => {
game.scene.gameData.gender = PlayerGender.MALE; game.scene.gameData.gender = PlayerGender.MALE;
@ -183,7 +169,7 @@ describe("Test Battle Phase", () => {
await game.phaseInterceptor.run(TitlePhase); await game.phaseInterceptor.run(TitlePhase);
}, 20000); }, 20000);
it("good run from select gender to title", async() => { it("good run from select gender to title", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => {
game.scene.gameData.gender = PlayerGender.MALE; game.scene.gameData.gender = PlayerGender.MALE;
@ -192,7 +178,7 @@ describe("Test Battle Phase", () => {
await game.phaseInterceptor.runFrom(SelectGenderPhase).to(TitlePhase); await game.phaseInterceptor.runFrom(SelectGenderPhase).to(TitlePhase);
}, 20000); }, 20000);
it("good run to SummonPhase phase", async() => { it("good run to SummonPhase phase", async () => {
await game.phaseInterceptor.run(LoginPhase); await game.phaseInterceptor.run(LoginPhase);
game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => { game.onNextPrompt("SelectGenderPhase", Mode.OPTION_SELECT, () => {
game.scene.gameData.gender = PlayerGender.MALE; game.scene.gameData.gender = PlayerGender.MALE;
@ -208,7 +194,7 @@ describe("Test Battle Phase", () => {
await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase); await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase);
}, 20000); }, 20000);
it("2vs1", async() => { it("2vs1", async () => {
game.override.battleType("single"); game.override.battleType("single");
game.override.enemySpecies(Species.MIGHTYENA); game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION); game.override.enemyAbility(Abilities.HYDRATION);
@ -221,7 +207,7 @@ describe("Test Battle Phase", () => {
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000); }, 20000);
it("1vs1", async() => { it("1vs1", async () => {
game.override.battleType("single"); game.override.battleType("single");
game.override.enemySpecies(Species.MIGHTYENA); game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION); game.override.enemyAbility(Abilities.HYDRATION);
@ -233,7 +219,7 @@ describe("Test Battle Phase", () => {
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000); }, 20000);
it("2vs2", async() => { it("2vs2", async () => {
game.override.battleType("double"); game.override.battleType("double");
game.override.enemySpecies(Species.MIGHTYENA); game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION); game.override.enemyAbility(Abilities.HYDRATION);
@ -247,7 +233,7 @@ describe("Test Battle Phase", () => {
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000); }, 20000);
it("4vs2", async() => { it("4vs2", async () => {
game.override.battleType("double"); game.override.battleType("double");
game.override.enemySpecies(Species.MIGHTYENA); game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION); game.override.enemyAbility(Abilities.HYDRATION);
@ -263,7 +249,7 @@ describe("Test Battle Phase", () => {
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name); expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000); }, 20000);
it("kill opponent pokemon", async() => { it("kill opponent pokemon", async () => {
const moveToUse = Moves.SPLASH; const moveToUse = Moves.SPLASH;
game.override.battleType("single"); game.override.battleType("single");
game.override.starterSpecies(Species.MEWTWO); game.override.starterSpecies(Species.MEWTWO);
@ -273,26 +259,20 @@ describe("Test Battle Phase", () => {
game.override.startingLevel(2000); game.override.startingLevel(2000);
game.override.startingWave(3); game.override.startingWave(3);
game.override.moveset([moveToUse]); game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle([ await game.startBattle([
Species.DARMANITAN, Species.DARMANITAN,
Species.CHARIZARD, Species.CHARIZARD,
]); ]);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
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);
});
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);
await game.killPokemon(game.scene.currentBattle.enemyParty[0]); await game.killPokemon(game.scene.currentBattle.enemyParty[0]);
expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true); expect(game.scene.currentBattle.enemyParty[0].isFainted()).toBe(true);
await game.phaseInterceptor.to(VictoryPhase, false); await game.phaseInterceptor.to(VictoryPhase, false);
}, 200000); }, 200000);
it("to next turn", async() => { it("to next turn", async () => {
const moveToUse = Moves.SPLASH; const moveToUse = Moves.SPLASH;
game.override.battleType("single"); game.override.battleType("single");
game.override.starterSpecies(Species.MEWTWO); game.override.starterSpecies(Species.MEWTWO);
@ -302,15 +282,15 @@ describe("Test Battle Phase", () => {
game.override.startingLevel(2000); game.override.startingLevel(2000);
game.override.startingWave(3); game.override.startingWave(3);
game.override.moveset([moveToUse]); game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle(); await game.startBattle();
const turn = game.scene.currentBattle.turn; const turn = game.scene.currentBattle.turn;
game.doAttack(0); game.move.select(moveToUse);
await game.toNextTurn(); await game.toNextTurn();
expect(game.scene.currentBattle.turn).toBeGreaterThan(turn); expect(game.scene.currentBattle.turn).toBeGreaterThan(turn);
}, 20000); }, 20000);
it("to next wave with pokemon killed, single", async() => { it("to next wave with pokemon killed, single", async () => {
const moveToUse = Moves.SPLASH; const moveToUse = Moves.SPLASH;
game.override.battleType("single"); game.override.battleType("single");
game.override.starterSpecies(Species.MEWTWO); game.override.starterSpecies(Species.MEWTWO);
@ -320,10 +300,10 @@ describe("Test Battle Phase", () => {
game.override.startingLevel(2000); game.override.startingLevel(2000);
game.override.startingWave(3); game.override.startingWave(3);
game.override.moveset([moveToUse]); game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle(); await game.startBattle();
const waveIndex = game.scene.currentBattle.waveIndex; const waveIndex = game.scene.currentBattle.waveIndex;
game.doAttack(0); game.move.select(moveToUse);
await game.doKillOpponents(); await game.doKillOpponents();
await game.toNextWave(); await game.toNextWave();
expect(game.scene.currentBattle.waveIndex).toBeGreaterThan(waveIndex); expect(game.scene.currentBattle.waveIndex).toBeGreaterThan(waveIndex);
@ -343,7 +323,7 @@ describe("Test Battle Phase", () => {
await game.startBattle(); await game.startBattle();
game.scene.getPlayerPokemon()!.hp = 1; game.scene.getPlayerPokemon()!.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(BattleEndPhase); await game.phaseInterceptor.to(BattleEndPhase);
game.doRevivePokemon(0); // pretend max revive was picked game.doRevivePokemon(0); // pretend max revive was picked

View File

@ -1,14 +1,13 @@
import { DamagePhase } from "#app/phases/damage-phase.js"; import { DamagePhase } from "#app/phases/damage-phase.js";
import GameManager from "#test/utils/gameManager"; import { toDmgValue } from "#app/utils";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { ArenaTagType } from "#enums/arena-tag-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { ArenaTagType } from "#enums/arena-tag-type";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { toDmgValue } from "#app/utils";
describe("Round Down and Minimun 1 test in Damage Calculation", () => { describe("Round Down and Minimun 1 test in Damage Calculation", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -41,7 +40,7 @@ describe("Round Down and Minimun 1 test in Damage Calculation", () => {
const shedinja = game.scene.getPlayerPokemon()!; const shedinja = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.JUMP_KICK)); game.move.select(Moves.JUMP_KICK);
await game.phaseInterceptor.to(DamagePhase); await game.phaseInterceptor.to(DamagePhase);

View File

@ -1,13 +1,12 @@
import GameManager from "#test/utils/gameManager"; import { Status, StatusEffect } from "#app/data/status-effect";
import { getMovePosition, } from "#test/utils/gameManagerUtils"; import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { Status, StatusEffect } from "#app/data/status-effect.js";
import { BattleEndPhase } from "#app/phases/battle-end-phase.js";
import { TurnInitPhase } from "#app/phases/turn-init-phase.js";
describe("Double Battles", () => { describe("Double Battles", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -29,7 +28,7 @@ describe("Double Battles", () => {
// double-battle player's pokemon both fainted in same round, then revive one, and next double battle summons two player's pokemon successfully. // double-battle player's pokemon both fainted in same round, then revive one, and next double battle summons two player's pokemon successfully.
// (There were bugs that either only summon one when can summon two, player stuck in switchPhase etc) // (There were bugs that either only summon one when can summon two, player stuck in switchPhase etc)
it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async() => { it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async () => {
game.override.battleType("double").enemyMoveset(SPLASH_ONLY).moveset(SPLASH_ONLY); game.override.battleType("double").enemyMoveset(SPLASH_ONLY).moveset(SPLASH_ONLY);
await game.startBattle([ await game.startBattle([
Species.BULBASAUR, Species.BULBASAUR,
@ -37,8 +36,8 @@ describe("Double Battles", () => {
Species.SQUIRTLE, Species.SQUIRTLE,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
for (const pokemon of game.scene.getPlayerField()) { for (const pokemon of game.scene.getPlayerField()) {
pokemon.hp = 0; pokemon.hp = 0;

View File

@ -1,13 +1,14 @@
import GameManager from "#test/utils/gameManager";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Error Handling", () => { describe("Error Handling", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
const moveToUse = Moves.SPLASH;
beforeAll(() => { beforeAll(() => {
phaserGame = new Phaser.Game({ phaserGame = new Phaser.Game({
@ -21,7 +22,6 @@ describe("Error Handling", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const moveToUse = Moves.SPLASH;
game.override game.override
.battleType("single") .battleType("single")
.startingWave(3); .startingWave(3);
@ -31,13 +31,13 @@ describe("Error Handling", () => {
game.override.ability(Abilities.ZEN_MODE); game.override.ability(Abilities.ZEN_MODE);
game.override.startingLevel(2000); game.override.startingLevel(2000);
game.override.moveset([moveToUse]); game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
}); });
it.skip("to next turn", async() => { it.skip("to next turn", async () => {
await game.startBattle(); await game.startBattle();
const turn = game.scene.currentBattle.turn; const turn = game.scene.currentBattle.turn;
game.doAttack(0); game.move.select(moveToUse);
await game.toNextTurn(); await game.toNextTurn();
expect(game.scene.currentBattle.turn).toBeGreaterThan(turn); expect(game.scene.currentBattle.turn).toBeGreaterThan(turn);
}, 20000); }, 20000);

View File

@ -1,9 +1,9 @@
import { CommandPhase } from "#app/phases/command-phase.js"; import { CommandPhase } from "#app/phases/command-phase";
import GameManager from "#test/utils/gameManager";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,10 +1,10 @@
import BattleScene from "#app/battle-scene";
import { BattleStat } from "#app/data/battle-stat";
import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import Pokemon from "#app/field/pokemon";
import { StatChangePhase } from "#app/phases/stat-change-phase";
import { describe, expect, it, vi } from "vitest"; import { describe, expect, it, vi } from "vitest";
import Pokemon from "#app/field/pokemon.js";
import BattleScene from "#app/battle-scene.js";
import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags.js";
import { BattleStat } from "#app/data/battle-stat.js";
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
import { StatChangePhase } from "#app/phases/stat-change-phase.js";
vi.mock("#app/battle-scene.js"); vi.mock("#app/battle-scene.js");

View File

@ -1,10 +1,10 @@
import BattleScene from "#app/battle-scene";
import { BattleStat } from "#app/data/battle-stat";
import { StockpilingTag } from "#app/data/battler-tags";
import Pokemon, { PokemonSummonData } from "#app/field/pokemon";
import * as messages from "#app/messages";
import { StatChangePhase } from "#app/phases/stat-change-phase";
import { beforeEach, describe, expect, it, vi } from "vitest"; import { beforeEach, describe, expect, it, vi } from "vitest";
import Pokemon, { PokemonSummonData } from "#app/field/pokemon.js";
import BattleScene from "#app/battle-scene.js";
import { StockpilingTag } from "#app/data/battler-tags.js";
import { BattleStat } from "#app/data/battle-stat.js";
import * as messages from "#app/messages.js";
import { StatChangePhase } from "#app/phases/stat-change-phase.js";
beforeEach(() => { beforeEach(() => {
vi.spyOn(messages, "getPokemonNameWithAffix").mockImplementation(() => ""); vi.spyOn(messages, "getPokemonNameWithAffix").mockImplementation(() => "");

View File

@ -1,14 +1,14 @@
import { Egg, getLegendaryGachaSpeciesForTimestamp } from "#app/data/egg";
import { EggSourceType } from "#app/enums/egg-source-types";
import { EggTier } from "#app/enums/egg-type";
import { VariantTier } from "#app/enums/variant-tiers";
import EggData from "#app/system/egg-data";
import * as Utils from "#app/utils";
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 { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import BattleScene from "../../battle-scene"; import BattleScene from "../../battle-scene";
import { Egg, getLegendaryGachaSpeciesForTimestamp } from "#app/data/egg.js";
import { Species } from "#enums/species";
import Phaser from "phaser";
import { EggSourceType } from "#app/enums/egg-source-types.js";
import { EggTier } from "#app/enums/egg-type.js";
import { VariantTier } from "#app/enums/variant-tiers.js";
import GameManager from "#test/utils/gameManager";
import EggData from "#app/system/egg-data.js";
import * as Utils from "#app/utils.js";
describe("Egg Generation Tests", () => { describe("Egg Generation Tests", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;

View File

@ -1,6 +1,6 @@
import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions.js"; import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,8 +1,8 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { Species } from "#enums/species";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
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";
describe("Evolution tests", () => { describe("Evolution tests", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;

View File

@ -1,4 +1,4 @@
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "../utils/gameManager"; import GameManager from "../utils/gameManager";

View File

@ -1,8 +1,8 @@
import { Biome } from "#app/enums/biome.js"; import { Biome } from "#app/enums/biome";
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { GameModes } from "#app/game-mode";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "./utils/gameManager"; import GameManager from "./utils/gameManager";
import { GameModes } from "#app/game-mode";
const FinalWave = { const FinalWave = {
Classic: 200, Classic: 200,

View File

@ -1,7 +1,7 @@
import { GameMode, GameModes, getGameMode } from "#app/game-mode.js"; import { GameMode, GameModes, getGameMode } from "#app/game-mode";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import GameManager from "./utils/gameManager";
import * as Utils from "../utils"; import * as Utils from "../utils";
import GameManager from "./utils/gameManager";
describe("game-mode", () => { describe("game-mode", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;

View File

@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { initStatsKeys } from "#app/ui/game-stats-ui-handler"; import { initStatsKeys } from "#app/ui/game-stats-ui-handler";
import { describe, expect, it } from "vitest";
async function importModule() { async function importModule() {
try { try {

View File

@ -1,9 +1,9 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import pad_xbox360 from "#app/configs/inputs/pad_xbox360";
import cfg_keyboard_qwerty from "#app/configs/inputs/cfg_keyboard_qwerty"; import cfg_keyboard_qwerty from "#app/configs/inputs/cfg_keyboard_qwerty";
import pad_xbox360 from "#app/configs/inputs/pad_xbox360";
import GameManager from "#test/utils/gameManager";
import InputsHandler from "#test/utils/inputsHandler"; import InputsHandler from "#test/utils/inputsHandler";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Inputs", () => { describe("Inputs", () => {

View File

@ -1,8 +1,8 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { Abilities } from "#app/enums/abilities";
import Phaser from "phaser"; import { Species } from "#app/enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { Species } from "#app/enums/species.js"; import Phaser from "phaser";
import { Abilities } from "#app/enums/abilities.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Internals", () => { describe("Internals", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;

View File

@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat";
import { EvolutionStatBoosterModifier } from "#app/modifier/modifier"; import { EvolutionStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -1,7 +1,7 @@
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { PokemonExpBoosterModifier } from "#app/modifier/modifier.js"; import { PokemonExpBoosterModifier } from "#app/modifier/modifier";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";

View File

@ -1,16 +1,14 @@
import { BattlerIndex } from "#app/battle.js"; import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { BerryType } from "#app/enums/berry-type.js"; import { BerryType } from "#app/enums/berry-type";
import { Moves } from "#app/enums/moves.js"; import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { SelectTargetPhase } from "#app/phases/select-target-phase.js";
const TIMEOUT = 20 * 1000; // 20 seconds const TIMEOUT = 20 * 1000; // 20 seconds
@ -35,12 +33,12 @@ describe("Items - Grip Claw", () => {
.battleType("double") .battleType("double")
.moveset([Moves.POPULATION_BOMB, Moves.SPLASH]) .moveset([Moves.POPULATION_BOMB, Moves.SPLASH])
.startingHeldItems([ .startingHeldItems([
{ name: "GRIP_CLAW", count: 5 }, { name: "GRIP_CLAW", count: 5 }, // TODO: Find a way to mock the steal chance of grip claw
{ name: "MULTI_LENS", count: 3 }, { name: "MULTI_LENS", count: 3 },
]) ])
.enemySpecies(Species.SNORLAX) .enemySpecies(Species.SNORLAX)
.ability(Abilities.KLUTZ) .ability(Abilities.KLUTZ)
.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]) .enemyMoveset(SPLASH_ONLY)
.enemyHeldItems([ .enemyHeldItems([
{ name: "BERRY", type: BerryType.SITRUS, count: 2 }, { name: "BERRY", type: BerryType.SITRUS, count: 2 },
{ name: "BERRY", type: BerryType.LUM, count: 2 }, { name: "BERRY", type: BerryType.LUM, count: 2 },
@ -54,19 +52,14 @@ describe("Items - Grip Claw", () => {
it( it(
"should only steal items from the attack target", "should only steal items from the attack target",
async () => { async () => {
await game.startBattle([Species.PANSEAR, Species.ROWLET, Species.PANPOUR, Species.PANSAGE, Species.CHARMANDER, Species.SQUIRTLE]); await game.startBattle([Species.PANSEAR, Species.ROWLET]);
const enemyPokemon = game.scene.getEnemyField(); const enemyPokemon = game.scene.getEnemyField();
const enemyHeldItemCt = enemyPokemon.map(p => p.getHeldItems.length); const enemyHeldItemCt = enemyPokemon.map(p => p.getHeldItems.length);
game.doAttack(getMovePosition(game.scene, 0, Moves.POPULATION_BOMB)); game.move.select(Moves.POPULATION_BOMB, 0, BattlerIndex.ENEMY);
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(BattlerIndex.ENEMY);
await game.phaseInterceptor.to(CommandPhase, false);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(MoveEndPhase, false); await game.phaseInterceptor.to(MoveEndPhase, false);

View File

@ -1,11 +1,11 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { CritBoosterModifier } from "#app/modifier/modifier"; import { CritBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -27,21 +27,21 @@ describe("Items - Leek", () => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override.enemySpecies(Species.MAGIKARP); game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
game.override.disableCrits(); game.override.disableCrits();
game.override.battleType("single"); game.override.battleType("single");
}); });
it("LEEK activates in battle correctly", async() => { it("LEEK activates in battle correctly", async () => {
game.override.startingHeldItems([{ name: "LEEK" }]); game.override.startingHeldItems([{ name: "LEEK" }]);
game.override.moveset([ Moves.POUND ]); game.override.moveset([Moves.POUND]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([ await game.startBattle([
Species.FARFETCHD Species.FARFETCHD
]); ]);
game.doAttack(0); game.move.select(Moves.POUND);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
@ -50,7 +50,7 @@ describe("Items - Leek", () => {
expect(consoleSpy).toHaveBeenCalledWith("Applied", "Leek", ""); expect(consoleSpy).toHaveBeenCalledWith("Applied", "Leek", "");
}, 20000); }, 20000);
it("LEEK held by FARFETCHD", async() => { it("LEEK held by FARFETCHD", async () => {
await game.startBattle([ await game.startBattle([
Species.FARFETCHD Species.FARFETCHD
]); ]);
@ -70,7 +70,7 @@ describe("Items - Leek", () => {
expect(critLevel.value).toBe(2); expect(critLevel.value).toBe(2);
}, 20000); }, 20000);
it("LEEK held by GALAR_FARFETCHD", async() => { it("LEEK held by GALAR_FARFETCHD", async () => {
await game.startBattle([ await game.startBattle([
Species.GALAR_FARFETCHD Species.GALAR_FARFETCHD
]); ]);
@ -90,7 +90,7 @@ describe("Items - Leek", () => {
expect(critLevel.value).toBe(2); expect(critLevel.value).toBe(2);
}, 20000); }, 20000);
it("LEEK held by SIRFETCHD", async() => { it("LEEK held by SIRFETCHD", async () => {
await game.startBattle([ await game.startBattle([
Species.SIRFETCHD Species.SIRFETCHD
]); ]);
@ -110,9 +110,9 @@ describe("Items - Leek", () => {
expect(critLevel.value).toBe(2); expect(critLevel.value).toBe(2);
}, 20000); }, 20000);
it("LEEK held by fused FARFETCHD line (base)", async() => { it("LEEK held by fused FARFETCHD line (base)", async () => {
// Randomly choose from the Farfetch'd line // Randomly choose from the Farfetch'd line
const species = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; const species = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD];
await game.startBattle([ await game.startBattle([
species[Utils.randInt(species.length)], species[Utils.randInt(species.length)],
@ -145,9 +145,9 @@ describe("Items - Leek", () => {
expect(critLevel.value).toBe(2); expect(critLevel.value).toBe(2);
}, 20000); }, 20000);
it("LEEK held by fused FARFETCHD line (part)", async() => { it("LEEK held by fused FARFETCHD line (part)", async () => {
// Randomly choose from the Farfetch'd line // Randomly choose from the Farfetch'd line
const species = [ Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD ]; const species = [Species.FARFETCHD, Species.GALAR_FARFETCHD, Species.SIRFETCHD];
await game.startBattle([ await game.startBattle([
Species.PIKACHU, Species.PIKACHU,
@ -180,7 +180,7 @@ describe("Items - Leek", () => {
expect(critLevel.value).toBe(2); expect(critLevel.value).toBe(2);
}, 20000); }, 20000);
it("LEEK not held by FARFETCHD line", async() => { it("LEEK not held by FARFETCHD line", async () => {
await game.startBattle([ await game.startBattle([
Species.PIKACHU Species.PIKACHU
]); ]);

View File

@ -1,12 +1,11 @@
import GameManager from "#test/utils/gameManager"; import { DamagePhase } from "#app/phases/damage-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Items - Leftovers", () => { describe("Items - Leftovers", () => {
@ -32,10 +31,10 @@ describe("Items - Leftovers", () => {
game.override.enemySpecies(Species.SHUCKLE); game.override.enemySpecies(Species.SHUCKLE);
game.override.enemyAbility(Abilities.UNNERVE); game.override.enemyAbility(Abilities.UNNERVE);
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]); game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
game.override.startingHeldItems([{name: "LEFTOVERS", count: 1}]); game.override.startingHeldItems([{ name: "LEFTOVERS", count: 1 }]);
}); });
it("leftovers works", async() => { it("leftovers works", async () => {
await game.startBattle([Species.ARCANINE]); await game.startBattle([Species.ARCANINE]);
// Make sure leftovers are there // Make sure leftovers are there
@ -46,7 +45,7 @@ describe("Items - Leftovers", () => {
// We should have full hp // We should have full hp
expect(leadPokemon.isFullHp()).toBe(true); expect(leadPokemon.isFullHp()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
// We should have less hp after the attack // We should have less hp after the attack
await game.phaseInterceptor.to(DamagePhase, false); await game.phaseInterceptor.to(DamagePhase, false);

View File

@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat";
import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -1,11 +1,10 @@
import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves";
import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { Abilities } from "#app/enums/abilities.js";
import { Moves } from "#app/enums/moves.js";
import { getMovePosition } from "../utils/gameManagerUtils";
import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type.js";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase.js";
describe("Items - Lock Capsule", () => { describe("Items - Lock Capsule", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -29,13 +28,13 @@ describe("Items - Lock Capsule", () => {
.startingLevel(200) .startingLevel(200)
.moveset([Moves.SURF]) .moveset([Moves.SURF])
.enemyAbility(Abilities.BALL_FETCH) .enemyAbility(Abilities.BALL_FETCH)
.startingModifier([{name: "LOCK_CAPSULE"}]); .startingModifier([{ name: "LOCK_CAPSULE" }]);
}); });
it("doesn't set the cost of common tier items to 0", async() => { it("doesn't set the cost of common tier items to 0", async () => {
await game.startBattle(); await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF)); game.move.select(Moves.SURF);
await game.phaseInterceptor.to(SelectModifierPhase, false); await game.phaseInterceptor.to(SelectModifierPhase, false);
const rewards = game.scene.getCurrentPhase() as SelectModifierPhase; const rewards = game.scene.getCurrentPhase() as SelectModifierPhase;

View File

@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat";
import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat";
import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -1,11 +1,11 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { CritBoosterModifier } from "#app/modifier/modifier"; import { CritBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -27,30 +27,30 @@ describe("Items - Scope Lens", () => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override.enemySpecies(Species.MAGIKARP); game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
game.override.disableCrits(); game.override.disableCrits();
game.override.battleType("single"); game.override.battleType("single");
}, 20000); }, 20000);
it("SCOPE_LENS activates in battle correctly", async() => { it("SCOPE_LENS activates in battle correctly", async () => {
game.override.startingHeldItems([{ name: "SCOPE_LENS" }]); game.override.startingHeldItems([{ name: "SCOPE_LENS" }]);
game.override.moveset([ Moves.POUND ]); game.override.moveset([Moves.POUND]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([ await game.startBattle([
Species.GASTLY Species.GASTLY
]); ]);
game.doAttack(0); game.move.select(Moves.POUND);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
expect(consoleSpy).toHaveBeenCalledWith("Applied", "Scope Lens", ""); expect(consoleSpy).toHaveBeenCalledWith("Applied", "Scope Lens", "");
}, 20000); }, 20000);
it("SCOPE_LENS held by random pokemon", async() => { it("SCOPE_LENS held by random pokemon", async () => {
await game.startBattle([ await game.startBattle([
Species.GASTLY Species.GASTLY
]); ]);

View File

@ -2,9 +2,9 @@ import { Stat } from "#app/data/pokemon-stat";
import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils"; import * as Utils from "#app/utils";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser"; import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -1,18 +1,14 @@
import { StatusEffect } from "#app/data/status-effect"; import { StatusEffect } from "#app/data/status-effect";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { MessagePhase } from "#app/phases/message-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import i18next, { initI18n } from "#app/plugins/i18n"; import i18next, { initI18n } from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { CommandPhase } from "#app/phases/command-phase.js";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
import { MessagePhase } from "#app/phases/message-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Items - Toxic orb", () => { describe("Items - Toxic orb", () => {
@ -45,7 +41,7 @@ describe("Items - Toxic orb", () => {
}]); }]);
}); });
it("TOXIC ORB", async() => { it("TOXIC ORB", async () => {
initI18n(); initI18n();
i18next.changeLanguage("en"); i18next.changeLanguage("en");
const moveToUse = Moves.GROWTH; const moveToUse = Moves.GROWTH;
@ -55,15 +51,7 @@ describe("Items - Toxic orb", () => {
]); ]);
expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB"); expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB");
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => { game.move.select(moveToUse);
// Select Attack
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
// Select Move Growth
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
// will run the 13 phase from enemyCommandPhase to TurnEndPhase // will run the 13 phase from enemyCommandPhase to TurnEndPhase
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase);

View File

@ -1,26 +1,25 @@
import { beforeAll, describe, expect, it } from "vitest"; import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat";
import { getBattleStatName, getBattleStatLevelChangeDescription } from "#app/data/battle-stat.js"; import { battle as deBattleStat } from "#app/locales/de/battle";
import { BattleStat} from "#app/data/battle-stat.js"; import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info";
import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info.js"; import { battle as enBattleStat } from "#app/locales/en/battle";
import { battle as enBattleStat } from "#app/locales/en/battle.js"; import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info";
import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info.js"; import { battle as esBattleStat } from "#app/locales/es/battle";
import { battle as deBattleStat } from "#app/locales/de/battle.js"; import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info";
import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info.js"; import { battle as frBattleStat } from "#app/locales/fr/battle";
import { battle as esBattleStat } from "#app/locales/es/battle.js"; import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info";
import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info.js"; import { battle as itBattleStat } from "#app/locales/it/battle";
import { battle as frBattleStat } from "#app/locales/fr/battle.js"; import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info";
import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info.js"; import { battle as koBattleStat } from "#app/locales/ko/battle";
import { battle as itBattleStat } from "#app/locales/it/battle.js"; import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info";
import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info.js"; import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle";
import { battle as koBattleStat } from "#app/locales/ko/battle.js"; import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info";
import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info.js"; import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle";
import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle.js"; import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info";
import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info.js"; import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle";
import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle.js"; import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info";
import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info.js";
import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle.js";
import i18next, { initI18n } from "#app/plugins/i18n"; import i18next, { initI18n } from "#app/plugins/i18n";
import { KoreanPostpositionProcessor } from "i18next-korean-postposition-processor"; import { KoreanPostpositionProcessor } from "i18next-korean-postposition-processor";
import { beforeAll, describe, expect, it } from "vitest";
interface BattleStatTestUnit { interface BattleStatTestUnit {
stat: BattleStat, stat: BattleStat,

View File

@ -1,9 +1,9 @@
import { afterEach, beforeAll, describe, expect, it } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { Species } from "#enums/species";
import i18next from "i18next";
import { initI18n } from "#app/plugins/i18n"; import { initI18n } from "#app/plugins/i18n";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import i18next from "i18next";
import Phaser from "phaser";
import { afterEach, beforeAll, describe, expect, it } from "vitest";
describe("Lokalization - french", () => { describe("Lokalization - french", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;

View File

@ -1,7 +1,7 @@
import { beforeAll, describe, afterEach, expect, it, vi } from "vitest";
import { StatusEffect, getStatusEffectActivationText, getStatusEffectDescriptor, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "#app/data/status-effect"; import { StatusEffect, getStatusEffectActivationText, getStatusEffectDescriptor, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "#app/data/status-effect";
import i18next from "i18next";
import { mockI18next } from "#test/utils/testUtils"; import { mockI18next } from "#test/utils/testUtils";
import i18next from "i18next";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
const pokemonName = "PKM"; const pokemonName = "PKM";
const sourceText = "SOURCE"; const sourceText = "SOURCE";

View File

@ -1,11 +1,11 @@
import { TerrainType, getTerrainName } from "#app/data/terrain"; import { TerrainType, getTerrainName } from "#app/data/terrain";
import { getTerrainBlockMessage, getTerrainClearMessage, getTerrainStartMessage } from "#app/data/weather"; import { getTerrainBlockMessage, getTerrainClearMessage, getTerrainStartMessage } from "#app/data/weather";
import GameManager from "#test/utils/gameManager";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { mockI18next } from "#test/utils/testUtils";
import i18next from "i18next"; import i18next from "i18next";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { mockI18next } from "#test/utils/testUtils";
describe("terrain", () => { describe("terrain", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;

View File

@ -1,16 +1,15 @@
import { allMoves } from "#app/data/move.js"; import { allMoves } from "#app/data/move";
import { BattlerTagType } from "#app/enums/battler-tag-type.js"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { BerryPhase } from "#app/phases/berry-phase";
import { CommandPhase } from "#app/phases/command-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BerryPhase } from "#app/phases/berry-phase.js";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MoveEndPhase } from "#app/phases/move-end-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -50,7 +49,7 @@ describe("Moves - Astonish", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.ASTONISH)); game.move.select(Moves.ASTONISH);
await game.phaseInterceptor.to(MoveEndPhase, false); await game.phaseInterceptor.to(MoveEndPhase, false);
@ -63,7 +62,7 @@ describe("Moves - Astonish", () => {
await game.phaseInterceptor.to(CommandPhase, false); await game.phaseInterceptor.to(CommandPhase, false);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);

View File

@ -1,15 +1,14 @@
import { ArenaTagSide } from "#app/data/arena-tag.js"; import { ArenaTagSide } from "#app/data/arena-tag";
import Move, { allMoves } from "#app/data/move.js"; import Move, { allMoves } from "#app/data/move";
import { WeatherType } from "#app/data/weather.js"; import { WeatherType } from "#app/data/weather";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { ArenaTagType } from "#app/enums/arena-tag-type.js"; import { ArenaTagType } from "#app/enums/arena-tag-type";
import Pokemon from "#app/field/pokemon.js"; import Pokemon from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager"; import { NumberHolder } from "#app/utils";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { NumberHolder } from "#app/utils.js";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -18,7 +17,7 @@ describe("Moves - Aurora Veil", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
const singleBattleMultiplier = 0.5; const singleBattleMultiplier = 0.5;
const doubleBattleMultiplier = 2732/4096; const doubleBattleMultiplier = 2732 / 4096;
beforeAll(() => { beforeAll(() => {
phaserGame = new Phaser.Game({ phaserGame = new Phaser.Game({
@ -42,11 +41,11 @@ describe("Moves - Aurora Veil", () => {
game.override.weather(WeatherType.HAIL); game.override.weather(WeatherType.HAIL);
}); });
it("reduces damage of physical attacks by half in a single battle", async() => { it("reduces damage of physical attacks by half in a single battle", async () => {
const moveToUse = Moves.TACKLE; const moveToUse = Moves.TACKLE;
await game.startBattle([Species.SHUCKLE]); await game.startBattle([Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]);
@ -54,14 +53,14 @@ describe("Moves - Aurora Veil", () => {
expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier);
}); });
it("reduces damage of physical attacks by a third in a double battle", async() => { it("reduces damage of physical attacks by a third in a double battle", async () => {
game.override.battleType("double"); game.override.battleType("double");
const moveToUse = Moves.ROCK_SLIDE; const moveToUse = Moves.ROCK_SLIDE;
await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]); await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
game.doAttack(getMovePosition(game.scene, 1, moveToUse)); game.move.select(moveToUse, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]);
@ -69,11 +68,11 @@ describe("Moves - Aurora Veil", () => {
expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier); expect(mockedDmg).toBe(allMoves[moveToUse].power * doubleBattleMultiplier);
}); });
it("reduces damage of special attacks by half in a single battle", async() => { it("reduces damage of special attacks by half in a single battle", async () => {
const moveToUse = Moves.ABSORB; const moveToUse = Moves.ABSORB;
await game.startBattle([Species.SHUCKLE]); await game.startBattle([Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -82,14 +81,14 @@ describe("Moves - Aurora Veil", () => {
expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier); expect(mockedDmg).toBe(allMoves[moveToUse].power * singleBattleMultiplier);
}); });
it("reduces damage of special attacks by a third in a double battle", async() => { it("reduces damage of special attacks by a third in a double battle", async () => {
game.override.battleType("double"); game.override.battleType("double");
const moveToUse = Moves.DAZZLING_GLEAM; const moveToUse = Moves.DAZZLING_GLEAM;
await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]); await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse)); game.move.select(moveToUse);
game.doAttack(getMovePosition(game.scene, 1, moveToUse)); game.move.select(moveToUse, 1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]); const mockedDmg = getMockedMoveDamage(game.scene.getEnemyPokemon()!, game.scene.getPlayerPokemon()!, allMoves[moveToUse]);

View File

@ -1,13 +1,12 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#app/test/utils/gameManager"; import GameManager from "#app/test/utils/gameManager";
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { PostSummonPhase } from "#app/phases/post-summon-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Moves - Baton Pass", () => { describe("Moves - Baton Pass", () => {
@ -36,7 +35,7 @@ describe("Moves - Baton Pass", () => {
.disableCrits(); .disableCrits();
}); });
it("passes stat stage buffs when player uses it", async() => { it("passes stat stage buffs when player uses it", async () => {
// arrange // arrange
await game.startBattle([ await game.startBattle([
Species.RAICHU, Species.RAICHU,
@ -44,12 +43,12 @@ describe("Moves - Baton Pass", () => {
]); ]);
// round 1 - buff // round 1 - buff
game.doAttack(getMovePosition(game.scene, 0, Moves.NASTY_PLOT)); game.move.select(Moves.NASTY_PLOT);
await game.toNextTurn(); await game.toNextTurn();
expect(game.scene.getPlayerPokemon()!.summonData.battleStats[BattleStat.SPATK]).toEqual(2); expect(game.scene.getPlayerPokemon()!.summonData.battleStats[BattleStat.SPATK]).toEqual(2);
// round 2 - baton pass // round 2 - baton pass
game.doAttack(getMovePosition(game.scene, 0, Moves.BATON_PASS)); game.move.select(Moves.BATON_PASS);
game.doSelectPartyPokemon(1); game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -59,7 +58,7 @@ describe("Moves - Baton Pass", () => {
expect(playerPkm.summonData.battleStats[BattleStat.SPATK]).toEqual(2); expect(playerPkm.summonData.battleStats[BattleStat.SPATK]).toEqual(2);
}, 20000); }, 20000);
it("passes stat stage buffs when AI uses it", async() => { it("passes stat stage buffs when AI uses it", async () => {
// arrange // arrange
game.override game.override
.startingWave(5) .startingWave(5)
@ -70,13 +69,13 @@ describe("Moves - Baton Pass", () => {
]); ]);
// round 1 - ai buffs // round 1 - ai buffs
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.toNextTurn(); await game.toNextTurn();
// round 2 - baton pass // round 2 - baton pass
game.scene.getEnemyPokemon()!.hp = 100; game.scene.getEnemyPokemon()!.hp = 100;
game.override.enemyMoveset(new Array(4).fill(Moves.BATON_PASS)); game.override.enemyMoveset(new Array(4).fill(Moves.BATON_PASS));
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(PostSummonPhase, false); await game.phaseInterceptor.to(PostSummonPhase, false);
// assert // assert

View File

@ -1,15 +1,14 @@
import Phaser from "phaser"; import { BattlerTagType } from "#app/enums/battler-tag-type";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { StatusEffect } from "#app/enums/status-effect";
import GameManager from "#test/utils/gameManager"; import { BerryPhase } from "#app/phases/berry-phase";
import { Species } from "#enums/species"; import { MovePhase } from "#app/phases/move-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { Species } from "#enums/species";
import { BattlerTagType } from "#app/enums/battler-tag-type.js"; import GameManager from "#test/utils/gameManager";
import { StatusEffect } from "#app/enums/status-effect.js"; import Phaser from "phaser";
import { BerryPhase } from "#app/phases/berry-phase.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { MovePhase } from "#app/phases/move-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -48,7 +47,7 @@ describe("Moves - Beak Blast", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); game.move.select(Moves.BEAK_BLAST);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined();
@ -68,7 +67,7 @@ describe("Moves - Beak Blast", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); game.move.select(Moves.BEAK_BLAST);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined();
@ -88,7 +87,7 @@ describe("Moves - Beak Blast", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); game.move.select(Moves.BEAK_BLAST);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined();
@ -101,13 +100,13 @@ describe("Moves - Beak Blast", () => {
it( it(
"should only hit twice with Multi-Lens", "should only hit twice with Multi-Lens",
async () => { async () => {
game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([Species.BLASTOISE]); await game.startBattle([Species.BLASTOISE]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); game.move.select(Moves.BEAK_BLAST);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
expect(leadPokemon.turnData.hitCount).toBe(2); expect(leadPokemon.turnData.hitCount).toBe(2);
@ -124,7 +123,7 @@ describe("Moves - Beak Blast", () => {
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAK_BLAST)); game.move.select(Moves.BEAK_BLAST);
await game.phaseInterceptor.to(MovePhase, false); await game.phaseInterceptor.to(MovePhase, false);
expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined(); expect(leadPokemon.getTag(BattlerTagType.BEAK_BLAST_CHARGING)).toBeDefined();

View File

@ -1,12 +1,11 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { Abilities } from "#app/enums/abilities";
import Phaser from "phaser"; import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species";
import { StatusEffect } from "#app/enums/status-effect";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { Species } from "#app/enums/species.js"; import Phaser from "phaser";
import { Moves } from "#app/enums/moves.js"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { Abilities } from "#app/enums/abilities.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { StatusEffect } from "#app/enums/status-effect.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
const TIMEOUT = 20 * 1000; // 20 sec timeout const TIMEOUT = 20 * 1000; // 20 sec timeout
@ -46,7 +45,7 @@ describe("Moves - Beat Up", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
let enemyStartingHp = enemyPokemon.hp; let enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP)); game.move.select(Moves.BEAT_UP);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
@ -70,7 +69,7 @@ describe("Moves - Beat Up", () => {
game.scene.getParty()[1].trySetStatus(StatusEffect.BURN); game.scene.getParty()[1].trySetStatus(StatusEffect.BURN);
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP)); game.move.select(Moves.BEAT_UP);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);
@ -81,14 +80,14 @@ describe("Moves - Beat Up", () => {
it( it(
"should hit twice for each player Pokemon if the user has Multi-Lens", "should hit twice for each player Pokemon if the user has Multi-Lens",
async () => { async () => {
game.override.startingHeldItems([{name: "MULTI_LENS", count: 1}]); game.override.startingHeldItems([{ name: "MULTI_LENS", count: 1 }]);
await game.startBattle([Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE]); await game.startBattle([Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE]);
const playerPokemon = game.scene.getPlayerPokemon()!; const playerPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
let enemyStartingHp = enemyPokemon.hp; let enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP)); game.move.select(Moves.BEAT_UP);
await game.phaseInterceptor.to(MoveEffectPhase); await game.phaseInterceptor.to(MoveEffectPhase);

View File

@ -1,12 +1,11 @@
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { BattleStat } from "#app/data/battle-stat";
import Phaser from "phaser"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager"; import { toDmgValue } from "#app/utils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { BattleStat } from "#app/data/battle-stat"; import GameManager from "#test/utils/gameManager";
import { toDmgValue } from "#app/utils"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
// RATIO : HP Cost of Move // RATIO : HP Cost of Move
@ -41,13 +40,13 @@ describe("Moves - BELLY DRUM", () => {
// Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Belly_Drum_(move) // Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Belly_Drum_(move)
test("Belly Drum raises the user's Attack to its max, at the cost of 1/2 of its maximum HP", test("Belly Drum raises the user's Attack to its max, at the cost of 1/2 of its maximum HP",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
@ -56,7 +55,7 @@ describe("Moves - BELLY DRUM", () => {
); );
test("Belly Drum will still take effect if an uninvolved stat is at max", test("Belly Drum will still take effect if an uninvolved stat is at max",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
@ -66,7 +65,7 @@ describe("Moves - BELLY DRUM", () => {
leadPokemon.summonData.battleStats[BattleStat.ATK] = -3; leadPokemon.summonData.battleStats[BattleStat.ATK] = -3;
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6; leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6;
game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
@ -76,14 +75,14 @@ describe("Moves - BELLY DRUM", () => {
); );
test("Belly Drum fails if the pokemon's attack stat is at its maximum", test("Belly Drum fails if the pokemon's attack stat is at its maximum",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
leadPokemon.summonData.battleStats[BattleStat.ATK] = 6; leadPokemon.summonData.battleStats[BattleStat.ATK] = 6;
game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
@ -92,14 +91,14 @@ describe("Moves - BELLY DRUM", () => {
); );
test("Belly Drum fails if the user's health is less than 1/2", test("Belly Drum fails if the user's health is less than 1/2",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
leadPokemon.hp = hpLost - PREDAMAGE; leadPokemon.hp = hpLost - PREDAMAGE;
game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM)); game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE);

View File

@ -2,14 +2,13 @@ import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities"; import { Abilities } from "#app/enums/abilities";
import { ArenaTagType } from "#app/enums/arena-tag-type"; import { ArenaTagType } from "#app/enums/arena-tag-type";
import GameManager from "#test/utils/gameManager"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -35,8 +34,8 @@ describe("Moves - Ceaseless Edge", () => {
game.override.enemyPassiveAbility(Abilities.RUN_AWAY); game.override.enemyPassiveAbility(Abilities.RUN_AWAY);
game.override.startingLevel(100); game.override.startingLevel(100);
game.override.enemyLevel(100); game.override.enemyLevel(100);
game.override.moveset([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]); game.override.moveset([Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR]);
game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]); game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100); vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100);
}); });
@ -44,13 +43,13 @@ describe("Moves - Ceaseless Edge", () => {
test( test(
"move should hit and apply spikes", "move should hit and apply spikes",
async () => { async () => {
await game.startBattle([ Species.ILLUMISE ]); await game.startBattle([Species.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE)); game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
// Spikes should not have any layers before move effect is applied // Spikes should not have any layers before move effect is applied
@ -68,14 +67,14 @@ describe("Moves - Ceaseless Edge", () => {
test( test(
"move should hit twice with multi lens and apply two layers of spikes", "move should hit twice with multi lens and apply two layers of spikes",
async () => { async () => {
game.override.startingHeldItems([{name: "MULTI_LENS"}]); game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
await game.startBattle([ Species.ILLUMISE ]); await game.startBattle([Species.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
const enemyStartingHp = enemyPokemon.hp; const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE)); game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
// Spikes should not have any layers before move effect is applied // Spikes should not have any layers before move effect is applied
@ -93,12 +92,12 @@ describe("Moves - Ceaseless Edge", () => {
test( test(
"trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage", "trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage",
async () => { async () => {
game.override.startingHeldItems([{name: "MULTI_LENS"}]); game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
game.override.startingWave(5); game.override.startingWave(5);
await game.startBattle([ Species.ILLUMISE ]); await game.startBattle([Species.ILLUMISE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.CEASELESS_EDGE)); game.move.select(Moves.CEASELESS_EDGE);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
// Spikes should not have any layers before move effect is applied // Spikes should not have any layers before move effect is applied
const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag; const tagBefore = game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY) as ArenaTrapTag;
@ -112,7 +111,7 @@ describe("Moves - Ceaseless Edge", () => {
const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp; const hpBeforeSpikes = game.scene.currentBattle.enemyParty[1].hp;
// Check HP of pokemon that WILL BE switched in (index 1) // Check HP of pokemon that WILL BE switched in (index 1)
game.forceOpponentToSwitch(); game.forceOpponentToSwitch();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH)); game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase, false); await game.phaseInterceptor.to(TurnEndPhase, false);
expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes); expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes);
}, TIMEOUT }, TIMEOUT

View File

@ -1,13 +1,12 @@
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { BattleStat } from "#app/data/battle-stat";
import Phaser from "phaser"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager"; import { toDmgValue } from "#app/utils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { BattleStat } from "#app/data/battle-stat"; import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils";
import { toDmgValue } from "#app/utils"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
/** HP Cost of Move */ /** HP Cost of Move */
@ -42,13 +41,13 @@ describe("Moves - CLANGOROUS_SOUL", () => {
//Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Clangorous_Soul_(move) //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/Clangorous_Soul_(move)
test("Clangorous Soul raises the user's Attack, Defense, Special Attack, Special Defense and Speed by one stage each, at the cost of 1/3 of its maximum HP", test("Clangorous Soul raises the user's Attack, Defense, Special Attack, Special Defense and Speed by one stage each, at the cost of 1/3 of its maximum HP",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); game.move.select(Moves.CLANGOROUS_SOUL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
@ -57,11 +56,11 @@ describe("Moves - CLANGOROUS_SOUL", () => {
expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(1); expect(leadPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(1);
expect(leadPokemon.summonData.battleStats[BattleStat.SPDEF]).toBe(1); expect(leadPokemon.summonData.battleStats[BattleStat.SPDEF]).toBe(1);
expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(1); expect(leadPokemon.summonData.battleStats[BattleStat.SPD]).toBe(1);
}, TIMEOUT }, TIMEOUT
); );
test("Clangorous Soul will still take effect if one or more of the involved stats are not at max", test("Clangorous Soul will still take effect if one or more of the involved stats are not at max",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
@ -73,7 +72,7 @@ describe("Moves - CLANGOROUS_SOUL", () => {
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6; leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6;
leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 4; leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 4;
game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); game.move.select(Moves.CLANGOROUS_SOUL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
@ -86,7 +85,7 @@ describe("Moves - CLANGOROUS_SOUL", () => {
); );
test("Clangorous Soul fails if all stats involved are at max", test("Clangorous Soul fails if all stats involved are at max",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
@ -97,7 +96,7 @@ describe("Moves - CLANGOROUS_SOUL", () => {
leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 6; leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 6;
leadPokemon.summonData.battleStats[BattleStat.SPD] = 6; leadPokemon.summonData.battleStats[BattleStat.SPD] = 6;
game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); game.move.select(Moves.CLANGOROUS_SOUL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
@ -110,14 +109,14 @@ describe("Moves - CLANGOROUS_SOUL", () => {
); );
test("Clangorous Soul fails if the user's health is less than 1/3", test("Clangorous Soul fails if the user's health is less than 1/3",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
leadPokemon.hp = hpLost - PREDAMAGE; leadPokemon.hp = hpLost - PREDAMAGE;
game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL)); game.move.select(Moves.CLANGOROUS_SOUL);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE);

View File

@ -1,14 +1,13 @@
import { BattleStat } from "#app/data/battle-stat";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { BerryPhase } from "#app/phases/berry-phase";
import { CommandPhase } from "#app/phases/command-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import GameManager from "../utils/gameManager"; import GameManager from "../utils/gameManager";
import { Species } from "#enums/species";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { getMovePosition } from "../utils/gameManagerUtils";
import { BattleStat } from "#app/data/battle-stat.js";
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
import { BerryPhase } from "#app/phases/berry-phase.js";
import { CommandPhase } from "#app/phases/command-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -48,11 +47,11 @@ describe("Moves - Crafty Shield", () => {
const leadPokemon = game.scene.getPlayerField(); const leadPokemon = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); game.move.select(Moves.CRAFTY_SHIELD);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -69,11 +68,11 @@ describe("Moves - Crafty Shield", () => {
const leadPokemon = game.scene.getPlayerField(); const leadPokemon = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); game.move.select(Moves.CRAFTY_SHIELD);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -91,11 +90,11 @@ describe("Moves - Crafty Shield", () => {
const leadPokemon = game.scene.getPlayerField(); const leadPokemon = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); game.move.select(Moves.CRAFTY_SHIELD);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH)); game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);
@ -110,11 +109,11 @@ describe("Moves - Crafty Shield", () => {
const leadPokemon = game.scene.getPlayerField(); const leadPokemon = game.scene.getPlayerField();
game.doAttack(getMovePosition(game.scene, 0, Moves.CRAFTY_SHIELD)); game.move.select(Moves.CRAFTY_SHIELD);
await game.phaseInterceptor.to(CommandPhase); await game.phaseInterceptor.to(CommandPhase);
game.doAttack(getMovePosition(game.scene, 1, Moves.SWORDS_DANCE)); game.move.select(Moves.SWORDS_DANCE, 1);
await game.phaseInterceptor.to(BerryPhase, false); await game.phaseInterceptor.to(BerryPhase, false);

View File

@ -1,10 +1,9 @@
import { BattleStat } from "#app/data/battle-stat.js"; import { BattleStat } from "#app/data/battle-stat";
import { Abilities } from "#app/enums/abilities.js"; import { Abilities } from "#app/enums/abilities";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -42,7 +41,7 @@ describe("Moves - Double Team", () => {
vi.spyOn(enemy, "getAccuracyMultiplier"); vi.spyOn(enemy, "getAccuracyMultiplier");
expect(ally.summonData.battleStats[BattleStat.EVA]).toBe(0); expect(ally.summonData.battleStats[BattleStat.EVA]).toBe(0);
game.doAttack(getMovePosition(game.scene, 0, Moves.DOUBLE_TEAM)); game.move.select(Moves.DOUBLE_TEAM);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
await game.toNextTurn(); await game.toNextTurn();

View File

@ -1,17 +1,16 @@
import { BattleStat } from "#app/data/battle-stat"; import { BattleStat } from "#app/data/battle-stat";
import { Type } from "#app/data/type"; import { Type } from "#app/data/type";
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import { modifierTypes } from "#app/modifier/modifier-type"; import { modifierTypes } from "#app/modifier/modifier-type";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
describe("Moves - Dragon Rage", () => { describe("Moves - Dragon Rage", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -62,7 +61,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits(); game.override.disableCrits();
vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([Type.DRAGON]); vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([Type.DRAGON]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -73,7 +72,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits(); game.override.disableCrits();
vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([Type.STEEL]); vi.spyOn(enemyPokemon, "getTypes").mockReturnValue([Type.STEEL]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -84,7 +83,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits(); game.override.disableCrits();
partyPokemon.summonData.battleStats[BattleStat.SPATK] = 2; partyPokemon.summonData.battleStats[BattleStat.SPATK] = 2;
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -95,7 +94,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits(); game.override.disableCrits();
vi.spyOn(partyPokemon, "getTypes").mockReturnValue([Type.DRAGON]); vi.spyOn(partyPokemon, "getTypes").mockReturnValue([Type.DRAGON]);
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -105,7 +104,7 @@ describe("Moves - Dragon Rage", () => {
it("ignores criticals", async () => { it("ignores criticals", async () => {
partyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 99); partyPokemon.addTag(BattlerTagType.ALWAYS_CRIT, 99);
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -116,7 +115,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits(); game.override.disableCrits();
game.override.enemyAbility(Abilities.ICE_SCALES); game.override.enemyAbility(Abilities.ICE_SCALES);
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -127,7 +126,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits(); game.override.disableCrits();
game.scene.addModifier(modifierTypes.MULTI_LENS().newModifier(partyPokemon), false); game.scene.addModifier(modifierTypes.MULTI_LENS().newModifier(partyPokemon), false);
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_RAGE)); game.move.select(Moves.DRAGON_RAGE);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp; const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;

View File

@ -1,16 +1,15 @@
import { allMoves } from "#app/data/move.js"; import { BattlerIndex } from "#app/battle";
import { SPLASH_ONLY } from "../utils/testUtils"; import { allMoves } from "#app/data/move";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { BerryPhase } from "#app/phases/berry-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import GameManager from "../utils/gameManager"; import GameManager from "../utils/gameManager";
import { getMovePosition } from "../utils/gameManagerUtils"; import { SPLASH_ONLY } from "../utils/testUtils";
import { BattlerIndex } from "#app/battle.js";
import { BattleEndPhase } from "#app/phases/battle-end-phase.js";
import { BerryPhase } from "#app/phases/berry-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -46,9 +45,8 @@ describe("Moves - Dragon Tail", () => {
await game.startBattle([Species.DRATINI]); await game.startBattle([Species.DRATINI]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).toBeDefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); game.move.select(Moves.DRAGON_TAIL);
await game.phaseInterceptor.to(BerryPhase); await game.phaseInterceptor.to(BerryPhase);
@ -68,12 +66,9 @@ describe("Moves - Dragon Tail", () => {
await game.startBattle([Species.DRATINI]); await game.startBattle([Species.DRATINI]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).toBeDefined();
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).toBeDefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); game.move.select(Moves.DRAGON_TAIL);
await game.phaseInterceptor.to(BerryPhase); await game.phaseInterceptor.to(BerryPhase);
@ -85,7 +80,7 @@ describe("Moves - Dragon Tail", () => {
); );
test( test(
"Double battles should proceed without crashing" , "Double battles should proceed without crashing",
async () => { async () => {
game.override.battleType("double").enemyMoveset(SPLASH_ONLY); game.override.battleType("double").enemyMoveset(SPLASH_ONLY);
game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]) game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER])
@ -93,19 +88,12 @@ describe("Moves - Dragon Tail", () => {
await game.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]); await game.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]);
const leadPokemon = game.scene.getParty()[0]!; const leadPokemon = game.scene.getParty()[0]!;
const secPokemon = game.scene.getParty()[1]!;
expect(leadPokemon).toBeDefined();
expect(secPokemon).toBeDefined();
const enemyLeadPokemon = game.scene.currentBattle.enemyParty[0]!; const enemyLeadPokemon = game.scene.getEnemyParty()[0]!;
const enemySecPokemon = game.scene.currentBattle.enemyParty[1]!; const enemySecPokemon = game.scene.getEnemyParty()[1]!;
expect(enemyLeadPokemon).toBeDefined();
expect(enemySecPokemon).toBeDefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); game.move.select(Moves.DRAGON_TAIL, 0, BattlerIndex.ENEMY);
game.doSelectTarget(BattlerIndex.ENEMY); game.move.select(Moves.SPLASH, 1);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -117,10 +105,8 @@ describe("Moves - Dragon Tail", () => {
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp()); expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
// second turn // second turn
game.move.select(Moves.FLAMETHROWER, 0, BattlerIndex.ENEMY_2);
game.doAttack(getMovePosition(game.scene, 0, Moves.FLAMETHROWER)); game.move.select(Moves.SPLASH, 1);
game.doSelectTarget(BattlerIndex.ENEMY_2);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
await game.phaseInterceptor.to(BerryPhase); await game.phaseInterceptor.to(BerryPhase);
expect(enemySecPokemon.hp).toBeLessThan(enemySecPokemon.getMaxHp()); expect(enemySecPokemon.hp).toBeLessThan(enemySecPokemon.getMaxHp());
@ -128,7 +114,7 @@ describe("Moves - Dragon Tail", () => {
); );
test( test(
"Flee move redirection works" , "Flee move redirection works",
async () => { async () => {
game.override.battleType("double").enemyMoveset(SPLASH_ONLY); game.override.battleType("double").enemyMoveset(SPLASH_ONLY);
game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]); game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]);
@ -137,20 +123,13 @@ describe("Moves - Dragon Tail", () => {
const leadPokemon = game.scene.getParty()[0]!; const leadPokemon = game.scene.getParty()[0]!;
const secPokemon = game.scene.getParty()[1]!; const secPokemon = game.scene.getParty()[1]!;
expect(leadPokemon).toBeDefined();
expect(secPokemon).toBeDefined();
const enemyLeadPokemon = game.scene.currentBattle.enemyParty[0]!; const enemyLeadPokemon = game.scene.getEnemyParty()[0]!;
const enemySecPokemon = game.scene.currentBattle.enemyParty[1]!; const enemySecPokemon = game.scene.getEnemyParty()[1]!;
expect(enemyLeadPokemon).toBeDefined();
expect(enemySecPokemon).toBeDefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL));
game.doSelectTarget(BattlerIndex.ENEMY);
game.move.select(Moves.DRAGON_TAIL, 0, BattlerIndex.ENEMY);
// target the same pokemon, second move should be redirected after first flees // target the same pokemon, second move should be redirected after first flees
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_TAIL)); game.move.select(Moves.DRAGON_TAIL, 1, BattlerIndex.ENEMY);
game.doSelectTarget(BattlerIndex.ENEMY);
await game.phaseInterceptor.to(BerryPhase); await game.phaseInterceptor.to(BerryPhase);

View File

@ -1,14 +1,12 @@
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move"; import { allMoves } from "#app/data/move";
import GameManager from "#test/utils/gameManager"; import { DamagePhase } from "#app/phases/damage-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import { TurnStartPhase } from "#app/phases/turn-start-phase.js";
describe("Moves - Dynamax Cannon", () => { describe("Moves - Dynamax Cannon", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -29,7 +27,7 @@ describe("Moves - Dynamax Cannon", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
game.override.moveset([ dynamaxCannon.id ]); game.override.moveset([dynamaxCannon.id]);
game.override.startingLevel(200); game.override.startingLevel(200);
// Note that, for Waves 1-10, the level cap is 10 // Note that, for Waves 1-10, the level cap is 10
@ -38,18 +36,18 @@ describe("Moves - Dynamax Cannon", () => {
game.override.disableCrits(); game.override.disableCrits();
game.override.enemySpecies(Species.MAGIKARP); game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyMoveset([ Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH ]); game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
vi.spyOn(dynamaxCannon, "calculateBattlePower"); vi.spyOn(dynamaxCannon, "calculateBattlePower");
}); });
it("should return 100 power against an enemy below level cap", async() => { it("should return 100 power against an enemy below level cap", async () => {
game.override.enemyLevel(1); game.override.enemyLevel(1);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
@ -57,13 +55,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000); }, 20000);
it("should return 100 power against an enemy at level cap", async() => { it("should return 100 power against an enemy at level cap", async () => {
game.override.enemyLevel(10); game.override.enemyLevel(10);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
@ -71,13 +69,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 20000); }, 20000);
it("should return 120 power against an enemy 1% above level cap", async() => { it("should return 120 power against an enemy 1% above level cap", async () => {
game.override.enemyLevel(101); game.override.enemyLevel(101);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -88,13 +86,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120);
}, 20000); }, 20000);
it("should return 140 power against an enemy 2% above level capp", async() => { it("should return 140 power against an enemy 2% above level capp", async () => {
game.override.enemyLevel(102); game.override.enemyLevel(102);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -105,13 +103,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140);
}, 20000); }, 20000);
it("should return 160 power against an enemy 3% above level cap", async() => { it("should return 160 power against an enemy 3% above level cap", async () => {
game.override.enemyLevel(103); game.override.enemyLevel(103);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -122,13 +120,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160);
}, 20000); }, 20000);
it("should return 180 power against an enemy 4% above level cap", async() => { it("should return 180 power against an enemy 4% above level cap", async () => {
game.override.enemyLevel(104); game.override.enemyLevel(104);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -139,13 +137,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180);
}, 20000); }, 20000);
it("should return 200 power against an enemy 5% above level cap", async() => { it("should return 200 power against an enemy 5% above level cap", async () => {
game.override.enemyLevel(105); game.override.enemyLevel(105);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase; const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -156,17 +154,14 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200); expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200);
}, 20000); }, 20000);
it("should return 200 power against an enemy way above level cap", async() => { it("should return 200 power against an enemy way above level cap", async () => {
game.override.enemyLevel(999); game.override.enemyLevel(999);
await game.startBattle([ await game.startBattle([
Species.ETERNATUS, Species.ETERNATUS,
]); ]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id)); game.move.select(dynamaxCannon.id);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(TurnStartPhase, false);
// Force user to act before enemy
vi.spyOn((game.scene.getCurrentPhase() as TurnStartPhase), "getOrder").mockReturnValue([ BattlerIndex.PLAYER, BattlerIndex. ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false); await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id); expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);

View File

@ -1,13 +1,12 @@
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest"; import { BattleStat } from "#app/data/battle-stat";
import Phaser from "phaser"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import GameManager from "#test/utils/gameManager"; import { toDmgValue } from "#app/utils";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import { BattleStat } from "#app/data/battle-stat"; import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils"; import { SPLASH_ONLY } from "#test/utils/testUtils";
import { toDmgValue } from "#app/utils"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
/** HP Cost of Move */ /** HP Cost of Move */
@ -42,13 +41,13 @@ describe("Moves - FILLET AWAY", () => {
//Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/fillet_away_(move) //Bulbapedia Reference: https://bulbapedia.bulbagarden.net/wiki/fillet_away_(move)
test("Fillet Away raises the user's Attack, Special Attack, and Speed by two stages each, at the cost of 1/2 of its maximum HP", test("Fillet Away raises the user's Attack, Special Attack, and Speed by two stages each, at the cost of 1/2 of its maximum HP",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); game.move.select(Moves.FILLET_AWAY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
@ -59,7 +58,7 @@ describe("Moves - FILLET AWAY", () => {
); );
test("Fillet Away will still take effect if one or more of the involved stats are not at max", test("Fillet Away will still take effect if one or more of the involved stats are not at max",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
@ -69,7 +68,7 @@ describe("Moves - FILLET AWAY", () => {
leadPokemon.summonData.battleStats[BattleStat.ATK] = 6; leadPokemon.summonData.battleStats[BattleStat.ATK] = 6;
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 3; leadPokemon.summonData.battleStats[BattleStat.SPATK] = 3;
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); game.move.select(Moves.FILLET_AWAY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp() - hpLost);
@ -80,7 +79,7 @@ describe("Moves - FILLET AWAY", () => {
); );
test("Fillet Away fails if all stats involved are at max", test("Fillet Away fails if all stats involved are at max",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
@ -89,7 +88,7 @@ describe("Moves - FILLET AWAY", () => {
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6; leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6;
leadPokemon.summonData.battleStats[BattleStat.SPD] = 6; leadPokemon.summonData.battleStats[BattleStat.SPD] = 6;
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); game.move.select(Moves.FILLET_AWAY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp()); expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
@ -100,14 +99,14 @@ describe("Moves - FILLET AWAY", () => {
); );
test("Fillet Away fails if the user's health is less than 1/2", test("Fillet Away fails if the user's health is less than 1/2",
async() => { async () => {
await game.startBattle([Species.MAGIKARP]); await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO); const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
leadPokemon.hp = hpLost - PREDAMAGE; leadPokemon.hp = hpLost - PREDAMAGE;
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY)); game.move.select(Moves.FILLET_AWAY);
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE); expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE);

View File

@ -1,15 +1,14 @@
import { BattleStat } from "#app/data/battle-stat"; import { BattleStat } from "#app/data/battle-stat";
import { Species } from "#app/enums/species.js"; import { Species } from "#app/enums/species";
import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; import { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon";
import GameManager from "#test/utils/gameManager"; import { DamagePhase } from "#app/phases/damage-phase";
import { getMovePosition } from "#test/utils/gameManagerUtils"; import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { DamagePhase } from "#app/phases/damage-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
describe("Moves - Fissure", () => { describe("Moves - Fissure", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -57,7 +56,7 @@ describe("Moves - Fissure", () => {
game.override.ability(Abilities.NO_GUARD); game.override.ability(Abilities.NO_GUARD);
game.override.enemyAbility(Abilities.FUR_COAT); game.override.enemyAbility(Abilities.FUR_COAT);
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(DamagePhase, true); await game.phaseInterceptor.to(DamagePhase, true);
expect(enemyPokemon.isFainted()).toBe(true); expect(enemyPokemon.isFainted()).toBe(true);
@ -68,7 +67,7 @@ describe("Moves - Fissure", () => {
enemyPokemon.summonData.battleStats[BattleStat.ACC] = -6; enemyPokemon.summonData.battleStats[BattleStat.ACC] = -6;
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); game.move.select(Moves.FISSURE);
// wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage // wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);
@ -81,7 +80,7 @@ describe("Moves - Fissure", () => {
enemyPokemon.summonData.battleStats[BattleStat.EVA] = 6; enemyPokemon.summonData.battleStats[BattleStat.EVA] = 6;
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE)); game.move.select(Moves.FISSURE);
// wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage // wait for TurnEndPhase instead of DamagePhase as fissure might not actually inflict damage
await game.phaseInterceptor.to(TurnEndPhase); await game.phaseInterceptor.to(TurnEndPhase);

Some files were not shown because too many files have changed in this diff Show More