diff --git a/src/data/ability.ts b/src/data/ability.ts index 5d2ccfc9d36..3c71b880a98 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -3594,7 +3594,13 @@ export class PostTurnStatStageChangeAbAttr extends PostTurnAbAttr { applyPostTurn(pokemon: Pokemon, passive: boolean, simulated: boolean, args: any[]): boolean { if (!simulated) { - pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.stages)); + if (!pokemon.hasAbility(Abilities.SPEED_BOOST)) { + pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.stages)); + } else if (pokemon.hasAbility(Abilities.SPEED_BOOST) && !pokemon.turnData.switchedInThisTurn && !pokemon.turnData.failedRunAway) { + pokemon.scene.unshiftPhase(new StatStageChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, this.stats, this.stages)); + } else { + this.showAbility = false; + } } return true; } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index e52457851bb..b27e92fc204 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -105,8 +105,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public pauseEvolutions: boolean; public pokerus: boolean; public switchOutStatus: boolean; - public switchedInThisTurn: boolean; - public failedRunAway: boolean; public evoCounter: integer; public fusionSpecies: PokemonSpecies | null; @@ -154,7 +152,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL; this.level = level; this.switchOutStatus = false; - this.switchedInThisTurn = false; // Determine the ability index if (abilityIndex !== undefined) { @@ -2254,10 +2251,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.switchOutStatus = status; } - setSwitchedInStatus(status: boolean): void { - this.switchedInThisTurn = status; - } - updateInfo(instant?: boolean): Promise { return this.battleInfo.updateInfo(this, instant); } @@ -5073,6 +5066,8 @@ export class PokemonTurnData { public statStagesDecreased: boolean = false; public moveEffectiveness: TypeDamageMultiplier | null = null; public combiningPledge?: Moves; + public switchedInThisTurn: boolean = false; + public failedRunAway: boolean = false; } export enum AiType { diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 553c9899db9..44cb014083d 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -54,7 +54,7 @@ export class AttemptRunPhase extends PokemonPhase { this.scene.pushPhase(new BattleEndPhase(this.scene)); this.scene.pushPhase(new NewBattlePhase(this.scene)); } else { - playerPokemon.failedRunAway = true; + playerPokemon.turnData.failedRunAway = true; this.scene.queueMessage(i18next.t("battle:runAwayCannotEscape"), null, true, 500); } diff --git a/src/phases/summon-phase.ts b/src/phases/summon-phase.ts index 119e550293c..ed6a6ff8d46 100644 --- a/src/phases/summon-phase.ts +++ b/src/phases/summon-phase.ts @@ -238,7 +238,10 @@ export class SummonPhase extends PartyMemberPokemonPhase { this.scene.unshiftPhase(new ShinySparklePhase(this.scene, pokemon.getBattlerIndex())); } + /** Switch in status is set before the pokemon is summoned and the new turn begins, so it is preserved from switch-summon-phase */ + const switchedInStatus = pokemon.turnData?.switchedInThisTurn; pokemon.resetTurnData(); + pokemon.turnData.switchedInThisTurn = switchedInStatus; if (!this.loaded || [ BattleType.TRAINER, BattleType.MYSTERY_ENCOUNTER ].includes(this.scene.currentBattle.battleType) || (this.scene.currentBattle.waveIndex % 10) === 1) { this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger, true); diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index c3b22dadc79..137265d409a 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -106,9 +106,9 @@ export class SwitchSummonPhase extends SummonPhase { const switchedInPokemon = party[this.slotIndex]; this.lastPokemon = this.getPokemon(); if (this.switchType !== SwitchType.INITIAL_SWITCH) { - switchedInPokemon.setSwitchedInStatus(true); + switchedInPokemon.resetTurnData(); + switchedInPokemon.turnData.switchedInThisTurn = true; } - this.lastPokemon.setSwitchedInStatus(false); applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this.lastPokemon); if (this.switchType === SwitchType.BATON_PASS && switchedInPokemon) { (this.player ? this.scene.getEnemyField() : this.scene.getPlayerField()).forEach(enemyPokemon => enemyPokemon.transferTagsBySourceId(this.lastPokemon.id, switchedInPokemon.id)); diff --git a/src/phases/turn-end-phase.ts b/src/phases/turn-end-phase.ts index 4c8e87b538b..60a2e6600db 100644 --- a/src/phases/turn-end-phase.ts +++ b/src/phases/turn-end-phase.ts @@ -10,7 +10,6 @@ import { TurnHealModifier, EnemyTurnHealModifier, EnemyStatusEffectHealChanceMod import i18next from "i18next"; import { FieldPhase } from "./field-phase"; import { PokemonHealPhase } from "./pokemon-heal-phase"; -import { Abilities } from "#app/enums/abilities"; export class TurnEndPhase extends FieldPhase { constructor(scene: BattleScene) { @@ -38,16 +37,7 @@ export class TurnEndPhase extends FieldPhase { this.scene.applyModifier(EnemyStatusEffectHealChanceModifier, false, pokemon); } - if (!pokemon.hasAbility(Abilities.SPEED_BOOST)) { - applyPostTurnAbAttrs(PostTurnAbAttr, pokemon); - } else if (pokemon.hasAbility(Abilities.SPEED_BOOST) && !pokemon.switchedInThisTurn && !pokemon.failedRunAway) { - pokemon.setSwitchedInStatus(false); - pokemon.failedRunAway = false; - applyPostTurnAbAttrs(PostTurnAbAttr, pokemon); - } else { - pokemon.failedRunAway = false; - pokemon.setSwitchedInStatus(false); - } + applyPostTurnAbAttrs(PostTurnAbAttr, pokemon); this.scene.applyModifiers(TurnStatusEffectModifier, pokemon.isPlayer(), pokemon);