[Bug] Prevent pokemon with 0 HP from being statused (#5137)
* [Bug] Prevent pokemon with 0 HP from being statused * Update test * Move check to `trySetStatus()` and update test
This commit is contained in:
parent
d495c48716
commit
d85aedbdfc
|
@ -3606,6 +3606,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||
if (!this.canSetStatus(effect, asPhase, false, sourcePokemon)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isFainted() && effect !== StatusEffect.FAINT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this Pokemon falls asleep or freezes in the middle of a multi-hit attack,
|
||||
|
|
|
@ -400,4 +400,42 @@ 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()!;
|
||||
player.hp = 0;
|
||||
|
||||
expect(player.trySetStatus(StatusEffect.BURN)).toBe(false);
|
||||
expect(player.status?.effect).not.toBe(StatusEffect.BURN);
|
||||
});
|
||||
});
|
||||
});
|
10
src/utils.ts
10
src/utils.ts
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue