[Balance] Endure Tokens only endure one hit (#4875)
* Endure Tokens only endure one hit * Add tests for Endure * Update docs --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
413f2b80c8
commit
360a897ed2
|
@ -1502,9 +1502,14 @@ export class ContactBurnProtectedTag extends DamageProtectedTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `BattlerTag` class for effects that cause the affected Pokemon to survive lethal attacks at 1 HP.
|
||||||
|
* Used for {@link https://bulbapedia.bulbagarden.net/wiki/Endure_(move) | Endure} and
|
||||||
|
* Endure Tokens.
|
||||||
|
*/
|
||||||
export class EnduringTag extends BattlerTag {
|
export class EnduringTag extends BattlerTag {
|
||||||
constructor(sourceMove: Moves) {
|
constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType, sourceMove: Moves) {
|
||||||
super(BattlerTagType.ENDURING, BattlerTagLapseType.TURN_END, 0, sourceMove);
|
super(tagType, lapseType, 0, sourceMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdd(pokemon: Pokemon): void {
|
onAdd(pokemon: Pokemon): void {
|
||||||
|
@ -3009,7 +3014,9 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
|
||||||
case BattlerTagType.BURNING_BULWARK:
|
case BattlerTagType.BURNING_BULWARK:
|
||||||
return new ContactBurnProtectedTag(sourceMove);
|
return new ContactBurnProtectedTag(sourceMove);
|
||||||
case BattlerTagType.ENDURING:
|
case BattlerTagType.ENDURING:
|
||||||
return new EnduringTag(sourceMove);
|
return new EnduringTag(tagType, BattlerTagLapseType.TURN_END, sourceMove);
|
||||||
|
case BattlerTagType.ENDURE_TOKEN:
|
||||||
|
return new EnduringTag(tagType, BattlerTagLapseType.AFTER_HIT, sourceMove);
|
||||||
case BattlerTagType.STURDY:
|
case BattlerTagType.STURDY:
|
||||||
return new SturdyTag(sourceMove);
|
return new SturdyTag(sourceMove);
|
||||||
case BattlerTagType.PERISH_SONG:
|
case BattlerTagType.PERISH_SONG:
|
||||||
|
|
|
@ -92,4 +92,5 @@ export enum BattlerTagType {
|
||||||
COMMANDED = "COMMANDED",
|
COMMANDED = "COMMANDED",
|
||||||
GRUDGE = "GRUDGE",
|
GRUDGE = "GRUDGE",
|
||||||
PSYCHO_SHIFT = "PSYCHO_SHIFT",
|
PSYCHO_SHIFT = "PSYCHO_SHIFT",
|
||||||
|
ENDURE_TOKEN = "ENDURE_TOKEN",
|
||||||
}
|
}
|
||||||
|
|
|
@ -2955,6 +2955,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING);
|
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING);
|
||||||
} else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) {
|
} else if (this.hp > 1 && this.getTag(BattlerTagType.STURDY)) {
|
||||||
surviveDamage.value = this.lapseTag(BattlerTagType.STURDY);
|
surviveDamage.value = this.lapseTag(BattlerTagType.STURDY);
|
||||||
|
} else if (this.hp >= 1 && this.getTag(BattlerTagType.ENDURE_TOKEN)) {
|
||||||
|
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURE_TOKEN);
|
||||||
}
|
}
|
||||||
if (!surviveDamage.value) {
|
if (!surviveDamage.value) {
|
||||||
this.scene.applyModifiers(SurviveDamageModifier, this.isPlayer(), this, surviveDamage);
|
this.scene.applyModifiers(SurviveDamageModifier, this.isPlayer(), this, surviveDamage);
|
||||||
|
|
|
@ -3647,8 +3647,8 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies {@linkcode EnemyEndureChanceModifier}
|
* Applies a chance of enduring a lethal hit of an attack
|
||||||
* @param target {@linkcode Pokemon} to apply the {@linkcode BattlerTagType.ENDURING} chance to
|
* @param target the {@linkcode Pokemon} to apply the {@linkcode BattlerTagType.ENDURING} chance to
|
||||||
* @returns `true` if {@linkcode Pokemon} endured
|
* @returns `true` if {@linkcode Pokemon} endured
|
||||||
*/
|
*/
|
||||||
override apply(target: Pokemon): boolean {
|
override apply(target: Pokemon): boolean {
|
||||||
|
@ -3656,7 +3656,7 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.addTag(BattlerTagType.ENDURING, 1);
|
target.addTag(BattlerTagType.ENDURE_TOKEN, 1);
|
||||||
|
|
||||||
target.battleData.endured = true;
|
target.battleData.endured = true;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { Moves } from "#enums/moves";
|
||||||
|
import { Species } from "#enums/species";
|
||||||
|
import GameManager from "#test/utils/gameManager";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("Moves - Endure", () => {
|
||||||
|
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.THUNDER, Moves.BULLET_SEED, Moves.TOXIC ])
|
||||||
|
.ability(Abilities.SKILL_LINK)
|
||||||
|
.startingLevel(100)
|
||||||
|
.battleType("single")
|
||||||
|
.disableCrits()
|
||||||
|
.enemySpecies(Species.MAGIKARP)
|
||||||
|
.enemyAbility(Abilities.NO_GUARD)
|
||||||
|
.enemyMoveset(Moves.ENDURE);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should let the pokemon survive with 1 HP", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.ARCEUS ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.THUNDER);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(game.scene.getEnemyPokemon()!.hp).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should let the pokemon survive with 1 HP when hit with a multihit move", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.ARCEUS ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.BULLET_SEED);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(game.scene.getEnemyPokemon()!.hp).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shouldn't prevent fainting from indirect damage", async () => {
|
||||||
|
game.override.enemyLevel(100);
|
||||||
|
await game.classicMode.startBattle([ Species.ARCEUS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
enemy.hp = 2;
|
||||||
|
|
||||||
|
game.move.select(Moves.TOXIC);
|
||||||
|
await game.phaseInterceptor.to("VictoryPhase");
|
||||||
|
|
||||||
|
expect(enemy.isFainted()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue