Merge branch 'beta' into finish-buff-punish-moves

This commit is contained in:
NightKev 2024-08-30 21:06:30 -07:00 committed by GitHub
commit a6269175a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 83 additions and 2 deletions

View File

@ -251,8 +251,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.shiny = false; this.shiny = false;
} }
if (!dataSource) {
this.calculateStats(); this.calculateStats();
} }
}
getNameToRender() { getNameToRender() {

View File

@ -293,7 +293,7 @@ export class TitlePhase extends Phase {
} }
for (const achv of Object.keys(this.scene.gameData.achvUnlocks)) { for (const achv of Object.keys(this.scene.gameData.achvUnlocks)) {
if (vouchers.hasOwnProperty(achv)) { if (vouchers.hasOwnProperty(achv) && achv !== "CLASSIC_VICTORY") {
this.scene.validateVoucher(vouchers[achv]); this.scene.validateVoucher(vouchers[achv]);
} }
} }

View File

@ -1,9 +1,11 @@
import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions"; import { pokemonEvolutions, SpeciesFormEvolution, SpeciesWildEvolutionDelay } from "#app/data/pokemon-evolutions";
import { Abilities } from "#app/enums/abilities"; import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species"; import { Species } from "#app/enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { SPLASH_ONLY } from "./utils/testUtils";
describe("Evolution", () => { describe("Evolution", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -89,4 +91,61 @@ describe("Evolution", () => {
expect(speciesFormEvo.wildDelay).toBe(SpeciesWildEvolutionDelay.NONE); expect(speciesFormEvo.wildDelay).toBe(SpeciesWildEvolutionDelay.NONE);
}); });
it("should increase both HP and max HP when evolving", async () => {
game.override.moveset([Moves.SURF])
.enemySpecies(Species.GOLEM)
.enemyMoveset(SPLASH_ONLY)
.startingWave(21)
.startingLevel(16)
.enemyLevel(50);
await game.startBattle([Species.TOTODILE]);
const totodile = game.scene.getPlayerPokemon()!;
const hpBefore = totodile.hp;
expect(totodile.hp).toBe(totodile.getMaxHp());
const golem = game.scene.getEnemyPokemon()!;
golem.hp = 1;
expect(golem.hp).toBe(1);
game.move.select(Moves.SURF);
await game.phaseInterceptor.to("EndEvolutionPhase");
expect(totodile.hp).toBe(totodile.getMaxHp());
expect(totodile.hp).toBeGreaterThan(hpBefore);
}, TIMEOUT);
it("should not fully heal HP when evolving", async () => {
game.override.moveset([Moves.SURF])
.enemySpecies(Species.GOLEM)
.enemyMoveset(SPLASH_ONLY)
.startingWave(21)
.startingLevel(13)
.enemyLevel(30);
await game.startBattle([Species.CYNDAQUIL]);
const cyndaquil = game.scene.getPlayerPokemon()!;
cyndaquil.hp = Math.floor(cyndaquil.getMaxHp() / 2);
const hpBefore = cyndaquil.hp;
const maxHpBefore = cyndaquil.getMaxHp();
expect(cyndaquil.hp).toBe(Math.floor(cyndaquil.getMaxHp() / 2));
const golem = game.scene.getEnemyPokemon()!;
golem.hp = 1;
expect(golem.hp).toBe(1);
game.move.select(Moves.SURF);
await game.phaseInterceptor.to("EndEvolutionPhase");
expect(cyndaquil.getMaxHp()).toBeGreaterThan(maxHpBefore);
expect(cyndaquil.hp).toBeGreaterThan(hpBefore);
expect(cyndaquil.hp).toBeLessThan(cyndaquil.getMaxHp());
}, TIMEOUT);
}); });

View File

@ -7,6 +7,8 @@ import MockSprite from "#test/utils/mocks/mocksContainer/mockSprite";
import MockText from "#test/utils/mocks/mocksContainer/mockText"; import MockText from "#test/utils/mocks/mocksContainer/mockText";
import MockTexture from "#test/utils/mocks/mocksContainer/mockTexture"; import MockTexture from "#test/utils/mocks/mocksContainer/mockTexture";
import { MockGameObject } from "./mockGameObject"; import { MockGameObject } from "./mockGameObject";
import { vi } from "vitest";
import { MockVideoGameObject } from "./mockVideoGameObject";
/** /**
* Stub class for Phaser.Textures.TextureManager * Stub class for Phaser.Textures.TextureManager
@ -34,6 +36,7 @@ export default class MockTextureManager {
text: this.text.bind(this), text: this.text.bind(this),
bitmapText: this.text.bind(this), bitmapText: this.text.bind(this),
displayList: this.displayList, displayList: this.displayList,
video: vi.fn(() => new MockVideoGameObject()),
}; };
} }

View File

@ -0,0 +1,13 @@
import { vi } from "vitest";
import { MockGameObject } from "./mockGameObject";
/** Mocks video-related stuff */
export class MockVideoGameObject implements MockGameObject {
constructor() {}
public play = vi.fn();
public stop = vi.fn(() => this);
public setOrigin = vi.fn();
public setScale = vi.fn();
public setVisible = vi.fn();
}

View File

@ -6,7 +6,9 @@ import { CommandPhase } from "#app/phases/command-phase";
import { DamagePhase } from "#app/phases/damage-phase"; import { DamagePhase } from "#app/phases/damage-phase";
import { EggLapsePhase } from "#app/phases/egg-lapse-phase"; import { EggLapsePhase } from "#app/phases/egg-lapse-phase";
import { EncounterPhase } from "#app/phases/encounter-phase"; import { EncounterPhase } from "#app/phases/encounter-phase";
import { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { EvolutionPhase } from "#app/phases/evolution-phase";
import { FaintPhase } from "#app/phases/faint-phase"; import { FaintPhase } from "#app/phases/faint-phase";
import { LoginPhase } from "#app/phases/login-phase"; import { LoginPhase } from "#app/phases/login-phase";
import { MessagePhase } from "#app/phases/message-phase"; import { MessagePhase } from "#app/phases/message-phase";
@ -92,6 +94,8 @@ export default class PhaseInterceptor {
[SwitchPhase, this.startPhase], [SwitchPhase, this.startPhase],
[SwitchSummonPhase, this.startPhase], [SwitchSummonPhase, this.startPhase],
[PartyHealPhase, this.startPhase], [PartyHealPhase, this.startPhase],
[EvolutionPhase, this.startPhase],
[EndEvolutionPhase, this.startPhase],
]; ];
private endBySetMode = [ private endBySetMode = [