This commit is contained in:
Bertie690 2025-08-08 12:37:14 -04:00
parent da5c0d2ca8
commit cf5c6ae58d
3 changed files with 6 additions and 9 deletions

View File

@ -164,7 +164,7 @@ export class BattlerTag implements BaseBattlerTag {
* Unused by default but can be used by subclasses.
* @param _lapseType - The {@linkcode BattlerTagLapseType} being lapsed.
* Unused by default but can be used by subclasses.
* @returns `true` if the tag should be kept (`turnCount` > 0`)
* @returns `true` if the tag should be kept (`turnCount > 0`)
*/
lapse(_pokemon: Pokemon, _lapseType: BattlerTagLapseType): boolean {
return --this.turnCount > 0;
@ -820,9 +820,7 @@ export class ConfusedTag extends SerializableBattlerTag {
* @returns Whether the tag should be kept.
*/
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
const shouldRemain = super.lapse(pokemon, lapseType);
if (!shouldRemain) {
if (!super.lapse(pokemon, lapseType)) {
return false;
}
@ -838,7 +836,6 @@ export class ConfusedTag extends SerializableBattlerTag {
// 1/3 chance of hitting self with a 40 base power move
const shouldInterruptMove = Overrides.CONFUSION_ACTIVATION_OVERRIDE ?? pokemon.randBattleSeedInt(3) === 0;
if (shouldInterruptMove) {
// TODO: Are these calculations correct? We probably shouldn't hardcode the damage formula here...
const atk = pokemon.getEffectiveStat(Stat.ATK);
const def = pokemon.getEffectiveStat(Stat.DEF);
const damage = toDmgValue(

View File

@ -827,8 +827,8 @@ export class MoveEffectPhase extends PokemonPhase {
const isOneHitKo = result === HitResult.ONE_HIT_KO;
target.lapseTags(BattlerTagLapseType.HIT);
const substituteTag = target.getTag(SubstituteTag);
const isBlockedBySubstitute = substituteTag && this.move.hitsSubstitute(user, target);
const substitute = target.getTag(SubstituteTag);
const isBlockedBySubstitute = !!substitute && this.move.hitsSubstitute(user, target);
if (isBlockedBySubstitute) {
user.turnData.lastMoveDamageDealt[target.getBattlerIndex()] += Math.min(dmg, substitute.hp);
substitute.hp -= dmg;

View File

@ -112,7 +112,7 @@ describe("Moves - Switching Moves", () => {
expect(game.scene.currentBattle.trainer).not.toBeNull();
const choiceSwitchSpy = vi.spyOn(game.scene.currentBattle.trainer!, "getNextSummonIndex");
// Grab each trainer's pokemon based on species name
// Grab each trainer's pokemon based on trainer slot
const [tateParty, lizaParty] = splitArray(
game.scene.getEnemyParty(),
pkmn => pkmn.trainerSlot === TrainerSlot.TRAINER,
@ -293,7 +293,7 @@ describe("Moves - Switching Moves", () => {
const player = game.field.getPlayerPokemon();
expect(player).toBe(raichu);
expect(player).not.toHaveFullHp();
expect(game.field.getEnemyPokemon().waveData.abilityRevealed).toBe(true); // proxy for asserting ability activated
expect(game.field.getEnemyPokemon()).toHaveAbilityApplied(AbilityId.ROUGH_SKIN);
});
});