[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 GameManager from "#test/utils/gameManager";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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", () => {

View File

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

View File

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

View File

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

View File

@ -1,14 +1,13 @@
import { BattleStat } from "#app/data/battle-stat.js";
import { Abilities } from "#app/enums/abilities.js";
import { Moves } from "#app/enums/moves.js";
import { Species } from "#app/enums/species.js";
import { BattleStat } from "#app/data/battle-stat";
import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves";
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 { 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;
@ -44,15 +43,15 @@ describe("Abilities - COSTAR", () => {
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH, 1);
await game.toNextTurn();
expect(leftPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(+2);
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);
game.doSwitchPokemon(2);
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);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(CommandPhase);
game.doSwitchPokemon(2);
await game.phaseInterceptor.to(MessagePhase);

View File

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

View File

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

View File

@ -1,16 +1,15 @@
import { Species } from "#app/enums/species.js";
import GameManager from "#test/utils/gameManager";
import { BattlerIndex } from "#app/battle";
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 { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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", () => {
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);
await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
expect(blissey.hp).toBe(blissey.getMaxHp());
}, 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]);
await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.PROTECT));
game.move.select(Moves.PROTECT);
await game.phaseInterceptor.to(TurnEndPhase);
expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined();
}, 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);
await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.move.forceHit();
await game.phaseInterceptor.to(MovePhase, false);
await game.move.forceHit();
@ -75,25 +74,25 @@ describe("Abilities - Flash Fire", () => {
expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined();
}, 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.statusEffect(StatusEffect.FREEZE);
await game.startBattle([Species.BLISSEY]);
const blissey = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
expect(blissey!.getTag(BattlerTagType.FIRE_BOOST)).toBeDefined();
}, 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]);
await game.startBattle([Species.BLISSEY, Species.CHANSEY]);
// 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]);
game.doSelectPartyPokemon(1);
@ -104,7 +103,7 @@ describe("Abilities - Flash Fire", () => {
expect(chansey!.getTag(BattlerTagType.FIRE_BOOST)).toBeUndefined();
}, 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.enemyAbility(Abilities.FLASH_FIRE).ability(Abilities.NONE);
await game.startBattle([Species.BLISSEY]);
@ -113,7 +112,7 @@ describe("Abilities - Flash Fire", () => {
blissey.hp = initialHP;
// first turn
game.doAttack(getMovePosition(game.scene, 0, Moves.EMBER));
game.move.select(Moves.EMBER);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(TurnEndPhase);
const originalDmg = initialHP - blissey.hp;
@ -122,7 +121,7 @@ describe("Abilities - Flash Fire", () => {
blissey.hp = initialHP;
// second turn
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
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 { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
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", () => {
let phaserGame: Phaser.Game;
@ -30,7 +29,7 @@ describe("Abilities - Gulp Missile", () => {
* @returns The effect damage of Gulp Missile
*/
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(() => {
@ -58,9 +57,9 @@ describe("Abilities - Gulp Missile", () => {
await game.startBattle([Species.CRAMORANT]);
const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE));
game.move.select(Moves.DIVE);
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE));
game.move.select(Moves.DIVE);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getHpRatio()).toBeGreaterThanOrEqual(.5);
@ -75,7 +74,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.49);
expect(cramorant.getHpRatio()).toBe(.49);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined();
@ -86,7 +85,7 @@ describe("Abilities - Gulp Missile", () => {
await game.startBattle([Species.CRAMORANT, Species.MAGIKARP]);
const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.toNextTurn();
game.doSwitchPokemon(1);
@ -101,7 +100,7 @@ describe("Abilities - Gulp Missile", () => {
await game.startBattle([Species.CRAMORANT]);
const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE));
game.move.select(Moves.DIVE);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -115,7 +114,7 @@ describe("Abilities - Gulp Missile", () => {
const enemy = game.scene.getEnemyPokemon()!;
vi.spyOn(enemy, "damageAndUpdate");
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(TurnEndPhase);
expect(enemy.damageAndUpdate).toHaveReturnedWith(getEffectDamage(enemy));
@ -128,7 +127,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!;
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -150,7 +149,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(enemy, "damageAndUpdate");
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -174,7 +173,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(enemy, "damageAndUpdate");
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.45);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_PIKACHU)).toBeDefined();
@ -194,7 +193,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.DIVE));
game.move.select(Moves.DIVE);
await game.phaseInterceptor.to(BerryPhase, false);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -210,7 +209,7 @@ describe("Abilities - Gulp Missile", () => {
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
const enemyHpPreEffect = enemy.hp;
@ -232,7 +231,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!;
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -252,7 +251,7 @@ describe("Abilities - Gulp Missile", () => {
const cramorant = game.scene.getPlayerPokemon()!;
vi.spyOn(cramorant, "getHpRatio").mockReturnValue(.55);
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(MoveEndPhase);
expect(cramorant.getTag(BattlerTagType.GULP_MISSILE_ARROKUDA)).toBeDefined();
@ -269,7 +268,7 @@ describe("Abilities - Gulp Missile", () => {
game.override.enemyAbility(Abilities.TRACE);
await game.startBattle([Species.CRAMORANT]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnStartPhase);
expect(game.scene.getEnemyPokemon()?.hasAbility(Abilities.GULP_MISSILE)).toBe(false);

View File

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

View File

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

View File

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

View File

@ -1,16 +1,15 @@
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
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 { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
let phaserGame: Phaser.Game;
@ -39,7 +38,7 @@ describe("Abilities - Ice Face", () => {
it("takes no damage from physical move and transforms to Noice", async () => {
await game.startBattle([Species.HITMONLEE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEndPhase);
@ -55,7 +54,7 @@ describe("Abilities - Ice Face", () => {
game.override.enemyLevel(1);
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()!;
expect(eiscue.getTag(BattlerTagType.ICE_FACE)).toBeDefined();
@ -81,7 +80,7 @@ describe("Abilities - Ice Face", () => {
it("takes damage from special moves", async () => {
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);
@ -95,7 +94,7 @@ describe("Abilities - Ice Face", () => {
it("takes effects from status moves", async () => {
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);
@ -111,7 +110,7 @@ describe("Abilities - Ice Face", () => {
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);
@ -133,7 +132,7 @@ describe("Abilities - Ice Face", () => {
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);
let eiscue = game.scene.getPlayerPokemon()!;
@ -160,7 +159,7 @@ describe("Abilities - Ice Face", () => {
await game.startBattle([Species.EISCUE]);
game.doAttack(getMovePosition(game.scene, 0, Moves.HAIL));
game.move.select(Moves.HAIL);
const eiscue = game.scene.getPlayerPokemon()!;
await game.phaseInterceptor.to(QuietFormChangePhase);
@ -179,7 +178,7 @@ describe("Abilities - Ice Face", () => {
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);
let eiscue = game.scene.getPlayerPokemon()!;
@ -213,7 +212,7 @@ describe("Abilities - Ice Face", () => {
expect(eiscue.formIndex).toBe(noiceForm);
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.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier();
@ -228,7 +227,7 @@ describe("Abilities - Ice Face", () => {
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);
@ -244,7 +243,7 @@ describe("Abilities - Ice Face", () => {
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);
@ -260,7 +259,7 @@ describe("Abilities - Ice Face", () => {
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);

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

View File

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

View File

@ -1,18 +1,17 @@
import { allMoves } from "#app/data/move.js";
import { Type } from "#app/data/type.js";
import { Weather, WeatherType } from "#app/data/weather.js";
import { PlayerPokemon } from "#app/field/pokemon.js";
import { allMoves } from "#app/data/move";
import { Type } from "#app/data/type";
import { Weather, WeatherType } from "#app/data/weather";
import { PlayerPokemon } from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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;
@ -49,7 +48,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
@ -67,12 +66,12 @@ describe("Abilities - Libero", () => {
let leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
game.doAttack(getMovePosition(game.scene, 0, Moves.AGILITY));
game.move.select(Moves.AGILITY);
await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied.filter((a) => a === Abilities.LIBERO)).toHaveLength(1);
@ -89,7 +88,7 @@ describe("Abilities - Libero", () => {
leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.SPLASH);
@ -108,7 +107,7 @@ describe("Abilities - Libero", () => {
expect(leadPokemon).not.toBe(undefined);
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);
expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO);
@ -131,7 +130,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).toContain(Abilities.LIBERO);
@ -154,7 +153,7 @@ describe("Abilities - Libero", () => {
expect(leadPokemon).not.toBe(undefined);
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);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.AIR_SLASH);
@ -172,7 +171,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.DIG));
game.move.select(Moves.DIG);
await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.DIG);
@ -191,7 +190,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.move.forceMiss();
await game.phaseInterceptor.to(TurnEndPhase);
@ -213,7 +212,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE);
@ -232,7 +231,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TACKLE);
@ -251,7 +250,7 @@ describe("Abilities - Libero", () => {
expect(leadPokemon).not.toBe(undefined);
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);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -271,7 +270,7 @@ describe("Abilities - Libero", () => {
vi.spyOn(leadPokemon, "isTerastallized").mockReturnValue(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -289,7 +288,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE));
game.move.select(Moves.STRUGGLE);
await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -307,7 +306,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
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);
expect(leadPokemon.summonData.abilitiesApplied).not.toContain(Abilities.LIBERO);
@ -326,7 +325,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
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);
testPokemonTypeMatchesDefaultMoveType(leadPokemon, Moves.TRICK_OR_TREAT);
@ -344,7 +343,7 @@ describe("Abilities - Libero", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE));
game.move.select(Moves.CURSE);
await game.phaseInterceptor.to(TurnEndPhase);
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 { 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 { 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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
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
@ -58,7 +57,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).toBeDefined();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
@ -82,7 +81,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
@ -99,14 +98,14 @@ describe("Abilities - Magic Guard", () => {
it(
"ability effect should not persist when the ability is replaced",
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);
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
@ -126,7 +125,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -150,7 +149,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -180,7 +179,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -206,7 +205,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -233,7 +232,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.CURSE));
game.move.select(Moves.CURSE);
const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -257,7 +256,7 @@ describe("Abilities - Magic Guard", () => {
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.phaseInterceptor.to(TurnEndPhase);
@ -276,7 +275,7 @@ describe("Abilities - Magic Guard", () => {
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);
@ -294,7 +293,7 @@ describe("Abilities - Magic Guard", () => {
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.STRUGGLE));
game.move.select(Moves.STRUGGLE);
await game.phaseInterceptor.to(TurnEndPhase);
@ -313,7 +312,7 @@ describe("Abilities - Magic Guard", () => {
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);
@ -329,7 +328,7 @@ describe("Abilities - Magic Guard", () => {
it("Magic Guard does not prevent self-damage from confusion", async () => {
await game.startBattle([Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.CHARM));
game.move.select(Moves.CHARM);
await game.phaseInterceptor.to(TurnEndPhase);
});
@ -341,7 +340,7 @@ describe("Abilities - Magic Guard", () => {
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);
@ -353,7 +352,7 @@ describe("Abilities - Magic Guard", () => {
}, 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
game.override.statusEffect(StatusEffect.SLEEP);
//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()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
@ -378,7 +377,7 @@ describe("Abilities - Magic Guard", () => {
}, 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
game.override.moveset([Moves.TACKLE]);
game.override.enemyAbility(Abilities.AFTERMATH);
@ -390,7 +389,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase);
/**
@ -403,7 +402,7 @@ describe("Abilities - Magic Guard", () => {
}, 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
game.override.moveset([Moves.TACKLE]);
game.override.enemyAbility(Abilities.IRON_BARBS);
@ -414,7 +413,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(TurnEndPhase);
/**
@ -427,7 +426,7 @@ describe("Abilities - Magic Guard", () => {
}, 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
game.override.moveset([Moves.ABSORB]);
game.override.enemyAbility(Abilities.LIQUID_OOZE);
@ -438,7 +437,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.ABSORB));
game.move.select(Moves.ABSORB);
await game.phaseInterceptor.to(TurnEndPhase);
/**
@ -451,14 +450,14 @@ describe("Abilities - Magic Guard", () => {
}, 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
game.override.passiveAbility(Abilities.SOLAR_POWER);
game.override.weather(WeatherType.SUNNY);
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
/**

View File

@ -1,17 +1,13 @@
import { BattleStat } from "#app/data/battle-stat";
import { Stat } from "#app/data/pokemon-stat";
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 { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { VictoryPhase } from "#app/phases/victory-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
@ -37,10 +33,10 @@ describe("Abilities - Moxie", () => {
game.override.ability(Abilities.MOXIE);
game.override.startingLevel(2000);
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;
await game.startBattle([
Species.MIGHTYENA,
@ -50,13 +46,7 @@ describe("Abilities - Moxie", () => {
let battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
expect(battleStatsPokemon[Stat.ATK]).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(VictoryPhase);
battleStatsPokemon = game.scene.getParty()[0].summonData.battleStats;
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 { 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 { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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
**/
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() => {
await game.startBattle([ Species.REGIELEKI ]);
it("will move last in its priority bracket and ignore protective abilities", async () => {
await game.startBattle([Species.REGIELEKI]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyPokemon = game.scene.getEnemyPokemon();
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);
// 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);
}, 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]);
await game.startBattle([ Species.REGIELEKI ]);
await game.startBattle([Species.REGIELEKI]);
const leadIndex = game.scene.getPlayerPokemon()!.getBattlerIndex();
const enemyPokemon = game.scene.getEnemyPokemon();
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);
// 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);
}, 20000);
it("Order is established normally if the Pokemon uses a non-status move", async() => {
await game.startBattle([ Species.REGIELEKI ]);
it("will not affect non-status moves", async () => {
await game.startBattle([Species.REGIELEKI]);
const leadIndex = game.scene.getPlayerPokemon()!.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);
// 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 { StatusEffect } from "#app/data/status-effect.js";
import { Type } from "#app/data/type.js";
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
import { BattleStat } from "#app/data/battle-stat";
import { StatusEffect } from "#app/data/status-effect";
import { Type } from "#app/data/type";
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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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;
@ -61,7 +60,7 @@ describe("Abilities - Parental Bond", () => {
let enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -92,7 +91,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
@ -114,7 +113,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
expect(enemyPokemon.summonData.battleStats[BattleStat.ATK]).toBe(-1);
@ -134,7 +133,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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.phaseInterceptor.to(BerryPhase, false);
@ -156,7 +155,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
@ -177,7 +176,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.ROLLOUT));
game.move.select(Moves.ROLLOUT);
await game.move.forceHit();
await game.phaseInterceptor.to(DamagePhase, false);
@ -201,7 +200,7 @@ describe("Abilities - Parental Bond", () => {
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);
expect(enemyPokemon.hp).toBe(enemyStartingHp - 80);
@ -212,7 +211,7 @@ describe("Abilities - Parental Bond", () => {
"ability should not apply multiplier to counter moves",
async () => {
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]);
@ -225,14 +224,14 @@ describe("Abilities - Parental Bond", () => {
const playerStartingHp = leadPokemon.hp;
const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.COUNTER));
game.move.select(Moves.COUNTER);
await game.phaseInterceptor.to(DamagePhase);
const playerDamage = playerStartingHp - leadPokemon.hp;
await game.phaseInterceptor.to(BerryPhase, false);
expect(enemyPokemon.hp).toBe(enemyStartingHp - 4*playerDamage);
expect(enemyPokemon.hp).toBe(enemyStartingHp - 4 * playerDamage);
}, TIMEOUT
);
@ -252,10 +251,10 @@ describe("Abilities - Parental Bond", () => {
expect(enemyPokemon.length).toBe(2);
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.EARTHQUAKE));
game.move.select(Moves.EARTHQUAKE, 1);
await game.phaseInterceptor.to(BerryPhase, false);
playerPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1));
@ -275,7 +274,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE));
game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(DamagePhase, false);
expect(leadPokemon.turnData.hitCount).toBe(2);
@ -295,7 +294,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
@ -304,7 +303,7 @@ describe("Abilities - Parental Bond", () => {
// This test will time out if the user faints
await game.phaseInterceptor.to(BerryPhase, false);
expect(leadPokemon.hp).toBe(toDmgValue(leadPokemon.getMaxHp()/2));
expect(leadPokemon.hp).toBe(toDmgValue(leadPokemon.getMaxHp() / 2));
}, TIMEOUT
);
@ -321,7 +320,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
@ -339,7 +338,7 @@ describe("Abilities - Parental Bond", () => {
"Moves boosted by this ability and Multi-Lens should strike 4 times",
async () => {
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]);
@ -349,7 +348,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
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",
async () => {
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]);
@ -373,7 +372,7 @@ describe("Abilities - Parental Bond", () => {
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.phaseInterceptor.to(DamagePhase);
@ -390,7 +389,7 @@ describe("Abilities - Parental Bond", () => {
"Seismic Toss boosted by this ability and Multi-Lens should strike twice",
async () => {
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]);
@ -402,7 +401,7 @@ describe("Abilities - Parental Bond", () => {
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.phaseInterceptor.to(DamagePhase);
@ -428,7 +427,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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.phaseInterceptor.to(DamagePhase);
@ -456,7 +455,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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.phaseInterceptor.to(DamagePhase);
@ -486,7 +485,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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.phaseInterceptor.to(DamagePhase);
@ -513,7 +512,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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.phaseInterceptor.to(MoveEffectPhase);
@ -537,7 +536,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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.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",
async () => {
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]);
@ -565,7 +564,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
expect(enemyPokemon).not.toBe(undefined);
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(BerryPhase, false);
@ -587,7 +586,7 @@ describe("Abilities - Parental Bond", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
@ -600,7 +599,7 @@ describe("Abilities - Parental Bond", () => {
async () => {
game.override.battleType("double");
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]);
@ -614,10 +613,10 @@ describe("Abilities - Parental Bond", () => {
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -626,7 +625,7 @@ describe("Abilities - Parental Bond", () => {
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
);

View File

@ -1,15 +1,14 @@
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 { BattlerIndex } from "#app/battle";
import { StatusEffect } from "#app/data/status-effect";
import { Abilities } from "#app/enums/abilities";
import { CommandPhase } from "#app/phases/command-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { StatusEffect } from "#app/data/status-effect.js";
import { allAbilities } from "#app/data/ability.js";
import { Abilities } from "#app/enums/abilities.js";
import { BattlerIndex } from "#app/battle.js";
import { CommandPhase } from "#app/phases/command-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils";
describe("Abilities - Pastel Veil", () => {
let phaserGame: Phaser.Game;
@ -27,50 +26,49 @@ describe("Abilities - Pastel Veil", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("double");
game.override.moveset([Moves.SPLASH]);
game.override.enemyAbility(Abilities.BALL_FETCH);
game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyMoveset([Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD]);
game.override
.battleType("double")
.moveset([Moves.TOXIC_THREAD, Moves.SPLASH])
.enemyAbility(Abilities.BALL_FETCH)
.enemySpecies(Species.SUNKERN)
.enemyMoveset(SPLASH_ONLY);
});
it("prevents the user and its allies from being afflicted by poison", async () => {
await game.startBattle([Species.GALAR_PONYTA, Species.MAGIKARP]);
const ponyta = game.scene.getPlayerField()[0];
vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]);
await game.startBattle([Species.MAGIKARP, Species.GALAR_PONYTA]);
const ponyta = game.scene.getPlayerField()[1];
const magikarp = game.scene.getPlayerField()[0];
ponyta.abilityIndex = 1;
expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.move.select(Moves.TOXIC_THREAD, 1, BattlerIndex.PLAYER);
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 () => {
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.GALAR_PONYTA]);
const ponyta = game.scene.getParty().find(p => p.species.speciesId === Species.GALAR_PONYTA)!;
vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]);
await game.startBattle([Species.MAGIKARP, Species.FEEBAS, Species.GALAR_PONYTA]);
const ponyta = game.scene.getParty()[2];
const magikarp = game.scene.getPlayerField()[0];
ponyta.abilityIndex = 1;
expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.move.select(Moves.TOXIC_THREAD, 1, BattlerIndex.PLAYER);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.getPlayerField().some(p => p.status?.effect === StatusEffect.POISON)).toBe(true);
const poisonedMon = game.scene.getPlayerField().find(p => p.status?.effect === StatusEffect.POISON);
expect(magikarp.status?.effect).toBe(StatusEffect.POISON);
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);
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 { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000;
@ -53,7 +52,7 @@ describe("Abilities - POWER CONSTRUCT", () => {
zygarde!.status = new Status(StatusEffect.FAINT);
expect(zygarde!.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier();

View File

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

View File

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

View File

@ -1,12 +1,11 @@
import { allAbilities, BypassSpeedChanceAbAttr } from "#app/data/ability";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { FaintPhase } from "#app/phases/faint-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
import { FaintPhase } from "#app/phases/faint-phase.js";
describe("Abilities - Quick Draw", () => {
let phaserGame: Phaser.Game;
@ -47,7 +46,7 @@ describe("Abilities - Quick Draw", () => {
pokemon.hp = 1;
enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(FaintPhase, false);
expect(pokemon.isFainted()).toBe(false);
@ -67,7 +66,7 @@ describe("Abilities - Quick Draw", () => {
pokemon.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);
expect(pokemon.isFainted()).toBe(true);
@ -87,7 +86,7 @@ describe("Abilities - Quick Draw", () => {
pokemon.hp = 1;
enemy.hp = 1;
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(FaintPhase, false);
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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
@ -35,21 +34,21 @@ describe("Abilities - Sand Spit", () => {
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));
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.toNextTurn();
expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SANDSTORM);
}, 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));
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, Moves.COIL));
game.move.select(Moves.COIL);
await game.toNextTurn();
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 { BattleStat } from "#app/data/battle-stat.js";
import { WeatherType } from "#app/data/weather.js";
import { BattleStatMultiplierAbAttr, allAbilities } from "#app/data/ability";
import { BattleStat } from "#app/data/battle-stat";
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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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;
@ -64,11 +63,11 @@ describe("Abilities - Sand Veil", () => {
expect(leadPokemon[0].hasAbility(Abilities.SAND_VEIL)).toBe(true);
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase, false);

View File

@ -1,15 +1,14 @@
import { BattleStat } from "#app/data/battle-stat.js";
import { TerrainType } from "#app/data/terrain.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BattleStat } from "#app/data/battle-stat";
import { TerrainType } from "#app/data/terrain";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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
describe("Abilities - Sap Sipper", () => {
@ -32,7 +31,7 @@ describe("Abilities - Sap Sipper", () => {
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 enemyAbility = Abilities.SAP_SIPPER;
@ -45,7 +44,7 @@ describe("Abilities - Sap Sipper", () => {
const startingOppHp = game.scene.currentBattle.enemyParty[0].hp;
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);
@ -53,7 +52,7 @@ describe("Abilities - Sap Sipper", () => {
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 enemyAbility = Abilities.SAP_SIPPER;
@ -64,7 +63,7 @@ describe("Abilities - Sap Sipper", () => {
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);
@ -72,7 +71,7 @@ describe("Abilities - Sap Sipper", () => {
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 enemyAbility = Abilities.SAP_SIPPER;
@ -83,7 +82,7 @@ describe("Abilities - Sap Sipper", () => {
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);
@ -92,7 +91,7 @@ describe("Abilities - Sap Sipper", () => {
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 enemyAbility = Abilities.SAP_SIPPER;
@ -105,7 +104,7 @@ describe("Abilities - Sap Sipper", () => {
const startingOppHp = game.scene.currentBattle.enemyParty[0].hp;
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);
@ -113,7 +112,7 @@ describe("Abilities - Sap Sipper", () => {
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 ability = Abilities.SAP_SIPPER;
@ -125,7 +124,7 @@ describe("Abilities - Sap Sipper", () => {
await game.startBattle();
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(MoveEndPhase);
@ -139,7 +138,7 @@ describe("Abilities - Sap Sipper", () => {
// TODO Add METRONOME outcome override
// 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 enemyAbility = Abilities.SAP_SIPPER;
@ -152,7 +151,7 @@ describe("Abilities - Sap Sipper", () => {
const startingOppHp = game.scene.currentBattle.enemyParty[0].hp;
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);

View File

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

View File

@ -1,13 +1,12 @@
import { ArenaTagType } from "#app/enums/arena-tag-type.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import { PostSummonPhase } from "#app/phases/post-summon-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
let phaserGame: Phaser.Game;
@ -36,7 +35,7 @@ describe("Abilities - Screen Cleaner", () => {
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);
expect(game.scene.arena.getTag(ArenaTagType.AURORA_VEIL)).toBeDefined();
@ -53,7 +52,7 @@ describe("Abilities - Screen Cleaner", () => {
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);
expect(game.scene.arena.getTag(ArenaTagType.LIGHT_SCREEN)).toBeDefined();
@ -70,7 +69,7 @@ describe("Abilities - Screen Cleaner", () => {
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);
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 { Stat } from "#app/data/pokemon-stat";
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 { MoveEffectPhase } from "#app/phases/move-effect-phase";
import * as Utils from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
@ -36,10 +32,10 @@ describe("Abilities - Serene Grace", () => {
game.override.enemySpecies(Species.ONIX);
game.override.startingLevel(100);
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;
await game.startBattle([
Species.PIDGEOT
@ -49,13 +45,7 @@ describe("Abilities - Serene Grace", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -72,7 +62,7 @@ describe("Abilities - Serene Grace", () => {
}, 20000);
it("Move chance with Serene Grace", async() => {
it("Move chance with Serene Grace", async () => {
const moveToUse = Moves.AIR_SLASH;
game.override.ability(Abilities.SERENE_GRACE);
await game.startBattle([
@ -82,13 +72,7 @@ describe("Abilities - Serene Grace", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
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 { Stat } from "#app/data/pokemon-stat";
import { CommandPhase } from "#app/phases/command-phase.js";
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 { MoveEffectPhase } from "#app/phases/move-effect-phase";
import * as Utils from "#app/utils";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BattlerIndex } from "#app/battle.js";
describe("Abilities - Sheer Force", () => {
@ -36,10 +32,10 @@ describe("Abilities - Sheer Force", () => {
game.override.enemySpecies(Species.ONIX);
game.override.startingLevel(100);
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;
game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([
@ -50,13 +46,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.SPDEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -73,12 +63,12 @@ describe("Abilities - Sheer Force", () => {
applyPreAttackAbAttrs(MovePowerBoostAbAttr, phase.getUserPokemon()!, phase.getTarget()!, move, false, power);
expect(chance.value).toBe(0);
expect(power.value).toBe(move.power * 5461/4096);
expect(power.value).toBe(move.power * 5461 / 4096);
}, 20000);
it("Sheer Force with exceptions including binding moves", async() => {
it("Sheer Force with exceptions including binding moves", async () => {
const moveToUse = Moves.BIND;
game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([
@ -89,13 +79,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -117,7 +101,7 @@ describe("Abilities - Sheer Force", () => {
}, 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;
game.override.ability(Abilities.SHEER_FORCE);
await game.startBattle([
@ -128,13 +112,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -156,10 +134,10 @@ describe("Abilities - Sheer Force", () => {
}, 20000);
it("Sheer Force Disabling Specific Abilities", async() => {
it("Sheer Force Disabling Specific Abilities", async () => {
const moveToUse = Moves.CRUSH_CLAW;
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);
await game.startBattle([
Species.PIDGEOT
@ -169,13 +147,7 @@ describe("Abilities - Sheer Force", () => {
game.scene.getEnemyParty()[0].stats[Stat.DEF] = 10000;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
@ -196,7 +168,7 @@ describe("Abilities - Sheer Force", () => {
applyPostDefendAbAttrs(PostDefendTypeChangeAbAttr, target, user, move, target.apply(user, move));
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()[0]).toBe(opponentType);

View File

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

View File

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

View File

@ -1,11 +1,10 @@
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { MovePhase } from "#app/phases/move-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { MovePhase } from "#app/phases/move-phase.js";
describe("Abilities - Stall", () => {
@ -38,13 +37,13 @@ describe("Abilities - Stall", () => {
* https://bulbapedia.bulbagarden.net/wiki/Priority
**/
it("Pokemon with Stall should move last in its priority bracket regardless of speed", async() => {
await game.startBattle([ Species.SHUCKLE ]);
it("Pokemon with Stall should move last in its priority bracket regardless of speed", async () => {
await game.startBattle([Species.SHUCKLE]);
const leadIndex = game.scene.getPlayerPokemon()!.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);
// 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);
}, 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() => {
await game.startBattle([ Species.SHUCKLE ]);
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]);
const leadIndex = game.scene.getPlayerPokemon()!.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);
// 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);
}, 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);
await game.startBattle([ Species.SHUCKLE ]);
await game.startBattle([Species.SHUCKLE]);
const leadIndex = game.scene.getPlayerPokemon()!.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);
// 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 { allMoves } from "#app/data/move.js";
import { Abilities } from "#app/enums/abilities.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { allAbilities } from "#app/data/ability";
import { allMoves } from "#app/data/move";
import { Abilities } from "#app/enums/abilities";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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", () => {
let phaserGame: Phaser.Game;
@ -47,10 +45,8 @@ describe("Abilities - Steely Spirit", () => {
expect(boostSource.hasAbility(Abilities.STEELY_SPIRIT)).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, moveToCheck));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex());
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase);
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);
game.doAttack(getMovePosition(game.scene, 0, moveToCheck));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, moveToCheck));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex());
game.move.select(moveToCheck, 1, enemyToCheck.getBattlerIndex());
await game.phaseInterceptor.to(MoveEffectPhase);
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.summonData.abilitySuppressed).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, moveToCheck));
await game.phaseInterceptor.to(SelectTargetPhase, false);
game.doSelectTarget(enemyToCheck.getBattlerIndex());
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(moveToCheck, 0, enemyToCheck.getBattlerIndex());
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(allMoves[moveToCheck].calculateBattlePower).toHaveReturnedWith(ironHeadPower);

View File

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

View File

@ -1,16 +1,14 @@
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 { BattlerIndex } from "#app/battle";
import { Abilities } from "#app/enums/abilities";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { CommandPhase } from "#app/phases/command-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
import { Abilities } from "#app/enums/abilities.js";
import { BattlerIndex } from "#app/battle.js";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import { CommandPhase } from "#app/phases/command-phase.js";
import { MovePhase } from "#app/phases/move-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Abilities - Sweet Veil", () => {
let phaserGame: Phaser.Game;
@ -29,7 +27,7 @@ describe("Abilities - Sweet Veil", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
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.enemyAbility(Abilities.BALL_FETCH);
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 () => {
await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(TurnEndPhase);
@ -50,8 +48,8 @@ describe("Abilities - Sweet Veil", () => {
game.override.enemyMoveset(SPLASH_ONLY);
await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.REST));
game.move.select(Moves.SPLASH);
game.move.select(Moves.REST, 1);
await game.phaseInterceptor.to(TurnEndPhase);
@ -62,8 +60,8 @@ describe("Abilities - Sweet Veil", () => {
game.override.enemyMoveset([Moves.YAWN, Moves.YAWN, Moves.YAWN, Moves.YAWN]);
await game.startBattle([Species.SWIRLIX, Species.MAGIKARP]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(TurnEndPhase);
@ -74,28 +72,19 @@ describe("Abilities - Sweet Veil", () => {
game.override.enemySpecies(Species.PIKACHU);
game.override.enemyLevel(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]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.move.select(Moves.YAWN, 1, BattlerIndex.PLAYER);
// First pokemon move
await game.move.forceHit();
// Second pokemon move
await game.phaseInterceptor.to(MovePhase, false);
await game.move.forceHit();
await game.phaseInterceptor.to("BerryPhase");
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);
game.doAttack(getMovePosition(game.scene, (drowsyMon.getBattlerIndex() as BattlerIndex.PLAYER | BattlerIndex.PLAYER_2), Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.doSwitchPokemon(2);
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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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;
@ -80,7 +79,7 @@ async function testUnseenFistHitResult(game: GameManager, attackMove: Moves, pro
const enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, attackMove));
game.move.select(attackMove);
await game.phaseInterceptor.to(TurnEndPhase, false);
if (shouldSucceed) {

View File

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

View File

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

View File

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

View File

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

View File

@ -1,26 +1,23 @@
import { BattlerIndex } from "#app/battle";
import { Stat } from "#app/data/pokemon-stat";
import { Status, StatusEffect } from "#app/data/status-effect.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { Command } from "#app/ui/command-ui-handler";
import { Status, StatusEffect } from "#app/data/status-effect";
import { DamagePhase } from "#app/phases/damage-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
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 { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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;
@ -59,13 +56,7 @@ describe("Abilities - ZEN MODE", () => {
game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(DamagePhase, false);
@ -88,13 +79,7 @@ describe("Abilities - ZEN MODE", () => {
game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(QuietFormChangePhase);
@ -114,13 +99,7 @@ describe("Abilities - ZEN MODE", () => {
game.scene.getParty()[0].hp = 100;
expect(game.scene.getParty()[0].formIndex).toBe(0);
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
});
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
const movePosition = getMovePosition(game.scene, 0, moveToUse);
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
});
game.move.select(moveToUse);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to(DamagePhase, false);
@ -169,7 +148,7 @@ describe("Abilities - ZEN MODE", () => {
darmanitan.status = new Status(StatusEffect.FAINT);
expect(darmanitan.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier();

View File

@ -1,11 +1,10 @@
import { Status, StatusEffect } from "#app/data/status-effect.js";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { Status, StatusEffect } from "#app/data/status-effect";
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils";
@ -52,7 +51,7 @@ describe("Abilities - ZERO TO HERO", () => {
palafin2.status = new Status(StatusEffect.FAINT);
expect(palafin2.isFainted()).toBe(true);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.doKillOpponents();
await game.phaseInterceptor.to(TurnEndPhase);
game.doSelectModifier();
@ -80,7 +79,7 @@ describe("Abilities - ZERO TO HERO", () => {
const palafin = game.scene.getPlayerPokemon()!;
expect(palafin.formIndex).toBe(baseForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.killPokemon(palafin);
game.doSelectPartyPokemon(1);
await game.toNextTurn();
@ -97,7 +96,7 @@ describe("Abilities - ZERO TO HERO", () => {
const palafin = game.scene.getPlayerPokemon()!;
expect(palafin.formIndex).toBe(heroForm);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.killPokemon(palafin);
game.doSelectPartyPokemon(1);
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 { initLoggedInUser, loggedInUser, updateUserInfo } from "../account";
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 { IntegerHolder, NumberHolder } from "#app/utils";
import GameManager from "#test/utils/gameManager";
import { IntegerHolder, NumberHolder } from "#app/utils.js";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
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 { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "../utils/testUtils";
@ -45,14 +44,14 @@ describe("Arena - Gravity", () => {
// Setup Gravity on first turn
await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY));
game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use non-OHKO move on second turn
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.TACKLE));
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(100 * 1.67);
@ -69,14 +68,14 @@ describe("Arena - Gravity", () => {
// Setup Gravity on first turn
await game.startBattle([Species.PIKACHU]);
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY));
game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use OHKO move on second turn
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.FISSURE));
game.move.select(Moves.FISSURE);
await game.phaseInterceptor.to(MoveEffectPhase);
expect(moveToCheck.calculateBattleAccuracy).toHaveReturnedWith(30);
@ -96,21 +95,21 @@ describe("Arena - Gravity", () => {
vi.spyOn(pidgeot, "getAttackTypeEffectiveness");
// Try earthquake on 1st turn (fails!);
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE));
game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(TurnEndPhase);
expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(0);
// Setup Gravity on 2nd turn
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY));
game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use ground move on 3rd turn
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.EARTHQUAKE));
game.move.select(Moves.EARTHQUAKE);
await game.phaseInterceptor.to(TurnEndPhase);
expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(1);
@ -129,14 +128,14 @@ describe("Arena - Gravity", () => {
vi.spyOn(pidgeot, "getAttackTypeEffectiveness");
// Setup Gravity on 1st turn
game.doAttack(getMovePosition(game.scene, 0, Moves.GRAVITY));
game.move.select(Moves.GRAVITY);
await game.phaseInterceptor.to(TurnEndPhase);
expect(game.scene.arena.getTag(ArenaTagType.GRAVITY)).toBeDefined();
// Use electric move on 2nd turn
await game.toNextTurn();
game.doAttack(getMovePosition(game.scene, 0, Moves.THUNDERBOLT));
game.move.select(Moves.THUNDERBOLT);
await game.phaseInterceptor.to(TurnEndPhase);
expect(pidgeot.getAttackTypeEffectiveness).toHaveReturnedWith(2);

View File

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

View File

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

View File

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

View File

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

View File

@ -1,14 +1,13 @@
import { DamagePhase } from "#app/phases/damage-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { toDmgValue } from "#app/utils";
import { Abilities } from "#enums/abilities";
import { ArenaTagType } from "#enums/arena-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 Phaser from "phaser";
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", () => {
let phaserGame: Phaser.Game;
@ -41,7 +40,7 @@ describe("Round Down and Minimun 1 test in Damage Calculation", () => {
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);

View File

@ -1,13 +1,12 @@
import GameManager from "#test/utils/gameManager";
import { getMovePosition, } from "#test/utils/gameManagerUtils";
import { Status, StatusEffect } from "#app/data/status-effect";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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", () => {
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.
// (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);
await game.startBattle([
Species.BULBASAUR,
@ -37,8 +36,8 @@ describe("Double Battles", () => {
Species.SQUIRTLE,
]);
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
for (const pokemon of game.scene.getPlayerField()) {
pokemon.hp = 0;

View File

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

View File

@ -1,9 +1,9 @@
import { CommandPhase } from "#app/phases/command-phase.js";
import GameManager from "#test/utils/gameManager";
import { CommandPhase } from "#app/phases/command-phase";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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 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");

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 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(() => {
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 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", () => {
let phaserGame: Phaser.Game;

View File

@ -1,6 +1,6 @@
import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions.js";
import { Abilities } from "#app/enums/abilities.js";
import { Species } from "#app/enums/species.js";
import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions";
import { Abilities } from "#app/enums/abilities";
import { Species } from "#app/enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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 { 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", () => {
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 GameManager from "../utils/gameManager";

View File

@ -1,8 +1,8 @@
import { Biome } from "#app/enums/biome.js";
import { Species } from "#app/enums/species.js";
import { Biome } from "#app/enums/biome";
import { Species } from "#app/enums/species";
import { GameModes } from "#app/game-mode";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "./utils/gameManager";
import { GameModes } from "#app/game-mode";
const FinalWave = {
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 GameManager from "./utils/gameManager";
import * as Utils from "../utils";
import GameManager from "./utils/gameManager";
describe("game-mode", () => {
let phaserGame: Phaser.Game;
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 { describe, expect, it } from "vitest";
async function importModule() {
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 pad_xbox360 from "#app/configs/inputs/pad_xbox360";
import GameManager from "#test/utils/gameManager";
import InputsHandler from "#test/utils/inputsHandler";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Inputs", () => {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,11 @@
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { DamagePhase } from "#app/phases/damage-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
@ -32,10 +31,10 @@ describe("Items - Leftovers", () => {
game.override.enemySpecies(Species.SHUCKLE);
game.override.enemyAbility(Abilities.UNNERVE);
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]);
// Make sure leftovers are there
@ -46,7 +45,7 @@ describe("Items - Leftovers", () => {
// We should have full hp
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
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 { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser";
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 Phase from "phaser";
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", () => {
let phaserGame: Phaser.Game;
@ -29,13 +28,13 @@ describe("Items - Lock Capsule", () => {
.startingLevel(200)
.moveset([Moves.SURF])
.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();
game.doAttack(getMovePosition(game.scene, 0, Moves.SURF));
game.move.select(Moves.SURF);
await game.phaseInterceptor.to(SelectModifierPhase, false);
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 { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser";
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 { modifierTypes } from "#app/modifier/modifier-type";
import i18next from "#app/plugins/i18n";
import GameManager from "#test/utils/gameManager";
import * as Utils from "#app/utils";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

View File

@ -1,11 +1,11 @@
import { BattlerIndex } from "#app/battle";
import { CritBoosterModifier } from "#app/modifier/modifier";
import { modifierTypes } from "#app/modifier/modifier-type";
import { MoveEffectPhase } from "#app/phases/move-effect-phase.js";
import GameManager from "#test/utils/gameManager";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import * as Utils from "#app/utils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phase from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
@ -27,30 +27,30 @@ describe("Items - Scope Lens", () => {
game = new GameManager(phaserGame);
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.battleType("single");
}, 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.moveset([ Moves.POUND ]);
game.override.moveset([Moves.POUND]);
const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([
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);
expect(consoleSpy).toHaveBeenCalledWith("Applied", "Scope Lens", "");
}, 20000);
it("SCOPE_LENS held by random pokemon", async() => {
it("SCOPE_LENS held by random pokemon", async () => {
await game.startBattle([
Species.GASTLY
]);

View File

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

View File

@ -1,18 +1,14 @@
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 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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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", () => {
@ -45,7 +41,7 @@ describe("Items - Toxic orb", () => {
}]);
});
it("TOXIC ORB", async() => {
it("TOXIC ORB", async () => {
initI18n();
i18next.changeLanguage("en");
const moveToUse = Moves.GROWTH;
@ -55,15 +51,7 @@ describe("Items - Toxic orb", () => {
]);
expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB");
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
// 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);
});
game.move.select(moveToUse);
// will run the 13 phase from enemyCommandPhase to TurnEndPhase
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase);

View File

@ -1,26 +1,25 @@
import { beforeAll, describe, expect, it } from "vitest";
import { getBattleStatName, getBattleStatLevelChangeDescription } from "#app/data/battle-stat.js";
import { BattleStat} from "#app/data/battle-stat.js";
import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info.js";
import { battle as enBattleStat } from "#app/locales/en/battle.js";
import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info.js";
import { battle as deBattleStat } from "#app/locales/de/battle.js";
import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info.js";
import { battle as esBattleStat } from "#app/locales/es/battle.js";
import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info.js";
import { battle as frBattleStat } from "#app/locales/fr/battle.js";
import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info.js";
import { battle as itBattleStat } from "#app/locales/it/battle.js";
import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info.js";
import { battle as koBattleStat } from "#app/locales/ko/battle.js";
import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info.js";
import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle.js";
import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info.js";
import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle.js";
import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info.js";
import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle.js";
import { BattleStat, getBattleStatLevelChangeDescription, getBattleStatName } from "#app/data/battle-stat";
import { battle as deBattleStat } from "#app/locales/de/battle";
import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info";
import { battle as enBattleStat } from "#app/locales/en/battle";
import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info";
import { battle as esBattleStat } from "#app/locales/es/battle";
import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info";
import { battle as frBattleStat } from "#app/locales/fr/battle";
import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info";
import { battle as itBattleStat } from "#app/locales/it/battle";
import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info";
import { battle as koBattleStat } from "#app/locales/ko/battle";
import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info";
import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle";
import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info";
import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle";
import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info";
import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle";
import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info";
import i18next, { initI18n } from "#app/plugins/i18n";
import { KoreanPostpositionProcessor } from "i18next-korean-postposition-processor";
import { beforeAll, describe, expect, it } from "vitest";
interface BattleStatTestUnit {
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 { 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", () => {
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 i18next from "i18next";
import { mockI18next } from "#test/utils/testUtils";
import i18next from "i18next";
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
const pokemonName = "PKM";
const sourceText = "SOURCE";

View File

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

View File

@ -1,16 +1,15 @@
import { allMoves } from "#app/data/move.js";
import { BattlerTagType } from "#app/enums/battler-tag-type.js";
import { allMoves } from "#app/data/move";
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 { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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;
@ -50,7 +49,7 @@ describe("Moves - Astonish", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.doAttack(getMovePosition(game.scene, 0, Moves.ASTONISH));
game.move.select(Moves.ASTONISH);
await game.phaseInterceptor.to(MoveEndPhase, false);
@ -63,7 +62,7 @@ describe("Moves - Astonish", () => {
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);

View File

@ -1,15 +1,14 @@
import { ArenaTagSide } from "#app/data/arena-tag.js";
import Move, { allMoves } from "#app/data/move.js";
import { WeatherType } from "#app/data/weather.js";
import { Abilities } from "#app/enums/abilities.js";
import { ArenaTagType } from "#app/enums/arena-tag-type.js";
import Pokemon from "#app/field/pokemon.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { NumberHolder } from "#app/utils.js";
import { ArenaTagSide } from "#app/data/arena-tag";
import Move, { allMoves } from "#app/data/move";
import { WeatherType } from "#app/data/weather";
import { Abilities } from "#app/enums/abilities";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import Pokemon from "#app/field/pokemon";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { NumberHolder } from "#app/utils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@ -18,7 +17,7 @@ describe("Moves - Aurora Veil", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const singleBattleMultiplier = 0.5;
const doubleBattleMultiplier = 2732/4096;
const doubleBattleMultiplier = 2732 / 4096;
beforeAll(() => {
phaserGame = new Phaser.Game({
@ -42,11 +41,11 @@ describe("Moves - Aurora Veil", () => {
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;
await game.startBattle([Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);
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);
});
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");
const moveToUse = Moves.ROCK_SLIDE;
await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.doAttack(getMovePosition(game.scene, 1, moveToUse));
game.move.select(moveToUse);
game.move.select(moveToUse, 1);
await game.phaseInterceptor.to(TurnEndPhase);
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);
});
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;
await game.startBattle([Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.move.select(moveToUse);
await game.phaseInterceptor.to(TurnEndPhase);
@ -82,14 +81,14 @@ describe("Moves - Aurora Veil", () => {
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");
const moveToUse = Moves.DAZZLING_GLEAM;
await game.startBattle([Species.SHUCKLE, Species.SHUCKLE]);
game.doAttack(getMovePosition(game.scene, 0, moveToUse));
game.doAttack(getMovePosition(game.scene, 1, moveToUse));
game.move.select(moveToUse);
game.move.select(moveToUse, 1);
await game.phaseInterceptor.to(TurnEndPhase);
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 { getMovePosition } from "#app/test/utils/gameManagerUtils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
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", () => {
@ -36,7 +35,7 @@ describe("Moves - Baton Pass", () => {
.disableCrits();
});
it("passes stat stage buffs when player uses it", async() => {
it("passes stat stage buffs when player uses it", async () => {
// arrange
await game.startBattle([
Species.RAICHU,
@ -44,12 +43,12 @@ describe("Moves - Baton Pass", () => {
]);
// round 1 - buff
game.doAttack(getMovePosition(game.scene, 0, Moves.NASTY_PLOT));
game.move.select(Moves.NASTY_PLOT);
await game.toNextTurn();
expect(game.scene.getPlayerPokemon()!.summonData.battleStats[BattleStat.SPATK]).toEqual(2);
// round 2 - baton pass
game.doAttack(getMovePosition(game.scene, 0, Moves.BATON_PASS));
game.move.select(Moves.BATON_PASS);
game.doSelectPartyPokemon(1);
await game.phaseInterceptor.to(TurnEndPhase);
@ -59,7 +58,7 @@ describe("Moves - Baton Pass", () => {
expect(playerPkm.summonData.battleStats[BattleStat.SPATK]).toEqual(2);
}, 20000);
it("passes stat stage buffs when AI uses it", async() => {
it("passes stat stage buffs when AI uses it", async () => {
// arrange
game.override
.startingWave(5)
@ -70,13 +69,13 @@ describe("Moves - Baton Pass", () => {
]);
// round 1 - ai buffs
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.toNextTurn();
// round 2 - baton pass
game.scene.getEnemyPokemon()!.hp = 100;
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);
// assert

View File

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

View File

@ -1,12 +1,11 @@
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import Phaser from "phaser";
import { Abilities } from "#app/enums/abilities";
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 { Species } from "#app/enums/species.js";
import { Moves } from "#app/enums/moves.js";
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";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
const TIMEOUT = 20 * 1000; // 20 sec timeout
@ -46,7 +45,7 @@ describe("Moves - Beat Up", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
let enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP));
game.move.select(Moves.BEAT_UP);
await game.phaseInterceptor.to(MoveEffectPhase);
@ -70,7 +69,7 @@ describe("Moves - Beat Up", () => {
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);
@ -81,14 +80,14 @@ describe("Moves - Beat Up", () => {
it(
"should hit twice for each player Pokemon if the user has Multi-Lens",
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]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!;
let enemyStartingHp = enemyPokemon.hp;
game.doAttack(getMovePosition(game.scene, 0, Moves.BEAT_UP));
game.move.select(Moves.BEAT_UP);
await game.phaseInterceptor.to(MoveEffectPhase);

View File

@ -1,12 +1,11 @@
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BattleStat } from "#app/data/battle-stat";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { toDmgValue } from "#app/utils";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import { BattleStat } from "#app/data/battle-stat";
import { toDmgValue } from "#app/utils";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000;
// RATIO : HP Cost of Move
@ -41,13 +40,13 @@ describe("Moves - BELLY DRUM", () => {
// 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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
@ -66,7 +65,7 @@ describe("Moves - BELLY DRUM", () => {
leadPokemon.summonData.battleStats[BattleStat.ATK] = -3;
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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
leadPokemon.hp = hpLost - PREDAMAGE;
game.doAttack(getMovePosition(game.scene, 0, Moves.BELLY_DRUM));
game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to(TurnEndPhase);
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 { Abilities } from "#app/enums/abilities";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
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;
@ -35,8 +34,8 @@ describe("Moves - Ceaseless Edge", () => {
game.override.enemyPassiveAbility(Abilities.RUN_AWAY);
game.override.startingLevel(100);
game.override.enemyLevel(100);
game.override.moveset([ Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR ]);
game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]);
game.override.moveset([Moves.CEASELESS_EDGE, Moves.SPLASH, Moves.ROAR]);
game.override.enemyMoveset([Moves.SPLASH, Moves.SPLASH, Moves.SPLASH, Moves.SPLASH]);
vi.spyOn(allMoves[Moves.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100);
});
@ -44,13 +43,13 @@ describe("Moves - Ceaseless Edge", () => {
test(
"move should hit and apply spikes",
async () => {
await game.startBattle([ Species.ILLUMISE ]);
await game.startBattle([Species.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
// Spikes should not have any layers before move effect is applied
@ -68,14 +67,14 @@ describe("Moves - Ceaseless Edge", () => {
test(
"move should hit twice with multi lens and apply two layers of spikes",
async () => {
game.override.startingHeldItems([{name: "MULTI_LENS"}]);
await game.startBattle([ Species.ILLUMISE ]);
game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
await game.startBattle([Species.ILLUMISE]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
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);
// Spikes should not have any layers before move effect is applied
@ -93,12 +92,12 @@ describe("Moves - Ceaseless Edge", () => {
test(
"trainer - move should hit twice, apply two layers of spikes, force switch opponent - opponent takes damage",
async () => {
game.override.startingHeldItems([{name: "MULTI_LENS"}]);
game.override.startingHeldItems([{ name: "MULTI_LENS" }]);
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);
// Spikes should not have any layers before move effect is applied
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;
// Check HP of pokemon that WILL BE switched in (index 1)
game.forceOpponentToSwitch();
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase, false);
expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(hpBeforeSpikes);
}, TIMEOUT

View File

@ -1,13 +1,12 @@
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
import Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BattleStat } from "#app/data/battle-stat";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { toDmgValue } from "#app/utils";
import { Moves } from "#enums/moves";
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 { toDmgValue } from "#app/utils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000;
/** HP Cost of Move */
@ -42,13 +41,13 @@ describe("Moves - CLANGOROUS_SOUL", () => {
//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",
async() => {
await game.startBattle([Species.MAGIKARP]);
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
const leadPokemon = game.scene.getPlayerPokemon()!;
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);
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.SPDEF]).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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
@ -73,7 +72,7 @@ describe("Moves - CLANGOROUS_SOUL", () => {
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 6;
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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
@ -97,7 +96,7 @@ describe("Moves - CLANGOROUS_SOUL", () => {
leadPokemon.summonData.battleStats[BattleStat.SPDEF] = 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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
leadPokemon.hp = hpLost - PREDAMAGE;
game.doAttack(getMovePosition(game.scene, 0, Moves.CLANGOROUS_SOUL));
game.move.select(Moves.CLANGOROUS_SOUL);
await game.phaseInterceptor.to(TurnEndPhase);
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 { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
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;
@ -48,11 +47,11 @@ describe("Moves - Crafty Shield", () => {
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false);
@ -69,11 +68,11 @@ describe("Moves - Crafty Shield", () => {
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false);
@ -91,11 +90,11 @@ describe("Moves - Crafty Shield", () => {
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
game.move.select(Moves.SPLASH, 1);
await game.phaseInterceptor.to(BerryPhase, false);
@ -110,11 +109,11 @@ describe("Moves - Crafty Shield", () => {
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);
game.doAttack(getMovePosition(game.scene, 1, Moves.SWORDS_DANCE));
game.move.select(Moves.SWORDS_DANCE, 1);
await game.phaseInterceptor.to(BerryPhase, false);

View File

@ -1,10 +1,9 @@
import { BattleStat } from "#app/data/battle-stat.js";
import { Abilities } from "#app/enums/abilities.js";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BattleStat } from "#app/data/battle-stat";
import { Abilities } from "#app/enums/abilities";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Moves } from "#enums/moves";
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";
@ -42,7 +41,7 @@ describe("Moves - Double Team", () => {
vi.spyOn(enemy, "getAccuracyMultiplier");
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.toNextTurn();

View File

@ -1,17 +1,16 @@
import { BattleStat } from "#app/data/battle-stat";
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 { modifierTypes } from "#app/modifier/modifier-type";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { BattlerTagType } from "#enums/battler-tag-type";
import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { SPLASH_ONLY } from "#test/utils/testUtils";
describe("Moves - Dragon Rage", () => {
let phaserGame: Phaser.Game;
@ -62,7 +61,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits();
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -73,7 +72,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits();
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -84,7 +83,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits();
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -95,7 +94,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits();
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -105,7 +104,7 @@ describe("Moves - Dragon Rage", () => {
it("ignores criticals", async () => {
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -116,7 +115,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits();
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;
@ -127,7 +126,7 @@ describe("Moves - Dragon Rage", () => {
game.override.disableCrits();
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);
const damageDealt = enemyPokemon.getMaxHp() - enemyPokemon.hp;

View File

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

View File

@ -1,14 +1,12 @@
import { BattlerIndex } from "#app/battle";
import { allMoves } from "#app/data/move";
import GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { DamagePhase } from "#app/phases/damage-phase";
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
import { Moves } from "#enums/moves";
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 { 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", () => {
let phaserGame: Phaser.Game;
@ -29,7 +27,7 @@ describe("Moves - Dynamax Cannon", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.moveset([ dynamaxCannon.id ]);
game.override.moveset([dynamaxCannon.id]);
game.override.startingLevel(200);
// Note that, for Waves 1-10, the level cap is 10
@ -38,18 +36,18 @@ describe("Moves - Dynamax Cannon", () => {
game.override.disableCrits();
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");
});
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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
@ -57,13 +55,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
expect((game.scene.getCurrentPhase() as MoveEffectPhase).move.moveId).toBe(dynamaxCannon.id);
@ -71,13 +69,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(100);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -88,13 +86,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(120);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -105,13 +103,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(140);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -122,13 +120,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(160);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -139,13 +137,13 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(180);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
game.move.select(dynamaxCannon.id);
await game.phaseInterceptor.to(MoveEffectPhase, false);
const phase = game.scene.getCurrentPhase() as MoveEffectPhase;
@ -156,17 +154,14 @@ describe("Moves - Dynamax Cannon", () => {
expect(dynamaxCannon.calculateBattlePower).toHaveLastReturnedWith(200);
}, 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);
await game.startBattle([
Species.ETERNATUS,
]);
game.doAttack(getMovePosition(game.scene, 0, dynamaxCannon.id));
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]);
game.move.select(dynamaxCannon.id);
await game.setTurnOrder([BattlerIndex.PLAYER, BattlerIndex.ENEMY]);
await game.phaseInterceptor.to(MoveEffectPhase, false);
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 Phaser from "phaser";
import GameManager from "#test/utils/gameManager";
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { BattleStat } from "#app/data/battle-stat";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { toDmgValue } from "#app/utils";
import { Moves } from "#enums/moves";
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 { toDmgValue } from "#app/utils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
const TIMEOUT = 20 * 1000;
/** HP Cost of Move */
@ -42,13 +41,13 @@ describe("Moves - FILLET AWAY", () => {
//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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
@ -69,7 +68,7 @@ describe("Moves - FILLET AWAY", () => {
leadPokemon.summonData.battleStats[BattleStat.ATK] = 6;
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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
@ -89,7 +88,7 @@ describe("Moves - FILLET AWAY", () => {
leadPokemon.summonData.battleStats[BattleStat.SPATK] = 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);
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",
async() => {
async () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
const hpLost = toDmgValue(leadPokemon.getMaxHp() / RATIO);
leadPokemon.hp = hpLost - PREDAMAGE;
game.doAttack(getMovePosition(game.scene, 0, Moves.FILLET_AWAY));
game.move.select(Moves.FILLET_AWAY);
await game.phaseInterceptor.to(TurnEndPhase);
expect(leadPokemon.hp).toBe(hpLost - PREDAMAGE);

View File

@ -1,15 +1,14 @@
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 GameManager from "#test/utils/gameManager";
import { getMovePosition } from "#test/utils/gameManagerUtils";
import { DamagePhase } from "#app/phases/damage-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
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", () => {
let phaserGame: Phaser.Game;
@ -57,7 +56,7 @@ describe("Moves - Fissure", () => {
game.override.ability(Abilities.NO_GUARD);
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);
expect(enemyPokemon.isFainted()).toBe(true);
@ -68,7 +67,7 @@ describe("Moves - Fissure", () => {
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
await game.phaseInterceptor.to(TurnEndPhase);
@ -81,7 +80,7 @@ describe("Moves - Fissure", () => {
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
await game.phaseInterceptor.to(TurnEndPhase);

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