diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index a1036420e44..a97438f1d05 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -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( diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 0d28467488f..d63a32c29b8 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -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; diff --git a/test/moves/force-switch.test.ts b/test/moves/force-switch.test.ts index 93daaf7f283..7cc20ced61a 100644 --- a/test/moves/force-switch.test.ts +++ b/test/moves/force-switch.test.ts @@ -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); }); });