test added

This commit is contained in:
Bertie690 2025-04-21 17:55:30 -04:00
parent 024b413611
commit 6374f38b11
4 changed files with 19 additions and 23 deletions

View File

@ -337,7 +337,7 @@ export class EncounterPhase extends BattlePhase {
for (const pokemon of globalScene.getPlayerParty()) { for (const pokemon of globalScene.getPlayerParty()) {
// Only reset wave data, not battle data // Only reset wave data, not battle data
if (pokemon) { if (pokemon) {
pokemon.resetBattleAndWaveData(); pokemon.resetWaveData();
} }
} }

View File

@ -187,7 +187,7 @@ describe("Abilities - Cud Chew", () => {
}); });
describe("regurgiates berries", () => { describe("regurgiates berries", () => {
it("re-triggers effects on eater without infinitely looping", async () => { it("re-triggers effects on eater without pushing to array", async () => {
const apply = vi.spyOn(RepeatBerryNextTurnAbAttr.prototype, "apply"); const apply = vi.spyOn(RepeatBerryNextTurnAbAttr.prototype, "apply");
await game.classicMode.startBattle([Species.FARIGIRAF]); await game.classicMode.startBattle([Species.FARIGIRAF]);
@ -198,7 +198,6 @@ describe("Abilities - Cud Chew", () => {
await game.toNextTurn(); await game.toNextTurn();
// ate 1 sitrus the turn prior, spitball pending // ate 1 sitrus the turn prior, spitball pending
expect(farigiraf.battleData.berriesEaten).toEqual([BerryType.SITRUS]);
expect(farigiraf.summonData.berriesEatenLast).toEqual([BerryType.SITRUS]); expect(farigiraf.summonData.berriesEatenLast).toEqual([BerryType.SITRUS]);
expect(farigiraf.turnData.berriesEaten).toEqual([]); expect(farigiraf.turnData.berriesEaten).toEqual([]);
expect(apply.mock.lastCall).toBeUndefined(); expect(apply.mock.lastCall).toBeUndefined();
@ -210,7 +209,6 @@ describe("Abilities - Cud Chew", () => {
// healed back up to half without adding any more to array // healed back up to half without adding any more to array
expect(farigiraf.hp).toBeGreaterThan(turn1Hp); expect(farigiraf.hp).toBeGreaterThan(turn1Hp);
expect(farigiraf.battleData.berriesEaten).toEqual([BerryType.SITRUS]);
expect(farigiraf.summonData.berriesEatenLast).toEqual([]); expect(farigiraf.summonData.berriesEatenLast).toEqual([]);
expect(farigiraf.turnData.berriesEaten).toEqual([]); expect(farigiraf.turnData.berriesEaten).toEqual([]);
}); });

View File

@ -19,7 +19,7 @@ describe("Abilities - Harvest", () => {
const getPlayerBerries = () => const getPlayerBerries = () =>
game.scene.getModifiers(BerryModifier, true).filter(b => b.pokemonId === game.scene.getPlayerPokemon()?.id); game.scene.getModifiers(BerryModifier, true).filter(b => b.pokemonId === game.scene.getPlayerPokemon()?.id);
/** Check whether the player's Modifiers contains the specified berries. */ /** Check whether the player's Modifiers contains the specified berries and nothing else. */
function expectBerriesContaining(...berries: ModifierOverride[]): void { function expectBerriesContaining(...berries: ModifierOverride[]): void {
const actualBerries: ModifierOverride[] = getPlayerBerries().map( const actualBerries: ModifierOverride[] = getPlayerBerries().map(
// only grab berry type and quantity since that's literally all we care about // only grab berry type and quantity since that's literally all we care about
@ -145,40 +145,29 @@ describe("Abilities - Harvest", () => {
expect(regielekiReloaded.battleData.berriesEaten).toEqual([BerryType.PETAYA]); expect(regielekiReloaded.battleData.berriesEaten).toEqual([BerryType.PETAYA]);
}); });
it("cannot restore capped berries, even if an ally has one under cap", async () => { it("cannot restore capped berries", async () => {
const initBerries: ModifierOverride[] = [ const initBerries: ModifierOverride[] = [
{ name: "BERRY", type: BerryType.LUM, count: 2 }, { name: "BERRY", type: BerryType.LUM, count: 2 },
{ name: "BERRY", type: BerryType.STARF, count: 2 }, { name: "BERRY", type: BerryType.STARF, count: 2 },
]; ];
game.override.startingHeldItems(initBerries); game.override.startingHeldItems(initBerries);
await game.classicMode.startBattle([Species.FEEBAS, Species.BELLOSSOM]); await game.classicMode.startBattle([Species.FEEBAS]);
const [feebas, bellossom] = game.scene.getPlayerParty(); const feebas = game.scene.getPlayerPokemon()!;
feebas.battleData.berriesEaten = [BerryType.LUM, BerryType.STARF]; feebas.battleData.berriesEaten = [BerryType.LUM, BerryType.STARF];
// get rid of bellossom's modifiers and add a sitrus
await game.scene.removePartyMemberModifiers(1);
const newMod = game.scene
.getModifiers(BerryModifier, true)
.find(b => b.berryType === BerryType.SITRUS)
?.clone()!;
expect(newMod).toBeDefined();
newMod.pokemonId = bellossom.id;
game.scene.addModifier(newMod, true);
game.move.select(Moves.SPLASH); game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH);
await game.phaseInterceptor.to("BerryPhase"); await game.phaseInterceptor.to("BerryPhase");
// Force RNG roll to hit the first berry we find. // Force RNG roll to hit the first berry we find that matches.
// This does nothing on a success (since there'd only be a starf left to grab), // This does nothing on a success (since there'd only be a starf left to grab),
// but ensures we don't accidentally let any false positives through. // but ensures we don't accidentally let any false positives through.
vi.spyOn(Phaser.Math.RND, "integerInRange").mockReturnValue(0); vi.spyOn(Phaser.Math.RND, "integerInRange").mockReturnValue(0);
await game.phaseInterceptor.to("TurnEndPhase"); await game.phaseInterceptor.to("TurnEndPhase");
// recovered a starf, // recovered a starf
expectBerriesContaining({ name: "BERRY", type: BerryType.STARF, count: 3 }); expectBerriesContaining({ name: "BERRY", type: BerryType.STARF, count: 3 });
expect(game.scene.getModifiers(BerryModifier, true).filter(b => b.pokemonId === bellossom.id)).toHaveLength(0);
}); });
it("does nothing if all berries are capped", async () => { it("does nothing if all berries are capped", async () => {

View File

@ -137,7 +137,7 @@ describe("Moves - Rage Fist", () => {
expect(ironHands.battleData.hitCount).toBe(0); expect(ironHands.battleData.hitCount).toBe(0);
}); });
it("should reset the hitRecCounter if we enter new biome", async () => { it("should reset hits recieved before new biome", async () => {
game.override.enemySpecies(Species.MAGIKARP).startingWave(10); game.override.enemySpecies(Species.MAGIKARP).startingWave(10);
await game.classicMode.startBattle([Species.MAGIKARP]); await game.classicMode.startBattle([Species.MAGIKARP]);
@ -153,7 +153,7 @@ describe("Moves - Rage Fist", () => {
expect(move.calculateBattlePower).toHaveLastReturnedWith(150); expect(move.calculateBattlePower).toHaveLastReturnedWith(150);
}); });
it("should not reset the hitRecCounter if switched out", async () => { it("should not reset if switched out or on reload", async () => {
game.override.enemyMoveset(Moves.TACKLE); game.override.enemyMoveset(Moves.TACKLE);
const getPartyHitCount = () => const getPartyHitCount = () =>
@ -188,5 +188,14 @@ describe("Moves - Rage Fist", () => {
expect(charizard).toBeDefined(); expect(charizard).toBeDefined();
expect(charizard.species.speciesId).toBe(Species.CHARIZARD); expect(charizard.species.speciesId).toBe(Species.CHARIZARD);
expect(move.calculateBattlePower).toHaveLastReturnedWith(150); expect(move.calculateBattlePower).toHaveLastReturnedWith(150);
// go to new wave, reload game and beat up another poor sap
await game.toNextWave();
await game.reload.reloadSession();
game.move.select(Moves.RAGE_FIST);
await game.phaseInterceptor.to("MoveEndPhase");
expect(move.calculateBattlePower).toHaveLastReturnedWith(250);
}); });
}); });