[Bug] Prevent pokemon with 0 HP from being statused

This commit is contained in:
NightKev 2025-01-17 01:23:35 -08:00
parent ca0522436a
commit 01adb30799
3 changed files with 47 additions and 5 deletions

View File

@ -3525,6 +3525,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
*/
canSetStatus(effect: StatusEffect | undefined, quiet: boolean = false, overrideStatus: boolean = false, sourcePokemon: Pokemon | null = null, ignoreField: boolean = false): boolean {
if (effect !== StatusEffect.FAINT) {
if (this.isFainted()) {
return false;
}
if (overrideStatus ? this.status?.effect === effect : this.status) {
return false;
}

View File

@ -400,4 +400,43 @@ describe("Status Effects", () => {
expect(player.getLastXMoves(1)[0].result).toBe(MoveResult.SUCCESS);
});
});
describe("Behavior", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([ Moves.SPLASH ])
.ability(Abilities.BALL_FETCH)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.NUZZLE)
.enemyLevel(2000);
});
it("should not inflict a 0 HP mon with a status", async () => {
await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]);
const player = game.scene.getPlayerPokemon()!;
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to("FaintPhase", false);
expect(player.status?.effect).not.toBe(StatusEffect.PARALYSIS);
});
});
});

View File

@ -349,14 +349,14 @@ export class IntegerHolder extends NumberHolder {
}
}
/** @deprecated Use {@linkcode NumberHolder}*/
export class FixedInt extends IntegerHolder {
constructor(value: integer) {
super(value);
export class FixedInt {
public readonly value: number;
constructor(value: number) {
this.value = value;
}
}
/** @deprecated */
export function fixedInt(value: integer): integer {
return new FixedInt(value) as unknown as integer;
}