mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 06:49:35 +02:00
refactoring solution to be more consistent with coding style
This commit is contained in:
parent
5f905689df
commit
667ca3283d
@ -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;
|
||||
}
|
||||
|
@ -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<void> {
|
||||
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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user