Reverted accidental changes

This commit is contained in:
Bertie690 2025-05-30 19:26:09 -04:00
parent 2978b78510
commit e867d00c69
2 changed files with 133 additions and 119 deletions

View File

@ -1,12 +1,11 @@
import { BattlerIndex } from "#app/battle";
import { ArenaTagSide, getArenaTag } from "#app/data/arena-tag";
import { getStatusEffectCatchRateMultiplier } from "#app/data/status-effect";
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 { Stat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import { WeatherType } from "#enums/weather-type";
import GameManager from "#test/testUtils/gameManager";
@ -56,7 +55,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -67,36 +66,9 @@ describe("Abilities - Magic Guard", () => {
expect(enemyPokemon.hp).toBeLessThan(enemyPokemon.getMaxHp());
});
it("should retain catch boost, toxic turn count and burn attack drops", async () => {
game.override.statusEffect(StatusEffect.TOXIC);
await game.classicMode.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase");
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
expect(leadPokemon.status).toBeTruthy();
expect(leadPokemon.status!.toxicTurnCount).toBeGreaterThan(0);
expect(getStatusEffectCatchRateMultiplier(leadPokemon.status!.effect)).toBe(1.5);
await game.toNextTurn();
// give ourselves burn and ensure our attack indeed dropped
const prevAtk = leadPokemon.getEffectiveStat(Stat.ATK);
leadPokemon.resetStatus();
expect(leadPokemon.status).toBeFalsy();
leadPokemon.trySetStatus(StatusEffect.BURN);
expect(leadPokemon.status).toBeTruthy();
const burntAtk = leadPokemon.getEffectiveStat(Stat.ATK);
expect(burntAtk).toBeCloseTo(prevAtk / 2, 1);
});
it("ability effect should not persist when the ability is replaced", async () => {
game.override.enemyMoveset(Moves.WORRY_SEED).statusEffect(StatusEffect.POISON);
it("ability should prevent damage caused by status effects but other non-damage effects still apply", async () => {
//Toxic keeps track of the turn counters -> important that Magic Guard keeps track of post-Toxic turns
game.override.statusEffect(StatusEffect.POISON);
await game.startBattle([Species.MAGIKARP]);
@ -104,7 +76,28 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
* - The player Pokemon (with Magic Guard) has not taken damage from poison
* - The Pokemon's CatchRateMultiplier should be 1.5
*/
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
expect(getStatusEffectCatchRateMultiplier(leadPokemon.status!.effect)).toBe(1.5);
});
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.statusEffect(StatusEffect.POISON);
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -123,7 +116,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -148,7 +141,7 @@ describe("Abilities - Magic Guard", () => {
const toxicStartCounter = enemyPokemon.status!.toxicTurnCount;
//should be 0
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -173,7 +166,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -198,7 +191,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -223,7 +216,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -245,7 +238,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.HIGH_JUMP_KICK);
await game.move.forceMiss();
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -262,7 +255,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.TAKE_DOWN);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -279,7 +272,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.STRUGGLE);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -288,7 +281,8 @@ describe("Abilities - Magic Guard", () => {
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
});
it("should prevent self-damage from attacking moves", async () => {
//This tests different move attributes than the recoil tests above
it("Magic Guard prevents self-damage from attacking moves", async () => {
game.override.moveset([Moves.STEEL_BEAM]);
await game.startBattle([Species.MAGIKARP]);
@ -296,7 +290,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.STEEL_BEAM);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -305,19 +299,17 @@ describe("Abilities - Magic Guard", () => {
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
});
it("should not prevent self-damage from confusion", async () => {
game.override.enemyMoveset(Moves.CONFUSE_RAY).confusionActivation(true);
await game.classicMode.startBattle([Species.MAGIKARP]);
/*
it("Magic Guard does not prevent self-damage from confusion", async () => {
await game.startBattle([Species.MAGIKARP]);
game.move.select(Moves.CHARM);
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
await game.phaseInterceptor.to("TurnEndPhase");
expect(game.scene.getPlayerPokemon()!.isFullHp()).toBe(false);
await game.phaseInterceptor.to(TurnEndPhase);
});
*/
it("should not prevent self-damage from non-attacking moves", async () => {
it("Magic Guard does not prevent self-damage from non-attacking moves", async () => {
game.override.moveset([Moves.BELLY_DRUM]);
await game.startBattle([Species.MAGIKARP]);
@ -325,7 +317,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.BELLY_DRUM);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -335,7 +327,11 @@ describe("Abilities - Magic Guard", () => {
});
it("Magic Guard prevents damage from abilities with PostTurnHurtIfSleepingAbAttr", async () => {
game.override.statusEffect(StatusEffect.SLEEP).enemyMoveset(Moves.SPORE).enemyAbility(Abilities.BAD_DREAMS);
//Tests the ability Bad Dreams
game.override.statusEffect(StatusEffect.SLEEP);
//enemy pokemon is given Spore just in case player pokemon somehow awakens during test
game.override.enemyMoveset([Moves.SPORE, Moves.SPORE, Moves.SPORE, Moves.SPORE]);
game.override.enemyAbility(Abilities.BAD_DREAMS);
await game.startBattle([Species.MAGIKARP]);
@ -343,7 +339,7 @@ describe("Abilities - Magic Guard", () => {
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -354,8 +350,10 @@ describe("Abilities - Magic Guard", () => {
expect(leadPokemon.status!.effect).toBe(StatusEffect.SLEEP);
});
it("should prevent damage from abilities with PostFaintContactDamageAbAttr", async () => {
game.override.moveset([Moves.TACKLE]).enemyAbility(Abilities.AFTERMATH);
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);
await game.startBattle([Species.MAGIKARP]);
@ -365,7 +363,7 @@ describe("Abilities - Magic Guard", () => {
enemyPokemon.hp = 1;
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -388,7 +386,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -411,7 +409,7 @@ describe("Abilities - Magic Guard", () => {
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.ABSORB);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:
@ -430,7 +428,7 @@ describe("Abilities - Magic Guard", () => {
await game.startBattle([Species.MAGIKARP]);
const leadPokemon = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase");
await game.phaseInterceptor.to(TurnEndPhase);
/**
* Expect:

View File

@ -27,7 +27,7 @@ import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { Biome } from "#app/enums/biome";
describe("Test - Battle Phase", () => {
describe("Test Battle Phase", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
@ -91,27 +91,28 @@ describe("Test - Battle Phase", () => {
}, 20000);
it("do attack wave 3 - single battle - regular - OHKO", async () => {
game.override
.enemySpecies(Species.RATTATA)
.startingLevel(2000)
.startingWave(3)
.battleStyle("single")
.enemyMoveset(Moves.TACKLE);
await game.classicMode.startBattle([Species.MEWTWO]);
game.override.starterSpecies(Species.MEWTWO);
game.override.enemySpecies(Species.RATTATA);
game.override.startingLevel(2000);
game.override.startingWave(3).battleStyle("single");
game.override.moveset([Moves.TACKLE]);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle();
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 () => {
game.override
.enemySpecies(Species.RATTATA)
.startingLevel(5)
.startingWave(3)
.moveset([Moves.TACKLE])
.enemyAbility(Abilities.HYDRATION)
.enemyMoveset(Moves.TAIL_WHIP)
.battleStyle("single");
await game.classicMode.startBattle([Species.MEWTWO]);
game.override.starterSpecies(Species.MEWTWO);
game.override.enemySpecies(Species.RATTATA);
game.override.startingLevel(5);
game.override.startingWave(3);
game.override.moveset([Moves.TACKLE]);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.enemyMoveset([Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP, Moves.TAIL_WHIP]);
game.override.battleStyle("single");
await game.startBattle();
game.move.select(Moves.TACKLE);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnInitPhase, false);
}, 20000);
@ -199,23 +200,7 @@ describe("Test - Battle Phase", () => {
selectStarterPhase.initBattle(starters);
});
await game.phaseInterceptor.runFrom(SelectGenderPhase).to(SummonPhase);
});
it.each([
{ name: "1v1", double: false, qty: 1 },
{ name: "2v1", double: false, qty: 2 },
{ name: "2v2", double: true, qty: 2 },
{ name: "4v2", double: true, qty: 4 },
])("should not crash when starting $name battle", async ({ double, qty }) => {
game.override
.battleStyle(double ? "double" : "single")
.enemySpecies(Species.MIGHTYENA)
.enemyAbility(Abilities.HYDRATION)
.ability(Abilities.HYDRATION);
await game.classicMode.startBattle(
[Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE].slice(0, qty),
);
}, 20000);
it("2vs1", async () => {
game.override.battleStyle("single");
@ -225,21 +210,52 @@ describe("Test - Battle Phase", () => {
await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
});
}, 20000);
it("1vs1", async () => {
game.override.battleStyle("single");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
await game.startBattle([Species.BLASTOISE]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
it("2vs2", async () => {
game.override.battleStyle("double");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
game.override.startingWave(3);
await game.startBattle([Species.BLASTOISE, Species.CHARIZARD]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
it("4vs2", async () => {
game.override.battleStyle("double");
game.override.enemySpecies(Species.MIGHTYENA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.HYDRATION);
game.override.startingWave(3);
await game.startBattle([Species.BLASTOISE, Species.CHARIZARD, Species.DARKRAI, Species.GABITE]);
expect(game.scene.ui?.getMode()).toBe(UiMode.COMMAND);
expect(game.scene.getCurrentPhase()!.constructor.name).toBe(CommandPhase.name);
}, 20000);
it("kill opponent pokemon", async () => {
const moveToUse = Moves.SPLASH;
game.override
.battleStyle("single")
.starterSpecies(Species.MEWTWO)
.enemySpecies(Species.RATTATA)
.enemyAbility(Abilities.HYDRATION)
.ability(Abilities.ZEN_MODE)
.startingLevel(2000)
.startingWave(3)
.moveset([moveToUse])
.enemyMoveset(Moves.TACKLE);
await game.classicMode.startBattle([Species.DARMANITAN, Species.CHARIZARD]);
game.override.battleStyle("single");
game.override.starterSpecies(Species.MEWTWO);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.ZEN_MODE);
game.override.startingLevel(2000);
game.override.startingWave(3);
game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle([Species.DARMANITAN, Species.CHARIZARD]);
game.move.select(moveToUse);
await game.phaseInterceptor.to(DamageAnimPhase, false);
@ -250,16 +266,16 @@ describe("Test - Battle Phase", () => {
it("to next turn", async () => {
const moveToUse = Moves.SPLASH;
game.override
.battleStyle("single")
.enemySpecies(Species.RATTATA)
.enemyAbility(Abilities.HYDRATION)
.ability(Abilities.ZEN_MODE)
.startingLevel(2000)
.startingWave(3)
.moveset([moveToUse])
.enemyMoveset(Moves.TACKLE);
await game.classicMode.startBattle([Species.MEWTWO]);
game.override.battleStyle("single");
game.override.starterSpecies(Species.MEWTWO);
game.override.enemySpecies(Species.RATTATA);
game.override.enemyAbility(Abilities.HYDRATION);
game.override.ability(Abilities.ZEN_MODE);
game.override.startingLevel(2000);
game.override.startingWave(3);
game.override.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.startBattle();
const turn = game.scene.currentBattle.turn;
game.move.select(moveToUse);
await game.toNextTurn();
@ -277,8 +293,8 @@ describe("Test - Battle Phase", () => {
.startingLevel(2000)
.startingWave(3)
.startingBiome(Biome.LAKE)
.moveset([moveToUse])
.enemyMoveset(Moves.TACKLE);
.moveset([moveToUse]);
game.override.enemyMoveset([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
await game.classicMode.startBattle();
const waveIndex = game.scene.currentBattle.waveIndex;
game.move.select(moveToUse);