diff --git a/src/battle-scene.ts b/src/battle-scene.ts index d82acec1c20..9be72366965 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1261,8 +1261,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; diff --git a/src/phases/attempt-capture-phase.ts b/src/phases/attempt-capture-phase.ts index 483e6eac943..7e7faddb01b 100644 --- a/src/phases/attempt-capture-phase.ts +++ b/src/phases/attempt-capture-phase.ts @@ -23,7 +23,7 @@ export class AttemptCapturePhase extends PokemonPhase { private pokeball: Phaser.GameObjects.Sprite; private originalY: number; - constructor(scene: BattleScene, targetIndex: integer, pokeballType: PokeballType) { + constructor(scene: BattleScene, targetIndex: number, pokeballType: PokeballType) { super(scene, BattlerIndex.ENEMY + targetIndex); this.pokeballType = pokeballType; @@ -160,7 +160,7 @@ export class AttemptCapturePhase extends PokemonPhase { }); } - failCatch(shakeCount: integer) { + failCatch(shakeCount: number) { const pokemon = this.getPokemon(); this.scene.playSound("se/pb_rel"); @@ -262,7 +262,7 @@ export class AttemptCapturePhase extends PokemonPhase { }); }, false); }, () => { - this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => { + this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: number, _option: PartyOption) => { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (slotIndex < 6) { addToParty(slotIndex); diff --git a/src/phases/battle-phase.ts b/src/phases/battle-phase.ts index 11807fdc714..708e0d2afed 100644 --- a/src/phases/battle-phase.ts +++ b/src/phases/battle-phase.ts @@ -8,8 +8,12 @@ export class BattlePhase extends Phase { } showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void { - const sprites = this.scene.currentBattle.trainer?.getSprites()!; // TODO: is this bang correct? - const tintSprites = this.scene.currentBattle.trainer?.getTintSprites()!; // TODO: is this bang correct? + if (!this.scene.currentBattle.trainer) { + console.warn("Enemy trainer is missing!"); + return; + } + const sprites = this.scene.currentBattle.trainer.getSprites(); + const tintSprites = this.scene.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 => { diff --git a/src/phases/check-status-effect-phase.ts b/src/phases/check-status-effect-phase.ts index 44918b54966..8b6d4bf08c4 100644 --- a/src/phases/check-status-effect-phase.ts +++ b/src/phases/check-status-effect-phase.ts @@ -4,10 +4,9 @@ import { BattlerIndex } from "#app/battle"; import BattleScene from "#app/battle-scene"; export class CheckStatusEffectPhase extends Phase { - private order : BattlerIndex[]; - constructor(scene : BattleScene, order : BattlerIndex[]) { + private order: BattlerIndex[]; + constructor(scene: BattleScene, order: BattlerIndex[]) { super(scene); - this.scene = scene; this.order = order; } diff --git a/src/phases/check-switch-phase.ts b/src/phases/check-switch-phase.ts index b87dff32f60..9ae720fbe8e 100644 --- a/src/phases/check-switch-phase.ts +++ b/src/phases/check-switch-phase.ts @@ -11,10 +11,10 @@ import { SwitchPhase } from "./switch-phase"; import { SwitchType } from "#enums/switch-type"; export class CheckSwitchPhase extends BattlePhase { - protected fieldIndex: integer; + protected fieldIndex: number; protected useName: boolean; - constructor(scene: BattleScene, fieldIndex: integer, useName: boolean) { + constructor(scene: BattleScene, fieldIndex: number, useName: boolean) { super(scene); this.fieldIndex = fieldIndex; diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index c1d38815c2f..0b0ab102948 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -21,9 +21,9 @@ import { ArenaTagSide } from "#app/data/arena-tag"; import { ArenaTagType } from "#app/enums/arena-tag-type"; export class CommandPhase extends FieldPhase { - protected fieldIndex: integer; + protected fieldIndex: number; - constructor(scene: BattleScene, fieldIndex: integer) { + constructor(scene: BattleScene, fieldIndex: number) { super(scene); this.fieldIndex = fieldIndex; @@ -90,7 +90,7 @@ export class CommandPhase extends FieldPhase { } } - handleCommand(command: Command, cursor: integer, ...args: any[]): boolean { + handleCommand(command: Command, cursor: number, ...args: any[]): boolean { const playerPokemon = this.scene.getPlayerField()[this.fieldIndex]; let success: boolean; @@ -307,7 +307,7 @@ export class CommandPhase extends FieldPhase { return true; } - getFieldIndex(): integer { + getFieldIndex(): number { return this.fieldIndex; } diff --git a/src/phases/common-anim-phase.ts b/src/phases/common-anim-phase.ts index c4071488eef..8a4f903c371 100644 --- a/src/phases/common-anim-phase.ts +++ b/src/phases/common-anim-phase.ts @@ -5,13 +5,13 @@ import { PokemonPhase } from "./pokemon-phase"; export class CommonAnimPhase extends PokemonPhase { private anim: CommonAnim | null; - private targetIndex: integer | undefined; + private targetIndex?: BattlerIndex; private playOnEmptyField: boolean; - constructor(scene: BattleScene, battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex | undefined, anim?: CommonAnim, playOnEmptyField: boolean = false) { + constructor(scene: BattleScene, battlerIndex?: BattlerIndex, targetIndex?: BattlerIndex, anim: CommonAnim | null = null, playOnEmptyField: boolean = false) { super(scene, battlerIndex); - this.anim = anim!; // TODO: is this bang correct? + this.anim = anim; this.targetIndex = targetIndex; this.playOnEmptyField = playOnEmptyField; } diff --git a/src/phases/damage-phase.ts b/src/phases/damage-phase.ts index 44e3dfd4182..ba3947bd595 100644 --- a/src/phases/damage-phase.ts +++ b/src/phases/damage-phase.ts @@ -6,15 +6,15 @@ import * as Utils from "#app/utils"; import { PokemonPhase } from "./pokemon-phase"; export class DamagePhase extends PokemonPhase { - private amount: integer; + private amount: number; private damageResult: DamageResult; private critical: boolean; - constructor(scene: BattleScene, battlerIndex: BattlerIndex, amount: integer, damageResult?: DamageResult, critical: boolean = false) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex, amount: number, damageResult: DamageResult = HitResult.EFFECTIVE, critical: boolean = false) { super(scene, battlerIndex); this.amount = amount; - this.damageResult = damageResult || HitResult.EFFECTIVE; + this.damageResult = damageResult; this.critical = critical; } @@ -35,7 +35,7 @@ export class DamagePhase extends PokemonPhase { this.applyDamage(); } - updateAmount(amount: integer): void { + updateAmount(amount: number): void { this.amount = amount; } diff --git a/src/phases/egg-hatch-phase.ts b/src/phases/egg-hatch-phase.ts index 90aceeb46bc..00954ea895f 100644 --- a/src/phases/egg-hatch-phase.ts +++ b/src/phases/egg-hatch-phase.ts @@ -26,7 +26,7 @@ export class EggHatchPhase extends Phase { private eggHatchData: EggHatchData; /** The number of eggs that are hatching */ - private eggsToHatchCount: integer; + private eggsToHatchCount: number; /** The container that lists how many eggs are hatching */ private eggCounterContainer: EggCounterContainer; @@ -57,7 +57,7 @@ export class EggHatchPhase extends Phase { /** The newly hatched {@link PlayerPokemon} */ private pokemon: PlayerPokemon; /** The index of which egg move is unlocked. 0-2 is common, 3 is rare */ - private eggMoveIndex: integer; + private eggMoveIndex: number; /** Internal booleans representing if the egg is hatched, able to be skipped, or skipped */ private hatched: boolean; private canSkip: boolean; @@ -66,7 +66,7 @@ export class EggHatchPhase extends Phase { private evolutionBgm: AnySound; private eggLapsePhase: EggLapsePhase; - constructor(scene: BattleScene, hatchScene: EggLapsePhase, egg: Egg, eggsToHatchCount: integer) { + constructor(scene: BattleScene, hatchScene: EggLapsePhase, egg: Egg, eggsToHatchCount: number) { super(scene); this.eggLapsePhase = hatchScene; this.egg = egg; @@ -219,7 +219,7 @@ export class EggHatchPhase extends Phase { * @param count the current number of times this function has been called. * @returns nothing since it's a Promise */ - doEggShake(intensity: number, repeatCount?: integer, count?: integer): Promise { + doEggShake(intensity: number, repeatCount?: number, count?: number): Promise { return new Promise(resolve => { if (repeatCount === undefined) { repeatCount = 0; @@ -376,7 +376,7 @@ export class EggHatchPhase extends Phase { * @param amplitude Scaling * @returns a number */ - sin(index: integer, amplitude: integer): number { + sin(index: number, amplitude: number): number { return amplitude * Math.sin(index * (Math.PI / 128)); } @@ -385,7 +385,7 @@ export class EggHatchPhase extends Phase { * @param intensity number of times this is repeated (this is a badly named variable) * @param offsetY how much to offset the Y coordinates */ - doSpray(intensity: integer, offsetY?: number) { + doSpray(intensity: number, offsetY?: number) { this.scene.tweens.addCounter({ repeat: intensity, duration: Utils.getFrameMs(1), @@ -400,7 +400,7 @@ export class EggHatchPhase extends Phase { * @param trigIndex Used to modify the particle's vertical speed, is a random number from 0-7 * @param offsetY how much to offset the Y coordinate */ - doSprayParticle(trigIndex: integer, offsetY: number) { + doSprayParticle(trigIndex: number, offsetY: number) { const initialX = this.eggHatchBg.displayWidth / 2; const initialY = this.eggHatchBg.displayHeight / 2 + offsetY; const shardKey = !this.egg.isManaphyEgg() ? this.egg.tier.toString() : "1"; diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index c4d919c0325..e0ac06d48a0 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -40,10 +40,10 @@ import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mys export class EncounterPhase extends BattlePhase { private loaded: boolean; - constructor(scene: BattleScene, loaded?: boolean) { + constructor(scene: BattleScene, loaded: boolean = false) { super(scene); - this.loaded = !!loaded; + this.loaded = loaded; } start() { @@ -268,7 +268,7 @@ export class EncounterPhase extends BattlePhase { const enemyField = this.scene.getEnemyField(); this.scene.tweens.add({ targets: [ this.scene.arenaEnemy, this.scene.currentBattle.trainer, enemyField, this.scene.arenaPlayer, this.scene.trainer ].flat(), - x: (_target, _key, value, fieldIndex: integer) => fieldIndex < 2 + (enemyField.length) ? value + 300 : value - 300, + x: (_target, _key, value, fieldIndex: number) => fieldIndex < 2 + (enemyField.length) ? value + 300 : value - 300, duration: 2000, onComplete: () => { if (!this.tryOverrideForBattleSpec()) { diff --git a/src/phases/enemy-command-phase.ts b/src/phases/enemy-command-phase.ts index 3647a237ef1..418debdc782 100644 --- a/src/phases/enemy-command-phase.ts +++ b/src/phases/enemy-command-phase.ts @@ -13,10 +13,10 @@ import { FieldPhase } from "./field-phase"; * @see {@linkcode EnemyPokemon.getNextMove} */ export class EnemyCommandPhase extends FieldPhase { - protected fieldIndex: integer; + protected fieldIndex: number; protected skipTurn: boolean = false; - constructor(scene: BattleScene, fieldIndex: integer) { + constructor(scene: BattleScene, fieldIndex: number) { super(scene); this.fieldIndex = fieldIndex; diff --git a/src/phases/enemy-party-member-pokemon-phase.ts b/src/phases/enemy-party-member-pokemon-phase.ts index bb34f53b475..97c3dccd0c2 100644 --- a/src/phases/enemy-party-member-pokemon-phase.ts +++ b/src/phases/enemy-party-member-pokemon-phase.ts @@ -3,7 +3,7 @@ import { EnemyPokemon } from "#app/field/pokemon"; import { PartyMemberPokemonPhase } from "./party-member-pokemon-phase"; export abstract class EnemyPartyMemberPokemonPhase extends PartyMemberPokemonPhase { - constructor(scene: BattleScene, partyMemberIndex: integer) { + constructor(scene: BattleScene, partyMemberIndex: number) { super(scene, partyMemberIndex, false); } diff --git a/src/phases/evolution-phase.ts b/src/phases/evolution-phase.ts index dec65e2c945..3bf4022b2a8 100644 --- a/src/phases/evolution-phase.ts +++ b/src/phases/evolution-phase.ts @@ -15,7 +15,7 @@ import { EndEvolutionPhase } from "#app/phases/end-evolution-phase"; export class EvolutionPhase extends Phase { protected pokemon: PlayerPokemon; - protected lastLevel: integer; + protected lastLevel: number; private preEvolvedPokemonName: string; @@ -33,7 +33,7 @@ export class EvolutionPhase extends Phase { protected pokemonEvoSprite: Phaser.GameObjects.Sprite; protected pokemonEvoTintSprite: Phaser.GameObjects.Sprite; - constructor(scene: BattleScene, pokemon: PlayerPokemon, evolution: SpeciesFormEvolution | null, lastLevel: integer) { + constructor(scene: BattleScene, pokemon: PlayerPokemon, evolution: SpeciesFormEvolution | null, lastLevel: number) { super(scene); this.pokemon = pokemon; @@ -339,7 +339,7 @@ export class EvolutionPhase extends Phase { }); } - doCycle(l: number, lastCycle: integer = 15): Promise { + doCycle(l: number, lastCycle: number = 15): Promise { return new Promise(resolve => { const isLastCycle = l === lastCycle; this.scene.tweens.add({ @@ -410,7 +410,7 @@ export class EvolutionPhase extends Phase { }); } - doSpiralUpwardParticle(trigIndex: integer) { + doSpiralUpwardParticle(trigIndex: number) { const initialX = this.evolutionBaseBg.displayWidth / 2; const particle = this.scene.add.image(initialX, 0, "evo_sparkle"); this.evolutionContainer.add(particle); @@ -446,7 +446,7 @@ export class EvolutionPhase extends Phase { updateParticle(); } - doArcDownParticle(trigIndex: integer) { + doArcDownParticle(trigIndex: number) { const initialX = this.evolutionBaseBg.displayWidth / 2; const particle = this.scene.add.image(initialX, 0, "evo_sparkle"); particle.setScale(0.5); @@ -479,7 +479,7 @@ export class EvolutionPhase extends Phase { updateParticle(); } - doCircleInwardParticle(trigIndex: integer, speed: integer) { + doCircleInwardParticle(trigIndex: number, speed: number) { const initialX = this.evolutionBaseBg.displayWidth / 2; const initialY = this.evolutionBaseBg.displayHeight / 2; const particle = this.scene.add.image(initialX, initialY, "evo_sparkle"); @@ -511,7 +511,7 @@ export class EvolutionPhase extends Phase { updateParticle(); } - doSprayParticle(trigIndex: integer) { + doSprayParticle(trigIndex: number) { const initialX = this.evolutionBaseBg.displayWidth / 2; const initialY = this.evolutionBaseBg.displayHeight / 2; const particle = this.scene.add.image(initialX, initialY, "evo_sparkle"); diff --git a/src/phases/exp-phase.ts b/src/phases/exp-phase.ts index 81982980d2a..9c445f28298 100644 --- a/src/phases/exp-phase.ts +++ b/src/phases/exp-phase.ts @@ -9,7 +9,7 @@ import { LevelUpPhase } from "./level-up-phase"; export class ExpPhase extends PlayerPartyMemberPokemonPhase { private expValue: number; - constructor(scene: BattleScene, partyMemberIndex: integer, expValue: number) { + constructor(scene: BattleScene, partyMemberIndex: number, expValue: number) { super(scene, partyMemberIndex); this.expValue = expValue; diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index 84fad257897..78fca492aae 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -29,10 +29,10 @@ export class GameOverPhase extends BattlePhase { private victory: boolean; private firstRibbons: PokemonSpecies[] = []; - constructor(scene: BattleScene, victory?: boolean) { + constructor(scene: BattleScene, victory: boolean = false) { super(scene); - this.victory = !!victory; + this.victory = victory; } start() { diff --git a/src/phases/learn-move-phase.ts b/src/phases/learn-move-phase.ts index fefda384092..e05b82c63f2 100644 --- a/src/phases/learn-move-phase.ts +++ b/src/phases/learn-move-phase.ts @@ -25,10 +25,10 @@ export enum LearnMoveType { export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { private moveId: Moves; private messageMode: Mode; - private learnMoveType; + private learnMoveType: LearnMoveType; private cost: number; - constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) { + constructor(scene: BattleScene, partyMemberIndex: number, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) { super(scene, partyMemberIndex); this.moveId = moveId; this.learnMoveType = learnMoveType; @@ -98,7 +98,7 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { async forgetMoveProcess(move: Move, pokemon: Pokemon) { this.scene.ui.setMode(this.messageMode); await this.scene.ui.showTextPromise(i18next.t("battle:learnMoveForgetQuestion"), undefined, true); - await this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: integer) => { + await this.scene.ui.setModeWithoutClear(Mode.SUMMARY, pokemon, SummaryUiMode.LEARN_MOVE, move, (moveIndex: number) => { if (moveIndex === 4) { this.scene.ui.setMode(this.messageMode).then(() => this.rejectMoveAndEnd(move, pokemon)); return; diff --git a/src/phases/level-up-phase.ts b/src/phases/level-up-phase.ts index a2fa8a16533..c48c92720ea 100644 --- a/src/phases/level-up-phase.ts +++ b/src/phases/level-up-phase.ts @@ -10,10 +10,10 @@ import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-pha import { LearnMovePhase } from "./learn-move-phase"; export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { - private lastLevel: integer; - private level: integer; + private lastLevel: number; + private level: number; - constructor(scene: BattleScene, partyMemberIndex: integer, lastLevel: integer, level: integer) { + constructor(scene: BattleScene, partyMemberIndex: number, lastLevel: number, level: number) { super(scene, partyMemberIndex); this.lastLevel = lastLevel; diff --git a/src/phases/login-phase.ts b/src/phases/login-phase.ts index ac1e68d1b0e..d181fb08613 100644 --- a/src/phases/login-phase.ts +++ b/src/phases/login-phase.ts @@ -11,10 +11,10 @@ import { UnavailablePhase } from "./unavailable-phase"; export class LoginPhase extends Phase { private showText: boolean; - constructor(scene: BattleScene, showText?: boolean) { + constructor(scene: BattleScene, showText: boolean = true) { super(scene); - this.showText = showText === undefined || !!showText; + this.showText = showText; } start(): void { diff --git a/src/phases/message-phase.ts b/src/phases/message-phase.ts index 1d953801178..bb76edcfe08 100644 --- a/src/phases/message-phase.ts +++ b/src/phases/message-phase.ts @@ -3,18 +3,18 @@ import { Phase } from "#app/phase"; export class MessagePhase extends Phase { private text: string; - private callbackDelay: integer | null; - private prompt: boolean | null; - private promptDelay: integer | null; + private callbackDelay?: number | null; + private prompt?: boolean | null; + private promptDelay?: number | null; private speaker?: string; - constructor(scene: BattleScene, text: string, callbackDelay?: integer | null, prompt?: boolean | null, promptDelay?: integer | null, speaker?: string) { + constructor(scene: BattleScene, text: string, callbackDelay?: number | null, prompt?: boolean | null, promptDelay?: number | null, speaker?: string) { super(scene); 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; } diff --git a/src/phases/money-reward-phase.ts b/src/phases/money-reward-phase.ts index 2f0a4f7b990..3b7ea6787d9 100644 --- a/src/phases/money-reward-phase.ts +++ b/src/phases/money-reward-phase.ts @@ -15,7 +15,7 @@ export class MoneyRewardPhase extends BattlePhase { } start() { - const moneyAmount = new Utils.IntegerHolder(this.scene.getWaveMoneyAmount(this.moneyMultiplier)); + const moneyAmount = new Utils.NumberHolder(this.scene.getWaveMoneyAmount(this.moneyMultiplier)); this.scene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount); diff --git a/src/phases/move-anim-test-phase.ts b/src/phases/move-anim-test-phase.ts deleted file mode 100644 index e4b04ce5de6..00000000000 --- a/src/phases/move-anim-test-phase.ts +++ /dev/null @@ -1,46 +0,0 @@ -import BattleScene from "#app/battle-scene"; -import { initMoveAnim, loadMoveAnimAssets, MoveAnim } from "#app/data/battle-anims"; -import { allMoves, SelfStatusMove } from "#app/data/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(scene: BattleScene, moveQueue?: Moves[]) { - super(scene); - - 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; - } else if (player) { - console.log(Moves[moveId]); - } - - initMoveAnim(this.scene, moveId).then(() => { - loadMoveAnimAssets(this.scene, [ moveId ], true) - .then(() => { - const user = player ? this.scene.getPlayerPokemon()! : this.scene.getEnemyPokemon()!; - const target = (player !== (allMoves[moveId] instanceof SelfStatusMove)) ? this.scene.getEnemyPokemon()! : this.scene.getPlayerPokemon()!; - new MoveAnim(moveId, user, target.getBattlerIndex()).play(this.scene, allMoves[moveId].hitsSubstitute(user, target), () => { // TODO: are the bangs correct here? - if (player) { - this.playMoveAnim(moveQueue, false); - } else { - this.playMoveAnim(moveQueue, true); - } - }); - }); - }); - } -} diff --git a/src/phases/party-member-pokemon-phase.ts b/src/phases/party-member-pokemon-phase.ts index f2e2b23bfb2..174a428cd46 100644 --- a/src/phases/party-member-pokemon-phase.ts +++ b/src/phases/party-member-pokemon-phase.ts @@ -3,11 +3,11 @@ import Pokemon from "#app/field/pokemon"; import { FieldPhase } from "./field-phase"; export abstract class PartyMemberPokemonPhase extends FieldPhase { - protected partyMemberIndex: integer; - protected fieldIndex: integer; + protected partyMemberIndex: number; + protected fieldIndex: number; protected player: boolean; - constructor(scene: BattleScene, partyMemberIndex: integer, player: boolean) { + constructor(scene: BattleScene, partyMemberIndex: number, player: boolean) { super(scene); this.partyMemberIndex = partyMemberIndex; diff --git a/src/phases/player-party-member-pokemon-phase.ts b/src/phases/player-party-member-pokemon-phase.ts index 87855b9334c..caa5f25c0b8 100644 --- a/src/phases/player-party-member-pokemon-phase.ts +++ b/src/phases/player-party-member-pokemon-phase.ts @@ -3,7 +3,7 @@ import { PlayerPokemon } from "#app/field/pokemon"; import { PartyMemberPokemonPhase } from "./party-member-pokemon-phase"; export abstract class PlayerPartyMemberPokemonPhase extends PartyMemberPokemonPhase { - constructor(scene: BattleScene, partyMemberIndex: integer) { + constructor(scene: BattleScene, partyMemberIndex: number) { super(scene, partyMemberIndex, true); } diff --git a/src/phases/pokemon-anim-phase.ts b/src/phases/pokemon-anim-phase.ts index 26ae11d1026..3bced389438 100644 --- a/src/phases/pokemon-anim-phase.ts +++ b/src/phases/pokemon-anim-phase.ts @@ -7,18 +7,18 @@ import { BattlePhase } from "#app/phases/battle-phase"; 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(scene: BattleScene, key: PokemonAnimType, pokemon: Pokemon, fieldAssets?: Phaser.GameObjects.Sprite[]) { + constructor(scene: BattleScene, key: PokemonAnimType, pokemon: Pokemon, fieldAssets: Phaser.GameObjects.Sprite[] = []) { super(scene); this.key = key; this.pokemon = pokemon; - this.fieldAssets = fieldAssets ?? []; + this.fieldAssets = fieldAssets; } start(): void { diff --git a/src/phases/pokemon-heal-phase.ts b/src/phases/pokemon-heal-phase.ts index dc0bd235bb5..1cafdf18c10 100644 --- a/src/phases/pokemon-heal-phase.ts +++ b/src/phases/pokemon-heal-phase.ts @@ -14,7 +14,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type"; import { HealBlockTag } from "#app/data/battler-tags"; export class PokemonHealPhase extends CommonAnimPhase { - private hpHealed: integer; + private hpHealed: number; private message: string | null; private showFullHpMessage: boolean; private skipAnim: boolean; @@ -22,7 +22,7 @@ export class PokemonHealPhase extends CommonAnimPhase { private healStatus: boolean; private preventFullHeal: boolean; - constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: integer, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex, hpHealed: number, message: string | null, showFullHpMessage: boolean, skipAnim: boolean = false, revive: boolean = false, healStatus: boolean = false, preventFullHeal: boolean = false) { super(scene, battlerIndex, undefined, CommonAnim.HEALTH_UP); this.hpHealed = hpHealed; @@ -59,7 +59,7 @@ export class PokemonHealPhase extends CommonAnimPhase { this.message = null; return super.end(); } else if (healOrDamage) { - const hpRestoreMultiplier = new Utils.IntegerHolder(1); + const hpRestoreMultiplier = new Utils.NumberHolder(1); if (!this.revive) { this.scene.applyModifiers(HealingBoosterModifier, this.player, hpRestoreMultiplier); } diff --git a/src/phases/pokemon-phase.ts b/src/phases/pokemon-phase.ts index b980c1d1719..b0019a65a5a 100644 --- a/src/phases/pokemon-phase.ts +++ b/src/phases/pokemon-phase.ts @@ -4,15 +4,16 @@ import Pokemon from "#app/field/pokemon"; import { FieldPhase } from "./field-phase"; export abstract class PokemonPhase extends FieldPhase { - protected battlerIndex: BattlerIndex | integer; + protected battlerIndex: BattlerIndex | number; public player: boolean; - public fieldIndex: integer; + public fieldIndex: number; - constructor(scene: BattleScene, battlerIndex?: BattlerIndex | integer) { + constructor(scene: BattleScene, battlerIndex?: BattlerIndex | number) { super(scene); + battlerIndex = battlerIndex ?? scene.getField().find(p => p?.isActive())!.getBattlerIndex(); // TODO: is the bang correct here? if (battlerIndex === undefined) { - battlerIndex = scene.getField().find(p => p?.isActive())!.getBattlerIndex(); // TODO: is the bang correct here? + console.warn("There are no Pokemon on the field!"); // TODO: figure out a suitable fallback behavior } this.battlerIndex = battlerIndex; diff --git a/src/phases/post-game-over-phase.ts b/src/phases/post-game-over-phase.ts index beeb30c7260..2fbd53e5c50 100644 --- a/src/phases/post-game-over-phase.ts +++ b/src/phases/post-game-over-phase.ts @@ -4,12 +4,12 @@ import { EndCardPhase } from "./end-card-phase"; import { TitlePhase } from "./title-phase"; export class PostGameOverPhase extends Phase { - private endCardPhase: EndCardPhase | null; + private endCardPhase?: EndCardPhase; constructor(scene: BattleScene, endCardPhase?: EndCardPhase) { super(scene); - this.endCardPhase = endCardPhase!; // TODO: is this bang correct? + this.endCardPhase = endCardPhase; } start() { diff --git a/src/phases/reload-session-phase.ts b/src/phases/reload-session-phase.ts index f8a38105869..16cefe02c14 100644 --- a/src/phases/reload-session-phase.ts +++ b/src/phases/reload-session-phase.ts @@ -4,12 +4,12 @@ import { Mode } from "#app/ui/ui"; import * as Utils from "#app/utils"; export class ReloadSessionPhase extends Phase { - private systemDataStr: string | null; + private systemDataStr?: string; constructor(scene: BattleScene, systemDataStr?: string) { super(scene); - this.systemDataStr = systemDataStr ?? null; + this.systemDataStr = systemDataStr; } start(): void { diff --git a/src/phases/return-phase.ts b/src/phases/return-phase.ts index eb587201585..250f748db89 100644 --- a/src/phases/return-phase.ts +++ b/src/phases/return-phase.ts @@ -4,7 +4,7 @@ import { SwitchType } from "#enums/switch-type"; import { SwitchSummonPhase } from "./switch-summon-phase"; export class ReturnPhase extends SwitchSummonPhase { - constructor(scene: BattleScene, fieldIndex: integer) { + constructor(scene: BattleScene, fieldIndex: number) { super(scene, SwitchType.SWITCH, fieldIndex, -1, true); } diff --git a/src/phases/scan-ivs-phase.ts b/src/phases/scan-ivs-phase.ts index 5ec61d5eec6..71ef41000f4 100644 --- a/src/phases/scan-ivs-phase.ts +++ b/src/phases/scan-ivs-phase.ts @@ -9,9 +9,9 @@ import i18next from "i18next"; import { PokemonPhase } from "./pokemon-phase"; export class ScanIvsPhase extends PokemonPhase { - private shownIvs: integer; + private shownIvs: number; - constructor(scene: BattleScene, battlerIndex: BattlerIndex, shownIvs: integer) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex, shownIvs: number) { super(scene, battlerIndex); this.shownIvs = shownIvs; diff --git a/src/phases/select-biome-phase.ts b/src/phases/select-biome-phase.ts index 817cd7bcd3d..e03d0b4c025 100644 --- a/src/phases/select-biome-phase.ts +++ b/src/phases/select-biome-phase.ts @@ -37,7 +37,7 @@ export class SelectBiomePhase extends BattlePhase { } else if (Array.isArray(biomeLinks[currentBiome])) { let biomes: Biome[] = []; this.scene.executeWithSeedOffset(() => { - biomes = (biomeLinks[currentBiome] as (Biome | [Biome, integer])[]) + biomes = (biomeLinks[currentBiome] as (Biome | [Biome, number])[]) .filter(b => !Array.isArray(b) || !Utils.randSeedInt(b[1])) .map(b => !Array.isArray(b) ? b : b[0]); }, this.scene.currentBattle.waveIndex); @@ -46,7 +46,7 @@ export class SelectBiomePhase extends BattlePhase { this.scene.executeWithSeedOffset(() => { biomeChoices = (!Array.isArray(biomeLinks[currentBiome]) ? [ biomeLinks[currentBiome] as Biome ] - : biomeLinks[currentBiome] as (Biome | [Biome, integer])[]) + : biomeLinks[currentBiome] as (Biome | [Biome, number])[]) .filter((b, i) => !Array.isArray(b) || !Utils.randSeedInt(b[1])) .map(b => Array.isArray(b) ? b[0] : b); }, this.scene.currentBattle.waveIndex); diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index 98975e30720..972e187dbab 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -13,14 +13,14 @@ import { CustomModifierSettings } from "#app/modifier/modifier-type"; import { isNullOrUndefined, NumberHolder } from "#app/utils"; export class SelectModifierPhase extends BattlePhase { - private rerollCount: integer; + private rerollCount: number; private modifierTiers?: ModifierTier[]; private customModifierSettings?: CustomModifierSettings; private isCopy: boolean; private typeOptions: ModifierTypeOption[]; - constructor(scene: BattleScene, rerollCount: integer = 0, modifierTiers?: ModifierTier[], customModifierSettings?: CustomModifierSettings, isCopy: boolean = false) { + constructor(scene: BattleScene, rerollCount: number = 0, modifierTiers?: ModifierTier[], customModifierSettings?: CustomModifierSettings, isCopy: boolean = false) { super(scene); this.rerollCount = rerollCount; @@ -42,7 +42,7 @@ export class SelectModifierPhase extends BattlePhase { if (!this.isCopy) { regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount); } - const modifierCount = new Utils.IntegerHolder(3); + const modifierCount = new Utils.NumberHolder(3); if (this.isPlayer()) { this.scene.applyModifiers(ExtraModifierModifier, true, modifierCount); this.scene.applyModifiers(TempExtraModifierModifier, true, modifierCount); @@ -63,7 +63,7 @@ export class SelectModifierPhase extends BattlePhase { this.typeOptions = this.getModifierTypeOptions(modifierCount.value); - const modifierSelectCallback = (rowCursor: integer, cursor: integer) => { + const modifierSelectCallback = (rowCursor: number, cursor: number) => { if (rowCursor < 0 || cursor < 0) { this.scene.ui.showText(i18next.t("battle:skipItemQuestion"), null, () => { this.scene.ui.setOverlayMode(Mode.CONFIRM, () => { @@ -75,7 +75,7 @@ export class SelectModifierPhase extends BattlePhase { return false; } let modifierType: ModifierType; - let cost: integer; + let cost: number; const rerollCost = this.getRerollCost(this.scene.lockModifierTiers); switch (rowCursor) { case 0: @@ -98,7 +98,7 @@ export class SelectModifierPhase extends BattlePhase { } break; case 1: - this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: integer, itemIndex: integer, itemQuantity: integer, toSlotIndex: integer) => { + this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: number, itemIndex: number, itemQuantity: number, toSlotIndex: number) => { if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) { const itemModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === party[fromSlotIndex].id) as PokemonHeldItemModifier[]; @@ -197,7 +197,7 @@ export class SelectModifierPhase extends BattlePhase { if (modifierType! instanceof PokemonModifierType) { //TODO: is the bang correct? if (modifierType instanceof FusePokemonModifierType) { - this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: integer, spliceSlotIndex: integer) => { + this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.SPLICE, -1, (fromSlotIndex: number, spliceSlotIndex: number) => { if (spliceSlotIndex !== undefined && fromSlotIndex < 6 && spliceSlotIndex < 6 && fromSlotIndex !== spliceSlotIndex) { this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => { const modifier = modifierType.newModifier(party[fromSlotIndex], party[spliceSlotIndex])!; //TODO: is the bang correct? @@ -220,13 +220,13 @@ export class SelectModifierPhase extends BattlePhase { const tmMoveId = isTmModifier ? (modifierType as TmModifierType).moveId : undefined; - this.scene.ui.setModeWithoutClear(Mode.PARTY, partyUiMode, -1, (slotIndex: integer, option: PartyOption) => { + this.scene.ui.setModeWithoutClear(Mode.PARTY, partyUiMode, -1, (slotIndex: number, option: PartyOption) => { if (slotIndex < 6) { this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer()).then(() => { const modifier = !isMoveModifier ? !isRememberMoveModifier ? modifierType.newModifier(party[slotIndex]) - : modifierType.newModifier(party[slotIndex], option as integer) + : modifierType.newModifier(party[slotIndex], option as number) : modifierType.newModifier(party[slotIndex], option - PartyOption.MOVE_1); applyModifier(modifier!, true); // TODO: is the bang correct? }); @@ -288,7 +288,7 @@ export class SelectModifierPhase extends BattlePhase { return ModifierPoolType.PLAYER; } - getModifierTypeOptions(modifierCount: integer): ModifierTypeOption[] { + getModifierTypeOptions(modifierCount: number): ModifierTypeOption[] { return getPlayerModifierTypeOptions(modifierCount, this.scene.getPlayerParty(), this.scene.lockModifierTiers ? this.modifierTiers : undefined, this.customModifierSettings); } diff --git a/src/phases/select-starter-phase.ts b/src/phases/select-starter-phase.ts index 2273ab1cd3c..83ffee01e1b 100644 --- a/src/phases/select-starter-phase.ts +++ b/src/phases/select-starter-phase.ts @@ -26,7 +26,7 @@ export class SelectStarterPhase extends Phase { this.scene.ui.setMode(Mode.STARTER_SELECT, (starters: Starter[]) => { this.scene.ui.clearText(); - this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: integer) => { + this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { if (slotId === -1) { this.scene.clearPhaseQueue(); this.scene.pushPhase(new TitlePhase(this.scene)); @@ -45,7 +45,7 @@ export class SelectStarterPhase extends Phase { initBattle(starters: Starter[]) { const party = this.scene.getPlayerParty(); const loadPokemonAssets: Promise[] = []; - starters.forEach((starter: Starter, i: integer) => { + starters.forEach((starter: Starter, i: number) => { if (!i && Overrides.STARTER_SPECIES_OVERRIDE) { starter.species = getPokemonSpecies(Overrides.STARTER_SPECIES_OVERRIDE as Species); } diff --git a/src/phases/select-target-phase.ts b/src/phases/select-target-phase.ts index 6f11f984c4b..1fed6aeff35 100644 --- a/src/phases/select-target-phase.ts +++ b/src/phases/select-target-phase.ts @@ -8,7 +8,7 @@ import i18next from "#app/plugins/i18n"; import { allMoves } from "#app/data/move"; export class SelectTargetPhase extends PokemonPhase { - constructor(scene: BattleScene, fieldIndex: integer) { + constructor(scene: BattleScene, fieldIndex: number) { super(scene, fieldIndex); } diff --git a/src/phases/show-party-exp-bar-phase.ts b/src/phases/show-party-exp-bar-phase.ts index f1783e7715f..0cdc660d701 100644 --- a/src/phases/show-party-exp-bar-phase.ts +++ b/src/phases/show-party-exp-bar-phase.ts @@ -10,7 +10,7 @@ import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-pha export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase { private expValue: number; - constructor(scene: BattleScene, partyMemberIndex: integer, expValue: number) { + constructor(scene: BattleScene, partyMemberIndex: number, expValue: number) { super(scene, partyMemberIndex); this.expValue = expValue; diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index ce6ebea2442..892cb94e486 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -16,14 +16,14 @@ export type StatStageChangeCallback = (target: Pokemon | null, changed: BattleSt export class StatStageChangePhase extends PokemonPhase { private stats: BattleStat[]; private selfTarget: boolean; - private stages: integer; + private stages: number; private showMessage: boolean; private ignoreAbilities: boolean; private canBeCopied: boolean; private onChange: StatStageChangeCallback | null; - constructor(scene: BattleScene, battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: integer, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex, selfTarget: boolean, stats: BattleStat[], stages: number, showMessage: boolean = true, ignoreAbilities: boolean = false, canBeCopied: boolean = true, onChange: StatStageChangeCallback | null = null) { super(scene, battlerIndex); this.selfTarget = selfTarget; @@ -214,7 +214,7 @@ export class StatStageChangePhase extends PokemonPhase { } } - getStatStageChangeMessages(stats: BattleStat[], stages: integer, relStages: integer[]): string[] { + getStatStageChangeMessages(stats: BattleStat[], stages: number, relStages: number[]): string[] { const messages: string[] = []; const relStageStatIndexes = {}; diff --git a/src/phases/summon-missing-phase.ts b/src/phases/summon-missing-phase.ts index 83ac8779dd8..6fb2cc71c94 100644 --- a/src/phases/summon-missing-phase.ts +++ b/src/phases/summon-missing-phase.ts @@ -4,7 +4,7 @@ import i18next from "i18next"; import { SummonPhase } from "./summon-phase"; export class SummonMissingPhase extends SummonPhase { - constructor(scene: BattleScene, fieldIndex: integer) { + constructor(scene: BattleScene, fieldIndex: number) { super(scene, fieldIndex); } diff --git a/src/phases/summon-phase.ts b/src/phases/summon-phase.ts index 119e550293c..eaac4fe2eea 100644 --- a/src/phases/summon-phase.ts +++ b/src/phases/summon-phase.ts @@ -17,7 +17,7 @@ import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; export class SummonPhase extends PartyMemberPokemonPhase { private loaded: boolean; - constructor(scene: BattleScene, fieldIndex: integer, player: boolean = true, loaded: boolean = false) { + constructor(scene: BattleScene, fieldIndex: number, player: boolean = true, loaded: boolean = false) { super(scene, fieldIndex, player); this.loaded = loaded; diff --git a/src/phases/switch-phase.ts b/src/phases/switch-phase.ts index 2abb109a529..ff0ccace632 100644 --- a/src/phases/switch-phase.ts +++ b/src/phases/switch-phase.ts @@ -10,7 +10,7 @@ import { SwitchSummonPhase } from "./switch-summon-phase"; * for the player (if a switch would be valid for the current battle state). */ export class SwitchPhase extends BattlePhase { - protected readonly fieldIndex: integer; + protected readonly fieldIndex: number; private readonly switchType: SwitchType; private readonly isModal: boolean; private readonly doReturn: boolean; @@ -25,7 +25,7 @@ export class SwitchPhase extends BattlePhase { * @param doReturn Indicates if the party member on the field should be * recalled to ball or has already left the field. Passed to {@linkcode SwitchSummonPhase}. */ - constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: integer, isModal: boolean, doReturn: boolean) { + constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: number, isModal: boolean, doReturn: boolean) { super(scene); this.switchType = switchType; @@ -61,7 +61,7 @@ export class SwitchPhase extends BattlePhase { // Override field index to 0 in case of double battle where 2/3 remaining legal party members fainted at once const fieldIndex = this.scene.currentBattle.getBattlerCount() === 1 || this.scene.getPokemonAllowedInBattle().length > 1 ? this.fieldIndex : 0; - this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: integer, option: PartyOption) => { + this.scene.ui.setMode(Mode.PARTY, this.isModal ? PartyUiMode.FAINT_SWITCH : PartyUiMode.POST_BATTLE_SWITCH, fieldIndex, (slotIndex: number, option: PartyOption) => { if (slotIndex >= this.scene.currentBattle.getBattlerCount() && slotIndex < 6) { const switchType = (option === PartyOption.PASS_BATON) ? SwitchType.BATON_PASS : this.switchType; this.scene.unshiftPhase(new SwitchSummonPhase(this.scene, switchType, fieldIndex, slotIndex, this.doReturn)); diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index 36db8b7a7e7..0838eac77da 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -16,7 +16,7 @@ import { SwitchType } from "#enums/switch-type"; export class SwitchSummonPhase extends SummonPhase { private readonly switchType: SwitchType; - private readonly slotIndex: integer; + private readonly slotIndex: number; private readonly doReturn: boolean; private lastPokemon: Pokemon; @@ -25,12 +25,12 @@ export class SwitchSummonPhase extends SummonPhase { * Constructor for creating a new SwitchSummonPhase * @param scene {@linkcode BattleScene} the scene the phase is associated with * @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 fieldIndex number representing position on the battle field + * @param slotIndex number 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 */ - constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: integer, slotIndex: integer, doReturn: boolean, player?: boolean) { + constructor(scene: BattleScene, switchType: SwitchType, fieldIndex: number, slotIndex: number, doReturn: boolean, player?: boolean) { super(scene, fieldIndex, player !== undefined ? player : true); this.switchType = switchType; diff --git a/src/phases/test-message-phase.ts b/src/phases/test-message-phase.ts deleted file mode 100644 index 464a5ed1f94..00000000000 --- a/src/phases/test-message-phase.ts +++ /dev/null @@ -1,8 +0,0 @@ -import BattleScene from "#app/battle-scene"; -import { MessagePhase } from "./message-phase"; - -export class TestMessagePhase extends MessagePhase { - constructor(scene: BattleScene, message: string) { - super(scene, message, null, true); - } -} diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index 88793617776..220a2da5256 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -1,6 +1,5 @@ import { loggedInUser } from "#app/account"; import { BattleType } from "#app/battle"; -import BattleScene from "#app/battle-scene"; import { fetchDailyRunSeed, getDailyRunStarters } from "#app/data/daily-run"; import { Gender } from "#app/data/gender"; import { getBiomeKey } from "#app/field/arena"; @@ -24,16 +23,10 @@ import { SummonPhase } from "./summon-phase"; export class TitlePhase extends Phase { - private loaded: boolean; + private loaded: boolean = false; private lastSessionData: SessionSaveData; public gameMode: GameModes; - constructor(scene: BattleScene) { - super(scene); - - this.loaded = false; - } - start(): void { super.start(); @@ -133,7 +126,7 @@ export class TitlePhase extends Phase { label: i18next.t("menu:loadGame"), handler: () => { this.scene.ui.setOverlayMode(Mode.SAVE_SLOT, SaveSlotUiMode.LOAD, - (slotId: integer) => { + (slotId: number) => { if (slotId === -1) { return this.showOptions(); } @@ -166,7 +159,7 @@ export class TitlePhase extends Phase { this.scene.ui.setMode(Mode.TITLE, config); } - loadSaveSlot(slotId: integer): void { + loadSaveSlot(slotId: number): void { this.scene.sessionSlotId = slotId > -1 || !loggedInUser ? slotId : loggedInUser.lastSessionSlot; this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.resetModeChain(); @@ -184,7 +177,7 @@ export class TitlePhase extends Phase { } initDailyRun(): void { - this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: integer) => { + this.scene.ui.setMode(Mode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => { this.scene.clearPhaseQueue(); if (slotId === -1) { this.scene.pushPhase(new TitlePhase(this.scene)); diff --git a/src/phases/trainer-message-test-phase.ts b/src/phases/trainer-message-test-phase.ts deleted file mode 100644 index d9e58473bd5..00000000000 --- a/src/phases/trainer-message-test-phase.ts +++ /dev/null @@ -1,41 +0,0 @@ -import BattleScene from "#app/battle-scene"; -import { trainerConfigs } from "#app/data/trainer-config"; -import { 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(scene: BattleScene, ...trainerTypes: TrainerType[]) { - super(scene); - - this.trainerTypes = trainerTypes; - } - - start() { - super.start(); - - const testMessages: string[] = []; - - for (const t of Object.keys(trainerConfigs)) { - const type = 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) { - this.scene.pushPhase(new TestMessagePhase(this.scene, message)); - } - - this.end(); - } -} diff --git a/src/phases/turn-init-phase.ts b/src/phases/turn-init-phase.ts index baff6c7d73f..cc4926d7f4d 100644 --- a/src/phases/turn-init-phase.ts +++ b/src/phases/turn-init-phase.ts @@ -44,7 +44,6 @@ export class TurnInitPhase extends FieldPhase { } }); - //this.scene.pushPhase(new MoveAnimTestPhase(this.scene)); this.scene.eventTarget.dispatchEvent(new TurnInitEvent()); handleMysteryEncounterBattleStartEffects(this.scene); diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index dc3ee3f660a..ea3d7763eba 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -99,8 +99,8 @@ export class TurnStartPhase extends FieldPhase { const bMove = allMoves[bCommand!.move!.move]; // The game now considers priority and applies the relevant move and ability attributes - const aPriority = new Utils.IntegerHolder(aMove.priority); - const bPriority = new Utils.IntegerHolder(bMove.priority); + const aPriority = new Utils.NumberHolder(aMove.priority); + const bPriority = new Utils.NumberHolder(bMove.priority); applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === a)!, null, aMove, aPriority); applyMoveAttrs(IncrementMovePriorityAttr, this.scene.getField().find(p => p?.isActive() && p.getBattlerIndex() === b)!, null, bMove, bPriority); diff --git a/src/phases/victory-phase.ts b/src/phases/victory-phase.ts index 1faa31655df..46d7a916296 100644 --- a/src/phases/victory-phase.ts +++ b/src/phases/victory-phase.ts @@ -16,7 +16,7 @@ export class VictoryPhase extends PokemonPhase { /** If true, indicates that the phase is intended for EXP purposes only, and not to continue a battle to next phase */ isExpOnly: boolean; - constructor(scene: BattleScene, battlerIndex: BattlerIndex | integer, isExpOnly: boolean = false) { + constructor(scene: BattleScene, battlerIndex: BattlerIndex | number, isExpOnly: boolean = false) { super(scene, battlerIndex); this.isExpOnly = isExpOnly; diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index b48ee342780..2e7af91a849 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -21,8 +21,7 @@ export class WeatherEffectPhase extends CommonAnimPhase { this.weather = this.scene?.arena?.weather; if (!this.weather) { - this.end(); - return; + return this.end(); } this.setAnimation(CommonAnim.SUNNY + (this.weather.weatherType - 1)); @@ -46,7 +45,7 @@ export class WeatherEffectPhase extends CommonAnimPhase { const damage = Utils.toDmgValue(pokemon.getMaxHp() / 16); - this.scene.queueMessage(getWeatherDamageMessage(this.weather?.weatherType!, pokemon)!); // TODO: are those bangs correct? + this.scene.queueMessage(getWeatherDamageMessage(this.weather!.weatherType, pokemon) ?? ""); pokemon.damageAndUpdate(damage, HitResult.EFFECTIVE, false, false, true); }; @@ -59,7 +58,7 @@ export class WeatherEffectPhase extends CommonAnimPhase { } } - this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType)!, null, () => { // TODO: is this bang correct? + this.scene.ui.showText(getWeatherLapseMessage(this.weather.weatherType) ?? "", null, () => { this.executeForAll((pokemon: Pokemon) => applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather)); super.start();