revert optimization. it will be on other PR

This commit is contained in:
KimJeongSun 2024-09-28 02:07:02 +09:00
parent a75f0d2611
commit 37e9fa8f08

View File

@ -20,7 +20,6 @@ import { WeatherEffectPhase } from "./weather-effect-phase";
import { BattlerIndex } from "#app/battle"; import { BattlerIndex } from "#app/battle";
import { TrickRoomTag } from "#app/data/arena-tag"; import { TrickRoomTag } from "#app/data/arena-tag";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
import { applyChallenges, ChallengeType } from "#app/data/challenge";
export class TurnStartPhase extends FieldPhase { export class TurnStartPhase extends FieldPhase {
constructor(scene: BattleScene) { constructor(scene: BattleScene) {
@ -44,18 +43,20 @@ export class TurnStartPhase extends FieldPhase {
orderedTargets = Utils.randSeedShuffle(orderedTargets); orderedTargets = Utils.randSeedShuffle(orderedTargets);
}, this.scene.currentBattle.turn, this.scene.waveSeed); }, this.scene.currentBattle.turn, this.scene.waveSeed);
// Next, a check for Trick Room is applied to determine sort order. orderedTargets.sort((a: Pokemon, b: Pokemon) => {
const aSpeed = a?.getEffectiveStat(Stat.SPD) || 0;
const bSpeed = b?.getEffectiveStat(Stat.SPD) || 0;
return bSpeed - aSpeed;
});
// Next, a check for Trick Room is applied. If Trick Room is present, the order is reversed.
const speedReversed = new Utils.BooleanHolder(false); const speedReversed = new Utils.BooleanHolder(false);
this.scene.arena.applyTags(TrickRoomTag, speedReversed); this.scene.arena.applyTags(TrickRoomTag, speedReversed);
applyChallenges(this.scene.gameMode, ChallengeType.TRICK_ROOM, speedReversed);
// Adjust the sort function based on whether Trick Room is active. if (speedReversed.value) {
orderedTargets.sort((a: Pokemon, b: Pokemon) => { orderedTargets = orderedTargets.reverse();
const aSpeed = a?.getEffectiveStat(Stat.SPD) ?? 0; }
const bSpeed = b?.getEffectiveStat(Stat.SPD) ?? 0;
return speedReversed.value ? aSpeed - bSpeed : bSpeed - aSpeed;
});
return orderedTargets.map(t => t.getFieldIndex() + (!t.isPlayer() ? BattlerIndex.ENEMY : BattlerIndex.PLAYER)); return orderedTargets.map(t => t.getFieldIndex() + (!t.isPlayer() ? BattlerIndex.ENEMY : BattlerIndex.PLAYER));
} }