[Misc] Clean up various phases (part 1) (#4797)

* Clean up various phases

Remove redundant code, utilize default parameters,
clean up some leftover `strict-null` `TODO`s,
replace `integer` with `number`

* Replace `* as Utils` imports with named imports

* Apply Biome
This commit is contained in:
NightKev 2025-04-05 20:10:52 -07:00 committed by GitHub
parent fdf8c1a695
commit 1e6ceb5581
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
51 changed files with 178 additions and 332 deletions

View File

@ -1526,8 +1526,6 @@ export default class BattleScene extends SceneBase {
this.currentBattle.mysteryEncounterType = mysteryEncounterType;
}
//this.pushPhase(new TrainerMessageTestPhase(this, TrainerType.RIVAL, TrainerType.RIVAL_2, TrainerType.RIVAL_3, TrainerType.RIVAL_4, TrainerType.RIVAL_5, TrainerType.RIVAL_6));
if (!waveIndex && lastBattle) {
const isWaveIndexMultipleOfTen = !(lastBattle.waveIndex % 10);
const isEndlessOrDaily = this.gameMode.hasShortBiomes || this.gameMode.isDaily;

View File

@ -9,10 +9,6 @@ import { Phase } from "#app/phase";
import { globalScene } from "#app/global-scene";
export class AddEnemyBuffModifierPhase extends Phase {
constructor() {
super();
}
start() {
super.start();

View File

@ -1,10 +1,10 @@
import { applyAbAttrs, applyPreLeaveFieldAbAttrs, PreLeaveFieldAbAttr, RunSuccessAbAttr } from "#app/data/ability";
import { Stat } from "#app/enums/stat";
import { StatusEffect } from "#app/enums/status-effect";
import { Stat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import type { PlayerPokemon, EnemyPokemon } from "#app/field/pokemon";
import type Pokemon from "#app/field/pokemon";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { NumberHolder } from "#app/utils";
import { BattleEndPhase } from "./battle-end-phase";
import { NewBattlePhase } from "./new-battle-phase";
import { PokemonPhase } from "./pokemon-phase";
@ -22,7 +22,7 @@ export class AttemptRunPhase extends PokemonPhase {
const playerPokemon = this.getPokemon();
const escapeChance = new Utils.NumberHolder(0);
const escapeChance = new NumberHolder(0);
this.attemptRunAway(playerField, enemyField, escapeChance);
@ -63,7 +63,7 @@ export class AttemptRunPhase extends PokemonPhase {
this.end();
}
attemptRunAway(playerField: PlayerPokemon[], enemyField: EnemyPokemon[], escapeChance: Utils.NumberHolder) {
attemptRunAway(playerField: PlayerPokemon[], enemyField: EnemyPokemon[], escapeChance: NumberHolder) {
/** Sum of the speed of all enemy pokemon on the field */
const enemySpeed = enemyField.reduce(
(total: number, enemyPokemon: Pokemon) => total + enemyPokemon.getStat(Stat.SPD),

View File

@ -26,13 +26,15 @@ export class BattleEndPhase extends BattlePhase {
return true;
});
// `phaseQueuePrepend` is private, so we have to use this inefficient loop.
while (globalScene.tryRemoveUnshiftedPhase(phase => {
if (phase instanceof BattleEndPhase) {
this.isVictory ||= phase.isVictory;
return true;
}
return false;
})) {}
while (
globalScene.tryRemoveUnshiftedPhase(phase => {
if (phase instanceof BattleEndPhase) {
this.isVictory ||= phase.isVictory;
return true;
}
return false;
})
) {}
globalScene.gameData.gameStats.battles++;
if (

View File

@ -3,13 +3,13 @@ import { TrainerSlot } from "#enums/trainer-slot";
import { Phase } from "#app/phase";
export class BattlePhase extends Phase {
constructor() {
super();
}
showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void {
const sprites = globalScene.currentBattle.trainer?.getSprites()!; // TODO: is this bang correct?
const tintSprites = globalScene.currentBattle.trainer?.getTintSprites()!; // TODO: is this bang correct?
if (!globalScene.currentBattle.trainer) {
console.warn("Enemy trainer is missing!");
return;
}
const sprites = globalScene.currentBattle.trainer.getSprites();
const tintSprites = globalScene.currentBattle.trainer.getTintSprites();
for (let i = 0; i < sprites.length; i++) {
const visible = !trainerSlot || !i === (trainerSlot === TrainerSlot.TRAINER) || sprites.length < 2;
[sprites[i], tintSprites[i]].map(sprite => {

View File

@ -4,7 +4,7 @@ import { BerryUsedEvent } from "#app/events/battle-scene";
import { getPokemonNameWithAffix } from "#app/messages";
import { BerryModifier } from "#app/modifier/modifier";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { BooleanHolder } from "#app/utils";
import { FieldPhase } from "./field-phase";
import { CommonAnimPhase } from "./common-anim-phase";
import { globalScene } from "#app/global-scene";
@ -20,7 +20,7 @@ export class BerryPhase extends FieldPhase {
}, pokemon.isPlayer());
if (hasUsableBerry) {
const cancelled = new Utils.BooleanHolder(false);
const cancelled = new BooleanHolder(false);
pokemon.getOpponents().map(opp => applyAbAttrs(PreventBerryUseAbAttr, opp, cancelled));
if (cancelled.value) {
@ -44,7 +44,7 @@ export class BerryPhase extends FieldPhase {
globalScene.updateModifiers(pokemon.isPlayer());
applyAbAttrs(HealFromBerryUseAbAttr, pokemon, new Utils.BooleanHolder(false));
applyAbAttrs(HealFromBerryUseAbAttr, pokemon, new BooleanHolder(false));
}
}
});

View File

@ -6,13 +6,18 @@ import { PokemonPhase } from "./pokemon-phase";
export class CommonAnimPhase extends PokemonPhase {
private anim: CommonAnim | null;
private targetIndex: number | undefined;
private targetIndex?: BattlerIndex;
private playOnEmptyField: boolean;
constructor(battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex, anim?: CommonAnim, playOnEmptyField = false) {
constructor(
battlerIndex?: BattlerIndex,
targetIndex?: BattlerIndex,
anim: CommonAnim | null = null,
playOnEmptyField = false,
) {
super(battlerIndex);
this.anim = anim!; // TODO: is this bang correct?
this.anim = anim;
this.targetIndex = targetIndex;
this.playOnEmptyField = playOnEmptyField;
}

View File

@ -10,11 +10,16 @@ export class DamageAnimPhase extends PokemonPhase {
private damageResult: DamageResult;
private critical: boolean;
constructor(battlerIndex: BattlerIndex, amount: number, damageResult?: DamageResult, critical = false) {
constructor(
battlerIndex: BattlerIndex,
amount: number,
damageResult: DamageResult = HitResult.EFFECTIVE,
critical = false,
) {
super(battlerIndex);
this.amount = amount;
this.damageResult = damageResult || HitResult.EFFECTIVE;
this.damageResult = damageResult;
this.critical = critical;
}

View File

@ -11,7 +11,7 @@ import PokemonInfoContainer from "#app/ui/pokemon-info-container";
import { Mode } from "#app/ui/ui";
import i18next from "i18next";
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import * as Utils from "#app/utils";
import { fixedInt, getFrameMs, randInt } from "#app/utils";
import type { EggLapsePhase } from "./egg-lapse-phase";
import type { EggHatchData } from "#app/data/egg-hatch-data";
import { doShinySparkleAnim } from "#app/field/anims";
@ -306,17 +306,17 @@ export class EggHatchPhase extends Phase {
this.canSkip = false;
this.hatched = true;
if (this.evolutionBgm) {
SoundFade.fadeOut(globalScene, this.evolutionBgm, Utils.fixedInt(100));
SoundFade.fadeOut(globalScene, this.evolutionBgm, fixedInt(100));
}
for (let e = 0; e < 5; e++) {
globalScene.time.delayedCall(Utils.fixedInt(375 * e), () =>
globalScene.time.delayedCall(fixedInt(375 * e), () =>
globalScene.playSound("se/egg_hatch", { volume: 1 - e * 0.2 }),
);
}
this.eggLightraysOverlay.setVisible(true);
this.eggLightraysOverlay.play("egg_lightrays");
globalScene.tweens.add({
duration: Utils.fixedInt(125),
duration: fixedInt(125),
targets: this.eggHatchOverlay,
alpha: 1,
ease: "Cubic.easeIn",
@ -325,7 +325,7 @@ export class EggHatchPhase extends Phase {
this.canSkip = true;
},
});
globalScene.time.delayedCall(Utils.fixedInt(1500), () => {
globalScene.time.delayedCall(fixedInt(1500), () => {
this.canSkip = false;
if (!this.skipped) {
this.doReveal();
@ -363,46 +363,43 @@ export class EggHatchPhase extends Phase {
this.pokemonSprite.setPipelineData("shiny", this.pokemon.shiny);
this.pokemonSprite.setPipelineData("variant", this.pokemon.variant);
this.pokemonSprite.setVisible(true);
globalScene.time.delayedCall(Utils.fixedInt(250), () => {
globalScene.time.delayedCall(fixedInt(250), () => {
this.eggsToHatchCount--;
this.eggHatchHandler.eventTarget.dispatchEvent(new EggCountChangedEvent(this.eggsToHatchCount));
this.pokemon.cry();
if (isShiny) {
globalScene.time.delayedCall(Utils.fixedInt(500), () => {
globalScene.time.delayedCall(fixedInt(500), () => {
doShinySparkleAnim(this.pokemonShinySparkle, this.pokemon.variant);
});
}
globalScene.time.delayedCall(
Utils.fixedInt(!this.skipped ? (!isShiny ? 1250 : 1750) : !isShiny ? 250 : 750),
() => {
this.infoContainer.show(this.pokemon, false, this.skipped ? 2 : 1);
globalScene.time.delayedCall(fixedInt(!this.skipped ? (!isShiny ? 1250 : 1750) : !isShiny ? 250 : 750), () => {
this.infoContainer.show(this.pokemon, false, this.skipped ? 2 : 1);
globalScene.playSoundWithoutBgm("evolution_fanfare");
globalScene.playSoundWithoutBgm("evolution_fanfare");
globalScene.ui.showText(
i18next.t("egg:hatchFromTheEgg", {
pokemonName: this.pokemon.species.getExpandedSpeciesName(),
}),
null,
() => {
globalScene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs);
globalScene.gameData.setPokemonCaught(this.pokemon, true, true).then(() => {
globalScene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex).then(value => {
this.eggHatchData.setEggMoveUnlocked(value);
globalScene.ui.showText("", 0);
this.end();
});
globalScene.ui.showText(
i18next.t("egg:hatchFromTheEgg", {
pokemonName: this.pokemon.species.getExpandedSpeciesName(),
}),
null,
() => {
globalScene.gameData.updateSpeciesDexIvs(this.pokemon.species.speciesId, this.pokemon.ivs);
globalScene.gameData.setPokemonCaught(this.pokemon, true, true).then(() => {
globalScene.gameData.setEggMoveUnlocked(this.pokemon.species, this.eggMoveIndex).then(value => {
this.eggHatchData.setEggMoveUnlocked(value);
globalScene.ui.showText("", 0);
this.end();
});
},
null,
true,
3000,
);
},
);
});
},
null,
true,
3000,
);
});
});
globalScene.tweens.add({
duration: Utils.fixedInt(this.skipped ? 500 : 3000),
duration: fixedInt(this.skipped ? 500 : 3000),
targets: this.eggHatchOverlay,
alpha: 0,
ease: "Cubic.easeOut",
@ -427,9 +424,9 @@ export class EggHatchPhase extends Phase {
doSpray(intensity: number, offsetY?: number) {
globalScene.tweens.addCounter({
repeat: intensity,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
this.doSprayParticle(Utils.randInt(8), offsetY || 0);
this.doSprayParticle(randInt(8), offsetY || 0);
},
});
}
@ -448,12 +445,12 @@ export class EggHatchPhase extends Phase {
let f = 0;
let yOffset = 0;
const speed = 3 - Utils.randInt(8);
const amp = 24 + Utils.randInt(32);
const speed = 3 - randInt(8);
const amp = 24 + randInt(32);
const particleTimer = globalScene.tweens.addCounter({
repeat: -1,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
updateParticle();
},

View File

@ -43,10 +43,10 @@ import { getNatureName } from "#app/data/nature";
export class EncounterPhase extends BattlePhase {
private loaded: boolean;
constructor(loaded?: boolean) {
constructor(loaded = false) {
super();
this.loaded = !!loaded;
this.loaded = loaded;
}
start() {

View File

@ -5,7 +5,7 @@ import { globalScene } from "#app/global-scene";
import type { SpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
import { FusionSpeciesFormEvolution } from "#app/data/balance/pokemon-evolutions";
import type EvolutionSceneHandler from "#app/ui/evolution-scene-handler";
import * as Utils from "#app/utils";
import { fixedInt, getFrameMs, randInt } from "#app/utils";
import { Mode } from "#app/ui/ui";
import { cos, sin } from "#app/field/anims";
import type { PlayerPokemon } from "#app/field/pokemon";
@ -332,9 +332,9 @@ export class EvolutionPhase extends Phase {
() => this.end(),
null,
true,
Utils.fixedInt(4000),
fixedInt(4000),
);
globalScene.time.delayedCall(Utils.fixedInt(4250), () => globalScene.playBgm());
globalScene.time.delayedCall(fixedInt(4250), () => globalScene.playBgm());
});
});
};
@ -392,7 +392,7 @@ export class EvolutionPhase extends Phase {
globalScene.tweens.addCounter({
repeat: 64,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
if (f < 64) {
if (!(f & 7)) {
@ -411,7 +411,7 @@ export class EvolutionPhase extends Phase {
globalScene.tweens.addCounter({
repeat: 96,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
if (f < 96) {
if (f < 6) {
@ -461,7 +461,7 @@ export class EvolutionPhase extends Phase {
globalScene.tweens.addCounter({
repeat: 48,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
if (!f) {
for (let i = 0; i < 16; i++) {
@ -482,14 +482,14 @@ export class EvolutionPhase extends Phase {
globalScene.tweens.addCounter({
repeat: 48,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
if (!f) {
for (let i = 0; i < 8; i++) {
this.doSprayParticle(i);
}
} else if (f < 50) {
this.doSprayParticle(Utils.randInt(8));
this.doSprayParticle(randInt(8));
}
f++;
},
@ -506,7 +506,7 @@ export class EvolutionPhase extends Phase {
const particleTimer = globalScene.tweens.addCounter({
repeat: -1,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
updateParticle();
},
@ -543,7 +543,7 @@ export class EvolutionPhase extends Phase {
const particleTimer = globalScene.tweens.addCounter({
repeat: -1,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
updateParticle();
},
@ -575,7 +575,7 @@ export class EvolutionPhase extends Phase {
const particleTimer = globalScene.tweens.addCounter({
repeat: -1,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
updateParticle();
},
@ -605,12 +605,12 @@ export class EvolutionPhase extends Phase {
let f = 0;
let yOffset = 0;
const speed = 3 - Utils.randInt(8);
const amp = 48 + Utils.randInt(64);
const speed = 3 - randInt(8);
const amp = 48 + randInt(64);
const particleTimer = globalScene.tweens.addCounter({
repeat: -1,
duration: Utils.getFrameMs(1),
duration: getFrameMs(1),
onRepeat: () => {
updateParticle();
},

View File

@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene";
import { getPokemonNameWithAffix } from "#app/messages";
import { ExpBoosterModifier } from "#app/modifier/modifier";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { NumberHolder } from "#app/utils";
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
import { LevelUpPhase } from "./level-up-phase";
@ -19,7 +19,7 @@ export class ExpPhase extends PlayerPartyMemberPokemonPhase {
super.start();
const pokemon = this.getPokemon();
const exp = new Utils.NumberHolder(this.expValue);
const exp = new NumberHolder(this.expValue);
globalScene.applyModifiers(ExpBoosterModifier, true, exp);
exp.value = Math.floor(exp.value);
globalScene.ui.showText(

View File

@ -1,5 +1,5 @@
import { globalScene } from "#app/global-scene";
import * as Utils from "../utils";
import { fixedInt } from "#app/utils";
import { achvs } from "../system/achv";
import type { SpeciesFormChange } from "../data/pokemon-forms";
import { getSpeciesFormChangeMessage } from "../data/pokemon-forms";
@ -9,7 +9,7 @@ import type PartyUiHandler from "../ui/party-ui-handler";
import { getPokemonNameWithAffix } from "../messages";
import { EndEvolutionPhase } from "./end-evolution-phase";
import { EvolutionPhase } from "./evolution-phase";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type";
import { SpeciesFormKey } from "#enums/species-form-key";
export class FormChangePhase extends EvolutionPhase {
@ -151,9 +151,9 @@ export class FormChangePhase extends EvolutionPhase {
() => this.end(),
null,
true,
Utils.fixedInt(delay),
fixedInt(delay),
);
globalScene.time.delayedCall(Utils.fixedInt(delay + 250), () =>
globalScene.time.delayedCall(fixedInt(delay + 250), () =>
globalScene.playBgm(),
);
});

View File

@ -20,7 +20,7 @@ import { UnlockPhase } from "#app/phases/unlock-phase";
import { achvs, ChallengeAchv } from "#app/system/achv";
import { Unlockables } from "#app/system/unlockables";
import { Mode } from "#app/ui/ui";
import * as Utils from "#app/utils";
import { isLocal, isLocalServerConnected } from "#app/utils";
import { PlayerGender } from "#enums/player-gender";
import { TrainerType } from "#enums/trainer-type";
import i18next from "i18next";
@ -219,7 +219,7 @@ export class GameOverPhase extends BattlePhase {
/* Added a local check to see if the game is running offline
If Online, execute apiFetch as intended
If Offline, execute offlineNewClear() only for victory, a localStorage implementation of newClear daily run checks */
if (!Utils.isLocal || Utils.isLocalServerConnected) {
if (!isLocal || isLocalServerConnected) {
pokerogueApi.savedata.session
.newclear({
slot: globalScene.sessionSlotId,

View File

@ -5,26 +5,26 @@ import { Phase } from "#app/phase";
import { handleTutorial, Tutorial } from "#app/tutorial";
import { Mode } from "#app/ui/ui";
import i18next, { t } from "i18next";
import * as Utils from "#app/utils";
import { getCookie, sessionIdKey, executeIf, removeCookie } from "#app/utils";
import { SelectGenderPhase } from "./select-gender-phase";
import { UnavailablePhase } from "./unavailable-phase";
export class LoginPhase extends Phase {
private showText: boolean;
constructor(showText?: boolean) {
constructor(showText = true) {
super();
this.showText = showText === undefined || !!showText;
this.showText = showText;
}
start(): void {
super.start();
const hasSession = !!Utils.getCookie(Utils.sessionIdKey);
const hasSession = !!getCookie(sessionIdKey);
globalScene.ui.setMode(Mode.LOADING, { buttonActions: [] });
Utils.executeIf(bypassLogin || hasSession, updateUserInfo).then(response => {
executeIf(bypassLogin || hasSession, updateUserInfo).then(response => {
const success = response ? response[0] : false;
const statusCode = response ? response[1] : null;
if (!success) {
@ -38,7 +38,7 @@ export class LoginPhase extends Phase {
const loadData = () => {
updateUserInfo().then(success => {
if (!success[0]) {
Utils.removeCookie(Utils.sessionIdKey);
removeCookie(sessionIdKey);
globalScene.reset(true, true);
return;
}
@ -60,7 +60,7 @@ export class LoginPhase extends Phase {
globalScene.ui.playSelect();
updateUserInfo().then(success => {
if (!success[0]) {
Utils.removeCookie(Utils.sessionIdKey);
removeCookie(sessionIdKey);
globalScene.reset(true, true);
return;
}
@ -89,7 +89,7 @@ export class LoginPhase extends Phase {
],
});
} else if (statusCode === 401) {
Utils.removeCookie(Utils.sessionIdKey);
removeCookie(sessionIdKey);
globalScene.reset(true, true);
} else {
globalScene.unshiftPhase(new UnavailablePhase());

View File

@ -3,9 +3,9 @@ import { Phase } from "#app/phase";
export class MessagePhase extends Phase {
private text: string;
private callbackDelay: number | null;
private prompt: boolean | null;
private promptDelay: number | null;
private callbackDelay?: number | null;
private prompt?: boolean | null;
private promptDelay?: number | null;
private speaker?: string;
constructor(
@ -18,9 +18,9 @@ export class MessagePhase extends Phase {
super();
this.text = text;
this.callbackDelay = callbackDelay!; // TODO: is this bang correct?
this.prompt = prompt!; // TODO: is this bang correct?
this.promptDelay = promptDelay!; // TODO: is this bang correct?
this.callbackDelay = callbackDelay;
this.prompt = prompt;
this.promptDelay = promptDelay;
this.speaker = speaker;
}

View File

@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene";
import { ArenaTagType } from "#app/enums/arena-tag-type";
import { MoneyMultiplierModifier } from "#app/modifier/modifier";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { NumberHolder } from "#app/utils";
import { BattlePhase } from "./battle-phase";
export class MoneyRewardPhase extends BattlePhase {
@ -15,7 +15,7 @@ export class MoneyRewardPhase extends BattlePhase {
}
start() {
const moneyAmount = new Utils.NumberHolder(globalScene.getWaveMoneyAmount(this.moneyMultiplier));
const moneyAmount = new NumberHolder(globalScene.getWaveMoneyAmount(this.moneyMultiplier));
globalScene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);

View File

@ -1,50 +0,0 @@
import { globalScene } from "#app/global-scene";
import { initMoveAnim, loadMoveAnimAssets, MoveAnim } from "#app/data/battle-anims";
import { allMoves, SelfStatusMove } from "#app/data/moves/move";
import { Moves } from "#app/enums/moves";
import * as Utils from "#app/utils";
import { BattlePhase } from "./battle-phase";
export class MoveAnimTestPhase extends BattlePhase {
private moveQueue: Moves[];
constructor(moveQueue?: Moves[]) {
super();
this.moveQueue = moveQueue || Utils.getEnumValues(Moves).slice(1);
}
start() {
const moveQueue = this.moveQueue.slice(0);
this.playMoveAnim(moveQueue, true);
}
playMoveAnim(moveQueue: Moves[], player: boolean) {
const moveId = player ? moveQueue[0] : moveQueue.shift();
if (moveId === undefined) {
this.playMoveAnim(this.moveQueue.slice(0), true);
return;
}
if (player) {
console.log(Moves[moveId]);
}
initMoveAnim(moveId).then(() => {
loadMoveAnimAssets([moveId], true).then(() => {
const user = player ? globalScene.getPlayerPokemon()! : globalScene.getEnemyPokemon()!;
const target =
player !== allMoves[moveId] instanceof SelfStatusMove
? globalScene.getEnemyPokemon()!
: globalScene.getPlayerPokemon()!;
new MoveAnim(moveId, user, target.getBattlerIndex()).play(allMoves[moveId].hitsSubstitute(user, target), () => {
// TODO: are the bangs correct here?
if (player) {
this.playMoveAnim(moveQueue, false);
} else {
this.playMoveAnim(moveQueue, true);
}
});
});
});
}
}

View File

@ -5,7 +5,7 @@ import type { BattlerIndex } from "#app/battle";
export class MoveEndPhase extends PokemonPhase {
private wasFollowUp: boolean;
constructor(battlerIndex: BattlerIndex, wasFollowUp: boolean = false) {
constructor(battlerIndex: BattlerIndex, wasFollowUp = false) {
super(battlerIndex);
this.wasFollowUp = wasFollowUp;
}

View File

@ -227,7 +227,7 @@ export class MovePhase extends BattlePhase {
(!this.pokemon.randSeedInt(4) || Overrides.STATUS_ACTIVATION_OVERRIDE === true) &&
Overrides.STATUS_ACTIVATION_OVERRIDE !== false;
break;
case StatusEffect.SLEEP:
case StatusEffect.SLEEP: {
applyMoveAttrs(BypassSleepAttr, this.pokemon, null, this.move.getMove());
const turnsRemaining = new NumberHolder(this.pokemon.status.sleepTurnsRemaining ?? 0);
applyAbAttrs(
@ -242,6 +242,7 @@ export class MovePhase extends BattlePhase {
healed = this.pokemon.status.sleepTurnsRemaining <= 0;
activated = !healed && !this.pokemon.getTag(BattlerTagType.BYPASS_SLEEP);
break;
}
case StatusEffect.FREEZE:
healed =
!!this.move

View File

@ -26,8 +26,7 @@ import { TrainerSlot } from "#enums/trainer-slot";
import { IvScannerModifier } from "../modifier/modifier";
import { Phase } from "../phase";
import { Mode } from "../ui/ui";
import * as Utils from "../utils";
import { isNullOrUndefined } from "../utils";
import { isNullOrUndefined, randSeedItem } from "#app/utils";
/**
* Will handle (in order):
@ -387,7 +386,7 @@ export class MysteryEncounterBattlePhase extends Phase {
const trainer = globalScene.currentBattle.trainer;
let message: string;
globalScene.executeWithSeedOffset(
() => (message = Utils.randSeedItem(encounterMessages)),
() => (message = randSeedItem(encounterMessages)),
globalScene.currentBattle.mysteryEncounter?.getSeedOffset(),
);
message = message!; // tell TS compiler it's defined now

View File

@ -4,10 +4,6 @@ import { getRandomWeatherType } from "#app/data/weather";
import { NextEncounterPhase } from "./next-encounter-phase";
export class NewBiomeEncounterPhase extends NextEncounterPhase {
constructor() {
super();
}
doEncounter(): void {
globalScene.playBgm(undefined, true);

View File

@ -2,10 +2,6 @@ import { globalScene } from "#app/global-scene";
import { EncounterPhase } from "./encounter-phase";
export class NextEncounterPhase extends EncounterPhase {
constructor() {
super();
}
start() {
super.start();
}

View File

@ -1,5 +1,5 @@
import { globalScene } from "#app/global-scene";
import * as Utils from "#app/utils";
import { fixedInt } from "#app/utils";
import { BattlePhase } from "./battle-phase";
export class PartyHealPhase extends BattlePhase {
@ -28,7 +28,7 @@ export class PartyHealPhase extends BattlePhase {
pokemon.updateInfo(true);
}
const healSong = globalScene.playSoundWithoutBgm("heal");
globalScene.time.delayedCall(Utils.fixedInt(healSong.totalDuration * 1000), () => {
globalScene.time.delayedCall(fixedInt(healSong.totalDuration * 1000), () => {
healSong.destroy();
if (this.resumeBgm && bgmPlaying) {
globalScene.playBgm();

View File

@ -8,18 +8,18 @@ import { Species } from "#enums/species";
export class PokemonAnimPhase extends BattlePhase {
/** The type of animation to play in this phase */
private key: PokemonAnimType;
protected key: PokemonAnimType;
/** The Pokemon to which this animation applies */
private pokemon: Pokemon;
protected pokemon: Pokemon;
/** Any other field sprites affected by this animation */
private fieldAssets: Phaser.GameObjects.Sprite[];
protected fieldAssets: Phaser.GameObjects.Sprite[];
constructor(key: PokemonAnimType, pokemon: Pokemon, fieldAssets?: Phaser.GameObjects.Sprite[]) {
constructor(key: PokemonAnimType, pokemon: Pokemon, fieldAssets: Phaser.GameObjects.Sprite[] = []) {
super();
this.key = key;
this.pokemon = pokemon;
this.fieldAssets = fieldAssets ?? [];
this.fieldAssets = fieldAssets;
}
start(): void {

View File

@ -8,7 +8,7 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { HealingBoosterModifier } from "#app/modifier/modifier";
import { HealAchv } from "#app/system/achv";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { NumberHolder } from "#app/utils";
import { CommonAnimPhase } from "./common-anim-phase";
import { BattlerTagType } from "#app/enums/battler-tag-type";
import type { HealBlockTag } from "#app/data/battler-tags";
@ -72,11 +72,11 @@ export class PokemonHealPhase extends CommonAnimPhase {
return super.end();
}
if (healOrDamage) {
const hpRestoreMultiplier = new Utils.NumberHolder(1);
const hpRestoreMultiplier = new NumberHolder(1);
if (!this.revive) {
globalScene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier);
}
const healAmount = new Utils.NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value));
const healAmount = new NumberHolder(Math.floor(this.hpHealed * hpRestoreMultiplier.value));
if (healAmount.value < 0) {
pokemon.damageAndUpdate(healAmount.value * -1, { result: HitResult.INDIRECT });
healAmount.value = 0;

View File

@ -11,11 +11,14 @@ export abstract class PokemonPhase extends FieldPhase {
constructor(battlerIndex?: BattlerIndex | number) {
super();
if (battlerIndex === undefined) {
battlerIndex = globalScene
battlerIndex =
battlerIndex ??
globalScene
.getField()
.find(p => p?.isActive())!
.getBattlerIndex(); // TODO: is the bang correct here?
.find(p => p?.isActive())! // TODO: is the bang correct here?
.getBattlerIndex();
if (battlerIndex === undefined) {
console.warn("There are no Pokemon on the field!"); // TODO: figure out a suitable fallback behavior
}
this.battlerIndex = battlerIndex;

View File

@ -4,12 +4,12 @@ import type { EndCardPhase } from "./end-card-phase";
import { TitlePhase } from "./title-phase";
export class PostGameOverPhase extends Phase {
private endCardPhase: EndCardPhase | null;
private endCardPhase?: EndCardPhase;
constructor(endCardPhase?: EndCardPhase) {
super();
this.endCardPhase = endCardPhase!; // TODO: is this bang correct?
this.endCardPhase = endCardPhase;
}
start() {

View File

@ -13,7 +13,7 @@ import { getStatusEffectActivationText } from "#app/data/status-effect";
import { BattleSpec } from "#app/enums/battle-spec";
import { StatusEffect } from "#app/enums/status-effect";
import { getPokemonNameWithAffix } from "#app/messages";
import * as Utils from "#app/utils";
import { BooleanHolder, NumberHolder } from "#app/utils";
import { PokemonPhase } from "./pokemon-phase";
export class PostTurnStatusEffectPhase extends PokemonPhase {
@ -26,7 +26,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
const pokemon = this.getPokemon();
if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn() && !pokemon.switchOutStatus) {
pokemon.status.incrementTurn();
const cancelled = new Utils.BooleanHolder(false);
const cancelled = new BooleanHolder(false);
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled);
applyAbAttrs(BlockStatusDamageAbAttr, pokemon, cancelled);
@ -34,7 +34,7 @@ export class PostTurnStatusEffectPhase extends PokemonPhase {
globalScene.queueMessage(
getStatusEffectActivationText(pokemon.status.effect, getPokemonNameWithAffix(pokemon)),
);
const damage = new Utils.NumberHolder(0);
const damage = new NumberHolder(0);
switch (pokemon.status.effect) {
case StatusEffect.POISON:
damage.value = Math.max(pokemon.getMaxHp() >> 3, 1);

View File

@ -1,15 +1,15 @@
import { globalScene } from "#app/global-scene";
import { Phase } from "#app/phase";
import { Mode } from "#app/ui/ui";
import * as Utils from "#app/utils";
import { fixedInt } from "#app/utils";
export class ReloadSessionPhase extends Phase {
private systemDataStr: string | null;
private systemDataStr?: string;
constructor(systemDataStr?: string) {
super();
this.systemDataStr = systemDataStr ?? null;
this.systemDataStr = systemDataStr;
}
start(): void {
@ -18,7 +18,7 @@ export class ReloadSessionPhase extends Phase {
let delayElapsed = false;
let loaded = false;
globalScene.time.delayedCall(Utils.fixedInt(1500), () => {
globalScene.time.delayedCall(fixedInt(1500), () => {
if (loaded) {
this.end();
} else {

View File

@ -8,6 +8,7 @@ import i18next from "i18next";
import { PokemonPhase } from "./pokemon-phase";
export class ScanIvsPhase extends PokemonPhase {
// biome-ignore lint/complexity/noUselessConstructor: This changes `battlerIndex` to be required
constructor(battlerIndex: BattlerIndex) {
super(battlerIndex);
}
@ -24,7 +25,8 @@ export class ScanIvsPhase extends PokemonPhase {
const uiTheme = globalScene.uiTheme; // Assuming uiTheme is accessible
for (let e = 0; e < enemyField.length; e++) {
enemyIvs = enemyField[e].ivs;
const currentIvs = globalScene.gameData.dexData[enemyField[e].species.getRootSpeciesId()].ivs; // we are using getRootSpeciesId() here because we want to check against the baby form, not the mid form if it exists
// we are using getRootSpeciesId() here because we want to check against the baby form, not the mid form if it exists
const currentIvs = globalScene.gameData.dexData[enemyField[e].species.getRootSpeciesId()].ivs;
statsContainer = enemyField[e].getBattleInfo().getStatsValueContainer().list as Phaser.GameObjects.Sprite[];
statsContainerLabels = statsContainer.filter(m => m.name.indexOf("icon_stat_label") >= 0);
for (let s = 0; s < statsContainerLabels.length; s++) {

View File

@ -5,15 +5,11 @@ import { MoneyInterestModifier, MapModifier } from "#app/modifier/modifier";
import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { Mode } from "#app/ui/ui";
import { BattlePhase } from "./battle-phase";
import * as Utils from "#app/utils";
import { randSeedInt } from "#app/utils";
import { PartyHealPhase } from "./party-heal-phase";
import { SwitchBiomePhase } from "./switch-biome-phase";
export class SelectBiomePhase extends BattlePhase {
constructor() {
super();
}
start() {
super.start();
@ -40,7 +36,7 @@ export class SelectBiomePhase extends BattlePhase {
let biomes: Biome[] = [];
globalScene.executeWithSeedOffset(() => {
biomes = (biomeLinks[currentBiome] as (Biome | [Biome, number])[])
.filter(b => !Array.isArray(b) || !Utils.randSeedInt(b[1]))
.filter(b => !Array.isArray(b) || !randSeedInt(b[1]))
.map(b => (!Array.isArray(b) ? b : b[0]));
}, globalScene.currentBattle.waveIndex);
if (biomes.length > 1 && globalScene.findModifier(m => m instanceof MapModifier)) {
@ -51,7 +47,7 @@ export class SelectBiomePhase extends BattlePhase {
? [biomeLinks[currentBiome] as Biome]
: (biomeLinks[currentBiome] as (Biome | [Biome, number])[])
)
.filter((b, _i) => !Array.isArray(b) || !Utils.randSeedInt(b[1]))
.filter(b => !Array.isArray(b) || !randSeedInt(b[1]))
.map(b => (Array.isArray(b) ? b[0] : b));
}, globalScene.currentBattle.waveIndex);
const biomeSelectItems = biomeChoices.map(b => {
@ -70,7 +66,7 @@ export class SelectBiomePhase extends BattlePhase {
delay: 1000,
});
} else {
setNextBiome(biomes[Utils.randSeedInt(biomes.length)]);
setNextBiome(biomes[randSeedInt(biomes.length)]);
}
} else if (biomeLinks.hasOwnProperty(currentBiome)) {
setNextBiome(biomeLinks[currentBiome] as Biome);

View File

@ -3,10 +3,6 @@ import { Phase } from "#app/phase";
import { Mode } from "#app/ui/ui";
export class SelectChallengePhase extends Phase {
constructor() {
super();
}
start() {
super.start();

View File

@ -6,10 +6,6 @@ import { Mode } from "#app/ui/ui";
import i18next from "i18next";
export class SelectGenderPhase extends Phase {
constructor() {
super();
}
start(): void {
super.start();

View File

@ -26,7 +26,6 @@ import { SHOP_OPTIONS_ROW_LIMIT } from "#app/ui/modifier-select-ui-handler";
import PartyUiHandler, { PartyUiMode, PartyOption } from "#app/ui/party-ui-handler";
import { Mode } from "#app/ui/ui";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { BattlePhase } from "./battle-phase";
import Overrides from "#app/overrides";
import type { CustomModifierSettings } from "#app/modifier/modifier-type";
@ -67,7 +66,7 @@ export class SelectModifierPhase extends BattlePhase {
if (!this.isCopy) {
regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount);
}
const modifierCount = new Utils.NumberHolder(3);
const modifierCount = new NumberHolder(3);
if (this.isPlayer()) {
globalScene.applyModifiers(ExtraModifierModifier, true, modifierCount);
globalScene.applyModifiers(TempExtraModifierModifier, true, modifierCount);

View File

@ -15,10 +15,6 @@ import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import * as Utils from "../utils";
export class SelectStarterPhase extends Phase {
constructor() {
super();
}
start() {
super.start();

View File

@ -8,6 +8,7 @@ import i18next from "#app/plugins/i18n";
import { allMoves } from "#app/data/moves/move";
export class SelectTargetPhase extends PokemonPhase {
// biome-ignore lint/complexity/noUselessConstructor: This makes `fieldIndex` required
constructor(fieldIndex: number) {
super(fieldIndex);
}

View File

@ -3,6 +3,7 @@ import type { BattlerIndex } from "#app/battle";
import { PokemonPhase } from "./pokemon-phase";
export class ShinySparklePhase extends PokemonPhase {
// biome-ignore lint/complexity/noUselessConstructor: This makes `battlerIndex` required
constructor(battlerIndex: BattlerIndex) {
super(battlerIndex);
}

View File

@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene";
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
import { ExpNotification } from "#app/enums/exp-notification";
import { ExpBoosterModifier } from "#app/modifier/modifier";
import * as Utils from "#app/utils";
import { NumberHolder } from "#app/utils";
import { HidePartyExpBarPhase } from "./hide-party-exp-bar-phase";
import { LevelUpPhase } from "./level-up-phase";
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
@ -20,7 +20,7 @@ export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase {
super.start();
const pokemon = this.getPokemon();
const exp = new Utils.NumberHolder(this.expValue);
const exp = new NumberHolder(this.expValue);
globalScene.applyModifiers(ExpBoosterModifier, true, exp);
exp.value = Math.floor(exp.value);

View File

@ -3,10 +3,6 @@ import { PlayerGender } from "#app/enums/player-gender";
import { BattlePhase } from "./battle-phase";
export class ShowTrainerPhase extends BattlePhase {
constructor() {
super();
}
start() {
super.start();

View File

@ -4,10 +4,6 @@ import { SummonPhase } from "./summon-phase";
import { globalScene } from "#app/global-scene";
export class SummonMissingPhase extends SummonPhase {
constructor(fieldIndex: number) {
super(fieldIndex);
}
preSummon(): void {
globalScene.ui.showText(
i18next.t("battle:sendOutPokemon", {

View File

@ -23,11 +23,11 @@ export class SwitchSummonPhase extends SummonPhase {
/**
* Constructor for creating a new SwitchSummonPhase
* @param switchType the type of switch behavior
* @param fieldIndex integer representing position on the battle field
* @param slotIndex integer for the index of pokemon (in party of 6) to switch into
* @param doReturn boolean whether to render "comeback" dialogue
* @param player boolean if the switch is from the player
* @param switchType - The type of switch behavior
* @param fieldIndex - Position on the battle field
* @param slotIndex - The index of pokemon (in party of 6) to switch into
* @param doReturn - Whether to render "comeback" dialogue
* @param player - (Optional) `true` if the switch is from the player
*/
constructor(switchType: SwitchType, fieldIndex: number, slotIndex: number, doReturn: boolean, player?: boolean) {
super(fieldIndex, player !== undefined ? player : true);

View File

@ -1,7 +0,0 @@
import { MessagePhase } from "./message-phase";
export class TestMessagePhase extends MessagePhase {
constructor(message: string) {
super(message, null, true);
}
}

View File

@ -18,7 +18,7 @@ import { vouchers } from "#app/system/voucher";
import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler";
import { Mode } from "#app/ui/ui";
import * as Utils from "#app/utils";
import { isLocal, isLocalServerConnected, isNullOrUndefined } from "#app/utils";
import i18next from "i18next";
import { CheckSwitchPhase } from "./check-switch-phase";
import { EncounterPhase } from "./encounter-phase";
@ -29,16 +29,10 @@ import { globalScene } from "#app/global-scene";
import Overrides from "#app/overrides";
export class TitlePhase extends Phase {
private loaded: boolean;
private loaded = false;
private lastSessionData: SessionSaveData;
public gameMode: GameModes;
constructor() {
super();
this.loaded = false;
}
start(): void {
super.start();
@ -282,7 +276,7 @@ export class TitlePhase extends Phase {
};
// If Online, calls seed fetch from db to generate daily run. If Offline, generates a daily run based on current date.
if (!Utils.isLocal || Utils.isLocalServerConnected) {
if (!isLocal || isLocalServerConnected) {
fetchDailyRunSeed()
.then(seed => {
if (seed) {
@ -296,7 +290,7 @@ export class TitlePhase extends Phase {
});
} else {
let seed: string = btoa(new Date().toISOString().substring(0, 10));
if (!Utils.isNullOrUndefined(Overrides.DAILY_RUN_SEED_OVERRIDE)) {
if (!isNullOrUndefined(Overrides.DAILY_RUN_SEED_OVERRIDE)) {
seed = Overrides.DAILY_RUN_SEED_OVERRIDE;
}
generateDaily(seed);

View File

@ -1,47 +0,0 @@
import { globalScene } from "#app/global-scene";
import { trainerConfigs } from "#app/data/trainers/trainer-config";
import type { TrainerType } from "#app/enums/trainer-type";
import { BattlePhase } from "./battle-phase";
import { TestMessagePhase } from "./test-message-phase";
export class TrainerMessageTestPhase extends BattlePhase {
private trainerTypes: TrainerType[];
constructor(...trainerTypes: TrainerType[]) {
super();
this.trainerTypes = trainerTypes;
}
start() {
super.start();
const testMessages: string[] = [];
for (const t of Object.keys(trainerConfigs)) {
const type = Number.parseInt(t);
if (this.trainerTypes.length && !this.trainerTypes.find(tt => tt === (type as TrainerType))) {
continue;
}
const config = trainerConfigs[type];
[
config.encounterMessages,
config.femaleEncounterMessages,
config.victoryMessages,
config.femaleVictoryMessages,
config.defeatMessages,
config.femaleDefeatMessages,
].map(messages => {
if (messages?.length) {
testMessages.push(...messages);
}
});
}
for (const message of testMessages) {
globalScene.pushPhase(new TestMessagePhase(message));
}
this.end();
}
}

View File

@ -3,7 +3,7 @@ import { TrainerType } from "#app/enums/trainer-type";
import { modifierTypes } from "#app/modifier/modifier-type";
import { vouchers } from "#app/system/voucher";
import i18next from "i18next";
import * as Utils from "#app/utils";
import { randSeedItem } from "#app/utils";
import { BattlePhase } from "./battle-phase";
import { ModifierRewardPhase } from "./modifier-reward-phase";
import { MoneyRewardPhase } from "./money-reward-phase";
@ -14,10 +14,6 @@ import { achvs } from "#app/system/achv";
import { timedEventManager } from "#app/global-event-manager";
export class TrainerVictoryPhase extends BattlePhase {
constructor() {
super();
}
start() {
globalScene.disableMenu = true;
@ -82,7 +78,7 @@ export class TrainerVictoryPhase extends BattlePhase {
const victoryMessages = globalScene.currentBattle.trainer?.getVictoryMessages()!; // TODO: is this bang correct?
let message: string;
globalScene.executeWithSeedOffset(
() => (message = Utils.randSeedItem(victoryMessages)),
() => (message = randSeedItem(victoryMessages)),
globalScene.currentBattle.waveIndex,
);
message = message!; // tell TS compiler it's defined now

View File

@ -18,10 +18,6 @@ import { PokemonHealPhase } from "./pokemon-heal-phase";
import { globalScene } from "#app/global-scene";
export class TurnEndPhase extends FieldPhase {
constructor() {
super();
}
start() {
super.start();

View File

@ -15,10 +15,6 @@ import { TurnStartPhase } from "./turn-start-phase";
import { globalScene } from "#app/global-scene";
export class TurnInitPhase extends FieldPhase {
constructor() {
super();
}
start() {
super.start();

View File

@ -6,7 +6,7 @@ import type Pokemon from "#app/field/pokemon";
import { PokemonMove } from "#app/field/pokemon";
import { BypassSpeedChanceModifier } from "#app/modifier/modifier";
import { Command } from "#app/ui/command-ui-handler";
import * as Utils from "#app/utils";
import { randSeedShuffle, BooleanHolder } from "#app/utils";
import { AttemptCapturePhase } from "./attempt-capture-phase";
import { AttemptRunPhase } from "./attempt-run-phase";
import { BerryPhase } from "./berry-phase";
@ -24,10 +24,6 @@ import { globalScene } from "#app/global-scene";
import { TeraPhase } from "./tera-phase";
export class TurnStartPhase extends FieldPhase {
constructor() {
super();
}
/**
* This orders the active Pokemon on the field by speed into an BattlerIndex array and returns that array.
* It also checks for Trick Room and reverses the array if it is present.
@ -43,14 +39,14 @@ export class TurnStartPhase extends FieldPhase {
// was varying based on how long since you last reloaded
globalScene.executeWithSeedOffset(
() => {
orderedTargets = Utils.randSeedShuffle(orderedTargets);
orderedTargets = randSeedShuffle(orderedTargets);
},
globalScene.currentBattle.turn,
globalScene.waveSeed,
);
// Next, a check for Trick Room is applied to determine sort order.
const speedReversed = new Utils.BooleanHolder(false);
const speedReversed = new BooleanHolder(false);
globalScene.arena.applyTags(TrickRoomTag, false, speedReversed);
// Adjust the sort function based on whether Trick Room is active.
@ -80,8 +76,8 @@ export class TurnStartPhase extends FieldPhase {
.getField(true)
.filter(p => p.summonData)
.map(p => {
const bypassSpeed = new Utils.BooleanHolder(false);
const canCheckHeldItems = new Utils.BooleanHolder(true);
const bypassSpeed = new BooleanHolder(false);
const canCheckHeldItems = new BooleanHolder(true);
applyAbAttrs(BypassSpeedChanceAbAttr, p, null, false, bypassSpeed);
applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, false, bypassSpeed, canCheckHeldItems);
if (canCheckHeldItems.value) {

View File

@ -4,10 +4,6 @@ import { Mode } from "#app/ui/ui";
import { LoginPhase } from "./login-phase";
export class UnavailablePhase extends Phase {
constructor() {
super();
}
start(): void {
globalScene.ui.setMode(Mode.UNAVAILABLE, () => {
globalScene.unshiftPhase(new LoginPhase(true));

View File

@ -15,7 +15,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type";
import { WeatherType } from "#app/enums/weather-type";
import type Pokemon from "#app/field/pokemon";
import { HitResult } from "#app/field/pokemon";
import * as Utils from "#app/utils";
import { BooleanHolder, toDmgValue } from "#app/utils";
import { CommonAnimPhase } from "./common-anim-phase";
export class WeatherEffectPhase extends CommonAnimPhase {
@ -35,14 +35,13 @@ export class WeatherEffectPhase extends CommonAnimPhase {
this.weather = globalScene?.arena?.weather;
if (!this.weather) {
this.end();
return;
return this.end();
}
this.setAnimation(CommonAnim.SUNNY + (this.weather.weatherType - 1));
if (this.weather.isDamaging()) {
const cancelled = new Utils.BooleanHolder(false);
const cancelled = new BooleanHolder(false);
this.executeForAll((pokemon: Pokemon) =>
applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, pokemon, this.weather, cancelled),
@ -50,7 +49,7 @@ export class WeatherEffectPhase extends CommonAnimPhase {
if (!cancelled.value) {
const inflictDamage = (pokemon: Pokemon) => {
const cancelled = new Utils.BooleanHolder(false);
const cancelled = new BooleanHolder(false);
applyPreWeatherEffectAbAttrs(PreWeatherDamageAbAttr, pokemon, this.weather, cancelled);
applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled);
@ -63,9 +62,9 @@ export class WeatherEffectPhase extends CommonAnimPhase {
return;
}
const damage = Utils.toDmgValue(pokemon.getMaxHp() / 16);
const damage = toDmgValue(pokemon.getMaxHp() / 16);
globalScene.queueMessage(getWeatherDamageMessage(this.weather?.weatherType!, pokemon)!); // TODO: are those bangs correct?
globalScene.queueMessage(getWeatherDamageMessage(this.weather!.weatherType, pokemon) ?? "");
pokemon.damageAndUpdate(damage, { result: HitResult.INDIRECT, ignoreSegments: true });
};