Fixed rest bug

This commit is contained in:
Bertie690 2025-05-25 19:50:01 -04:00
parent 45bbaf2b25
commit 96e4bb5e0e
3 changed files with 16 additions and 20 deletions

View File

@ -281,7 +281,8 @@ export class MovePhase extends BattlePhase {
globalScene.queueMessage( globalScene.queueMessage(
getStatusEffectHealText(this.pokemon.status.effect, getPokemonNameWithAffix(this.pokemon)), getStatusEffectHealText(this.pokemon.status.effect, getPokemonNameWithAffix(this.pokemon)),
); );
this.pokemon.resetStatus(); // cannot use `unshiftPhase` as it will cause status to be reset _after_ move condition checks fire
this.pokemon.resetStatus(false, false, false, false);
this.pokemon.updateInfo(); this.pokemon.updateInfo();
} }
} }

View File

@ -103,26 +103,9 @@ describe("Moves - Rest", () => {
const snorlax = game.scene.getPlayerPokemon()!; const snorlax = game.scene.getPlayerPokemon()!;
snorlax.hp = 1; snorlax.hp = 1;
// Turn 1
game.move.select(Moves.REST);
await game.toNextTurn();
snorlax.hp = 1;
expect(snorlax.status?.effect).toBe(StatusEffect.SLEEP); expect(snorlax.status?.effect).toBe(StatusEffect.SLEEP);
snorlax.status!.sleepTurnsRemaining = 1;
// Turn 2
game.move.select(Moves.REST);
await game.toNextTurn();
expect(snorlax.status?.effect).toBe(StatusEffect.SLEEP);
// Turn 3
game.move.select(Moves.REST);
await game.toNextTurn();
expect(snorlax.status?.effect).toBe(StatusEffect.SLEEP);
// Turn 4 (wakeup)
game.move.select(Moves.REST); game.move.select(Moves.REST);
await game.toNextTurn(); await game.toNextTurn();

View File

@ -61,7 +61,7 @@ describe("Moves - Sleep Talk", () => {
); );
}); });
it("should fail when the user is not asleep", async () => { it("should fail if the user is not asleep", async () => {
game.override.statusEffect(StatusEffect.NONE); game.override.statusEffect(StatusEffect.NONE);
await game.classicMode.startBattle([Species.FEEBAS]); await game.classicMode.startBattle([Species.FEEBAS]);
@ -70,6 +70,18 @@ describe("Moves - Sleep Talk", () => {
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
it("should fail the turn the user wakes up from Sleep", async () => {
await game.classicMode.startBattle([Species.FEEBAS]);
const feebas = game.scene.getPlayerPokemon()!;
expect(feebas.status?.effect).toBe(StatusEffect.SLEEP);
feebas.status!.sleepTurnsRemaining = 1;
game.move.select(Moves.SLEEP_TALK);
await game.toNextTurn();
expect(feebas.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
});
it("should fail if the user has no valid moves", async () => { it("should fail if the user has no valid moves", async () => {
game.override.moveset([Moves.SLEEP_TALK, Moves.DIG, Moves.METRONOME, Moves.SOLAR_BEAM]); game.override.moveset([Moves.SLEEP_TALK, Moves.DIG, Moves.METRONOME, Moves.SOLAR_BEAM]);
await game.classicMode.startBattle([Species.FEEBAS]); await game.classicMode.startBattle([Species.FEEBAS]);