Merge branch 'beta' into instruct

This commit is contained in:
Bertie690 2024-11-16 09:18:55 -05:00 committed by GitHub
commit 1d32137696
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 82 additions and 7 deletions

View File

@ -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 {
constructor(sourceMove: Moves) {
super(BattlerTagType.ENDURING, BattlerTagLapseType.TURN_END, 0, sourceMove);
constructor(tagType: BattlerTagType, lapseType: BattlerTagLapseType, sourceMove: Moves) {
super(tagType, lapseType, 0, sourceMove);
}
onAdd(pokemon: Pokemon): void {
@ -3009,7 +3014,9 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: number, source
case BattlerTagType.BURNING_BULWARK:
return new ContactBurnProtectedTag(sourceMove);
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:
return new SturdyTag(sourceMove);
case BattlerTagType.PERISH_SONG:

View File

@ -92,4 +92,5 @@ export enum BattlerTagType {
COMMANDED = "COMMANDED",
GRUDGE = "GRUDGE",
PSYCHO_SHIFT = "PSYCHO_SHIFT",
ENDURE_TOKEN = "ENDURE_TOKEN",
}

View File

@ -2955,6 +2955,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
surviveDamage.value = this.lapseTag(BattlerTagType.ENDURING);
} else if (this.hp > 1 && this.getTag(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) {
this.scene.applyModifiers(SurviveDamageModifier, this.isPlayer(), this, surviveDamage);

View File

@ -2818,7 +2818,7 @@ export class MoneyRewardModifier extends ConsumableModifier {
battleScene.getPlayerParty().map(p => {
if (p.species?.speciesId === Species.GIMMIGHOUL || p.fusionSpecies?.speciesId === Species.GIMMIGHOUL) {
p.evoCounter ? p.evoCounter++ : p.evoCounter = 1;
p.evoCounter ? p.evoCounter += Math.min(Math.floor(this.moneyMultiplier), 3) : p.evoCounter = Math.min(Math.floor(this.moneyMultiplier), 3);
const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(p) as EvoTrackerModifier;
battleScene.addModifier(modifier);
}
@ -3647,8 +3647,8 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier {
}
/**
* Applies {@linkcode EnemyEndureChanceModifier}
* @param target {@linkcode Pokemon} to apply the {@linkcode BattlerTagType.ENDURING} chance to
* Applies a chance of enduring a lethal hit of an attack
* @param target the {@linkcode Pokemon} to apply the {@linkcode BattlerTagType.ENDURING} chance to
* @returns `true` if {@linkcode Pokemon} endured
*/
override apply(target: Pokemon): boolean {
@ -3656,7 +3656,7 @@ export class EnemyEndureChanceModifier extends EnemyPersistentModifier {
return false;
}
target.addTag(BattlerTagType.ENDURING, 1);
target.addTag(BattlerTagType.ENDURE_TOKEN, 1);
target.battleData.endured = true;

View File

@ -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);
});
});