diff --git a/src/data/ability.ts b/src/data/ability.ts index d43230cbf15..37db29a006e 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -5775,7 +5775,7 @@ export function initAbilities() { .ignorable(), new Ability(Abilities.ANALYTIC, 5) .attr(MovePowerBoostAbAttr, (user, target, move) => { - const movePhase = globalScene.findPhase((phase) => phase instanceof MovePhase && phase.pokemon.id !== user.id); + const movePhase = globalScene.findPhase((phase) => phase instanceof MovePhase && phase.pokemon.id !== user?.id); return Utils.isNullOrUndefined(movePhase); }, 1.3), new Ability(Abilities.ILLUSION, 5) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ffa2a011610..ab2861b91ac 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -870,7 +870,7 @@ export class PowderTag extends BattlerTag { super.onAdd(pokemon); // "{Pokemon} is covered in powder!" - pokemon.scene.queueMessage(i18next.t("battlerTags:powderOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + globalScene.queueMessage(i18next.t("battlerTags:powderOnAdd", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } /** @@ -882,13 +882,13 @@ export class PowderTag extends BattlerTag { */ lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { if (lapseType === BattlerTagLapseType.PRE_MOVE) { - const movePhase = pokemon.scene.getCurrentPhase(); + const movePhase = globalScene.getCurrentPhase(); if (movePhase instanceof MovePhase) { const move = movePhase.move.getMove(); if (pokemon.getMoveType(move) === Type.FIRE) { movePhase.cancel(); - pokemon.scene.unshiftPhase(new CommonAnimPhase(pokemon.scene, pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.POWDER)); + globalScene.unshiftPhase(new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.POWDER)); const cancelDamage = new BooleanHolder(false); applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelDamage); @@ -897,7 +897,7 @@ export class PowderTag extends BattlerTag { } // "When the flame touched the powder\non the Pokémon, it exploded!" - pokemon.scene.queueMessage(i18next.t("battlerTags:powderLapse", { moveName: move.name })); + globalScene.queueMessage(i18next.t("battlerTags:powderLapse", { moveName: move.name })); } } return true; diff --git a/src/data/move.ts b/src/data/move.ts index f8332ffd34f..92a23cf9e4f 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -6041,7 +6041,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { } } return false; - } else if (user.scene.currentBattle.battleType !== BattleType.WILD) { // Switch out logic for enemy trainers + } else if (globalScene.currentBattle.battleType !== BattleType.WILD) { // Switch out logic for enemy trainers // Find indices of off-field Pokemon that are eligible to be switched into const eligibleNewIndices: number[] = []; globalScene.getEnemyParty().forEach((pokemon, index) => { @@ -6074,7 +6074,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { new SwitchSummonPhase( this.switchType, switchOutTarget.getFieldIndex(), - (user.scene.currentBattle.trainer ? user.scene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot) : 0), + (globalScene.currentBattle.trainer ? globalScene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot) : 0), false, false ), @@ -6750,13 +6750,13 @@ export class RepeatMoveAttr extends MoveEffectAttr { const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move)!; const moveTargets = lastMove.targets ?? []; - user.scene.queueMessage(i18next.t("moveTriggers:instructingMove", { + globalScene.queueMessage(i18next.t("moveTriggers:instructingMove", { userPokemonName: getPokemonNameWithAffix(user), targetPokemonName: getPokemonNameWithAffix(target) })); target.getMoveQueue().unshift({ move: lastMove.move, targets: moveTargets, ignorePP: false }); target.turnData.extraTurns++; - target.scene.appendToPhase(new MovePhase(target.scene, target, moveTargets, movesetMove), MoveEndPhase); + globalScene.appendToPhase(new MovePhase(target, moveTargets, movesetMove), MoveEndPhase); return true; } diff --git a/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts b/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts index 1cff313f8d3..4b2efad9a5f 100644 --- a/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts +++ b/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts @@ -92,7 +92,7 @@ export const DancingLessonsEncounter: MysteryEncounter = .withCatchAllowed(true) .withFleeAllowed(false) .withOnVisualsStart(() => { - const oricorio = globalSscene.getEnemyPokemon()!; + const oricorio = globalScene.getEnemyPokemon()!; const danceAnim = new EncounterBattleAnim(EncounterAnim.DANCE, oricorio, globalScene.getPlayerPokemon()!); danceAnim.play(false, () => { if (oricorio.shiny) { diff --git a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts index f27ca5a72e0..77829e4e657 100644 --- a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts +++ b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts @@ -812,7 +812,7 @@ function doTradeReceivedSequence(receivedPokemon: PlayerPokemon, receivedPokemon // Received pokemon sparkles let pokemonShinySparkle: Phaser.GameObjects.Sprite; if (receivedPokemon.shiny) { - pokemonShinySparkle = scene.add.sprite(receivedPokemonSprite.x, receivedPokemonSprite.y, "shiny"); + pokemonShinySparkle = globalScene.add.sprite(receivedPokemonSprite.x, receivedPokemonSprite.y, "shiny"); pokemonShinySparkle.setVisible(false); tradeContainer.add(pokemonShinySparkle); } @@ -856,8 +856,8 @@ function doTradeReceivedSequence(receivedPokemon: PlayerPokemon, receivedPokemon alpha: 0, onComplete: () => { if (receivedPokemon.shiny) { - scene.time.delayedCall(500, () => { - doShinySparkleAnim(scene, pokemonShinySparkle, receivedPokemon.variant); + globalScene.time.delayedCall(500, () => { + doShinySparkleAnim(pokemonShinySparkle, receivedPokemon.variant); }); } receivedPokeballSprite.destroy(); diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 3dc026e080b..7ada28c9ba2 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -114,7 +114,6 @@ export interface EnemyPartyConfig { * Generates an enemy party for a mystery encounter battle * This will override and replace any standard encounter generation logic * Useful for tailoring specific battles to mystery encounters - * @param scene Battle Scene * @param partyConfig Can pass various customizable attributes for the enemy party, see EnemyPartyConfig */ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): Promise { @@ -370,7 +369,6 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): * See: [startOfBattleEffects](IMysteryEncounter.startOfBattleEffects) for more details * * This promise does not need to be awaited on if called in an encounter onInit (will just load lazily) - * @param scene * @param moves */ export function loadCustomMovesForEncounter(moves: Moves | Moves[]) { @@ -381,7 +379,6 @@ export function loadCustomMovesForEncounter(moves: Moves | Moves[]) { /** * Will update player money, and animate change (sound optional) - * @param scene * @param changeValue * @param playSound * @param showMessage @@ -404,7 +401,6 @@ export function updatePlayerMoney(changeValue: number, playSound: boolean = true /** * Converts modifier bullshit to an actual item - * @param scene Battle Scene * @param modifier * @param pregenArgs Can specify BerryType for berries, TM for TMs, AttackBoostType for item, etc. */ @@ -426,7 +422,6 @@ export function generateModifierType(modifier: () => ModifierType, pregenArgs?: /** * Converts modifier bullshit to an actual item - * @param scene - Battle Scene * @param modifier * @param pregenArgs - can specify BerryType for berries, TM for TMs, AttackBoostType for item, etc. */ @@ -440,7 +435,6 @@ export function generateModifierTypeOption(modifier: () => ModifierType, pregenA /** * This function is intended for use inside onPreOptionPhase() of an encounter option - * @param scene * @param onPokemonSelected - Any logic that needs to be performed when Pokemon is chosen * If a second option needs to be selected, onPokemonSelected should return a OptionSelectItem[] object * @param onPokemonNotSelected - Any logic that needs to be performed if no Pokemon is chosen @@ -529,9 +523,9 @@ interface PokemonAndOptionSelected { } /** - * This function is intended for use inside onPreOptionPhase() of an encounter option - * @param scene - * If a second option needs to be selected, onPokemonSelected should return a OptionSelectItem[] object + * This function is intended for use inside `onPreOptionPhase()` of an encounter option + * + * If a second option needs to be selected, `onPokemonSelected` should return a {@linkcode OptionSelectItem}`[]` object * @param options * @param optionSelectPromptKey * @param selectablePokemonFilter @@ -617,7 +611,6 @@ export function selectOptionThenPokemon(options: OptionSelectItem[], optionSelec /** * Will initialize reward phases to follow the mystery encounter * Can have shop displayed or skipped - * @param scene - Battle Scene * @param customShopRewards - adds a shop phase with the specified rewards / reward tiers * @param eggRewards * @param preRewardsCallback - can execute an arbitrary callback before the new phases if necessary (useful for updating items/party/injecting new phases before {@linkcode MysteryEncounterRewardsPhase}) @@ -648,10 +641,11 @@ export function setEncounterRewards(customShopRewards?: CustomModifierSettings, /** * Will initialize exp phases into the phase queue (these are in addition to any combat or other exp earned) * Exp Share and Exp Balance will still function as normal - * @param scene - Battle Scene * @param participantId - id/s of party pokemon that get full exp value. Other party members will receive Exp Share amounts * @param baseExpValue - gives exp equivalent to a pokemon of the wave index's level. + * * Guidelines: + * ```md * 36 - Sunkern (lowest in game) * 62-64 - regional starter base evos * 100 - Scyther @@ -660,6 +654,7 @@ export function setEncounterRewards(customShopRewards?: CustomModifierSettings, * 290 - trio legendaries * 340 - box legendaries * 608 - Blissey (highest in game) + * ``` * https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_effort_value_yield_(Generation_IX) * @param useWaveIndex - set to false when directly passing the the full exp value instead of baseExpValue */ @@ -686,7 +681,6 @@ export class OptionSelectSettings { /** * Can be used to queue a new series of Options to select for an Encounter * MUST be used only in onOptionPhase, will not work in onPreOptionPhase or onPostOptionPhase - * @param scene * @param optionSelectSettings */ export function initSubsequentOptionSelect(optionSelectSettings: OptionSelectSettings) { @@ -696,7 +690,6 @@ export function initSubsequentOptionSelect(optionSelectSettings: OptionSelectSet /** * Can be used to exit an encounter without any battles or followup * Will skip any shops and rewards, and queue the next encounter phase as normal - * @param scene * @param addHealPhase - when true, will add a shop phase to end of encounter with 0 rewards but healing items are available * @param encounterMode - Can set custom encounter mode if necessary (may be required for forcing Pokemon to return before next phase) */ @@ -709,7 +702,6 @@ export function leaveEncounterWithoutBattle(addHealPhase: boolean = false, encou /** * - * @param scene * @param addHealPhase - Adds an empty shop phase to allow player to purchase healing items * @param doNotContinue - default `false`. If set to true, will not end the battle and continue to next wave */ @@ -747,7 +739,6 @@ export function handleMysteryEncounterVictory(addHealPhase: boolean = false, doN /** * Similar to {@linkcode handleMysteryEncounterVictory}, but for cases where the player lost a battle or failed a challenge - * @param scene * @param addHealPhase */ export function handleMysteryEncounterBattleFailed(addHealPhase: boolean = false, doNotContinue: boolean = false) { @@ -778,7 +769,6 @@ export function handleMysteryEncounterBattleFailed(addHealPhase: boolean = false /** * - * @param scene * @param hide - If true, performs ease out and hide visuals. If false, eases in visuals. Defaults to true * @param destroy - If true, will destroy visuals ONLY ON HIDE TRANSITION. Does nothing on show. Defaults to true * @param duration @@ -829,7 +819,6 @@ export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, des /** * Will queue moves for any pokemon to use before the first CommandPhase of a battle * Mostly useful for allowing {@linkcode MysteryEncounter} enemies to "cheat" and use moves before the first turn - * @param scene */ export function handleMysteryEncounterBattleStartEffects() { const encounter = globalScene.currentBattle.mysteryEncounter; @@ -867,7 +856,6 @@ export function handleMysteryEncounterBattleStartEffects() { /** * Can queue extra phases or logic during {@linkcode TurnInitPhase} * Should mostly just be used for injecting custom phases into the battle system on turn start - * @param scene * @return boolean - if true, will skip the remainder of the {@linkcode TurnInitPhase} */ export function handleMysteryEncounterTurnStartEffects(): boolean { @@ -882,7 +870,6 @@ export function handleMysteryEncounterTurnStartEffects(): boolean { /** * TODO: remove once encounter spawn rate is finalized * Just a helper function to calculate aggregate stats for MEs in a Classic run - * @param scene * @param baseSpawnWeight */ export function calculateMEAggregateStats(baseSpawnWeight: number) { @@ -1047,7 +1034,6 @@ export function calculateMEAggregateStats(baseSpawnWeight: number) { /** * TODO: remove once encounter spawn rate is finalized * Just a helper function to calculate aggregate stats for MEs in a Classic run - * @param scene * @param luckValue - 0 to 14 */ export function calculateRareSpawnAggregateStats(luckValue: number) { diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 1d407cf5785..5707797537f 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -1191,7 +1191,7 @@ function getSpeciesFilterRandomPartyMemberFunc( }; return (level: number, strength: PartyMemberStrength) => { - const waveIndex = scene.currentBattle.waveIndex; + const waveIndex = globalScene.currentBattle.waveIndex; const species = getPokemonSpecies(globalScene.randomSpecies(waveIndex, level, false, speciesFilter) .getTrainerSpeciesForLevel(level, true, strength, waveIndex)); diff --git a/src/field/anims.ts b/src/field/anims.ts index fe7b6566273..314a4fe3281 100644 --- a/src/field/anims.ts +++ b/src/field/anims.ts @@ -193,15 +193,15 @@ export function cos(index: integer, amplitude: integer): number { * @param sparkleSprite the Sprite to play the animation on * @param variant which shiny {@linkcode variant} to play the animation for */ -export function doShinySparkleAnim(scene: BattleScene, sparkleSprite: Phaser.GameObjects.Sprite, variant: Variant) { +export function doShinySparkleAnim(sparkleSprite: Phaser.GameObjects.Sprite, variant: Variant) { const keySuffix = variant ? `_${variant + 1}` : ""; const spriteKey = `shiny${keySuffix}`; const animationKey = `sparkle${keySuffix}`; // Make sure the animation exists, and create it if not - if (!scene.anims.exists(animationKey)) { - const frameNames = scene.anims.generateFrameNames(spriteKey, { suffix: ".png", end: 34 }); - scene.anims.create({ + if (!globalScene.anims.exists(animationKey)) { + const frameNames = globalScene.anims.generateFrameNames(spriteKey, { suffix: ".png", end: 34 }); + globalScene.anims.create({ key: `sparkle${keySuffix}`, frames: frameNames, frameRate: 32, @@ -212,5 +212,5 @@ export function doShinySparkleAnim(scene: BattleScene, sparkleSprite: Phaser.Gam // Play the animation sparkleSprite.play(animationKey); - scene.playSound("se/sparkle"); + globalScene.playSound("se/sparkle"); } diff --git a/src/field/mystery-encounter-intro.ts b/src/field/mystery-encounter-intro.ts index 7de54de6d04..1b0df1e8d16 100644 --- a/src/field/mystery-encounter-intro.ts +++ b/src/field/mystery-encounter-intro.ts @@ -4,9 +4,10 @@ import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { Species } from "#enums/species"; import { isNullOrUndefined } from "#app/utils"; import { getSpriteKeysFromSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; -import PlayAnimationConfig = Phaser.Types.Animations.PlayAnimationConfig; import { Variant } from "#app/data/variant"; import { doShinySparkleAnim } from "#app/field/anims"; +import type BattleScene from "#app/battle-scene"; +import PlayAnimationConfig = Phaser.Types.Animations.PlayAnimationConfig; type KnownFileRoot = | "arenas" @@ -128,7 +129,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con const spacingValue = Math.round((maxX - minX) / Math.max(this.spriteConfigs.filter(s => !s.x && !s.y).length, 1)); this.shinySparkleSprites = []; - const shinySparkleSprites = scene.add.container(0, 0); + const shinySparkleSprites = globalScene.add.container(0, 0); this.spriteConfigs?.forEach((config) => { const { spriteKey, isItem, hasShadow, scale, x, y, yShadow, alpha, isPokemon, isShiny, variant } = config; @@ -151,7 +152,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con tintSprite.setPipelineData("shiny", true); tintSprite.setPipelineData("variant", variant); // Create Sprite for shiny Sparkle - pokemonShinySparkle = scene.add.sprite(sprite.x, sprite.y, "shiny"); + pokemonShinySparkle = globalScene.add.sprite(sprite.x, sprite.y, "shiny"); pokemonShinySparkle.setOrigin(0.5, 1); pokemonShinySparkle.setVisible(false); this.shinySparkleSprites.push({ sprite: pokemonShinySparkle, variant: variant ?? 0 }); @@ -338,7 +339,7 @@ export default class MysteryEncounterIntroVisuals extends Phaser.GameObjects.Con playShinySparkles() { for (const sparkleConfig of this.shinySparkleSprites) { this.scene.time.delayedCall(500, () => { - doShinySparkleAnim(this.scene, sparkleConfig.sprite, sparkleConfig.variant); + doShinySparkleAnim(sparkleConfig.sprite, sparkleConfig.variant); }); } } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index d8616574129..420ab181427 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2636,7 +2636,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyMoveAttrs(FixedDamageAttr, source, this, move, fixedDamage); if (fixedDamage.value) { const multiLensMultiplier = new Utils.NumberHolder(1); - source.scene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, move.id, null, multiLensMultiplier); + globalScene.applyModifiers(PokemonMultiHitModifier, source.isPlayer(), source, move.id, null, multiLensMultiplier); fixedDamage.value = Utils.toDmgValue(fixedDamage.value * multiLensMultiplier.value); return { @@ -3565,7 +3565,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } break; case StatusEffect.FREEZE: - if (this.isOfType(Type.ICE) || (!ignoreField && (globalScene?.arena?.weather?.weatherType && [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(this.scene.arena.weather.weatherType)))) { + if (this.isOfType(Type.ICE) || (!ignoreField && (globalScene?.arena?.weather?.weatherType && [ WeatherType.SUNNY, WeatherType.HARSH_SUN ].includes(globalScene.arena.weather.weatherType)))) { return false; } break; diff --git a/src/phases/battle-end-phase.ts b/src/phases/battle-end-phase.ts index 5570f35d839..edffd8498d6 100644 --- a/src/phases/battle-end-phase.ts +++ b/src/phases/battle-end-phase.ts @@ -17,9 +17,9 @@ export class BattleEndPhase extends BattlePhase { start() { super.start(); - this.scene.gameData.gameStats.battles++; - if (this.scene.gameMode.isEndless && this.scene.currentBattle.waveIndex + 1 > this.scene.gameData.gameStats.highestEndlessWave) { - this.scene.gameData.gameStats.highestEndlessWave = this.scene.currentBattle.waveIndex + 1; + globalScene.gameData.gameStats.battles++; + if (globalScene.gameMode.isEndless && globalScene.currentBattle.waveIndex + 1 > globalScene.gameData.gameStats.highestEndlessWave) { + globalScene.gameData.gameStats.highestEndlessWave = globalScene.currentBattle.waveIndex + 1; } if (this.isVictory) { diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index 749a8cc651e..a7c22e1a3a1 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -217,9 +217,9 @@ export class EncounterPhase extends BattlePhase { if (!this.loaded && battle.battleType !== BattleType.MYSTERY_ENCOUNTER) { regenerateModifierPoolThresholds(globalScene.getEnemyField(), battle.battleType === BattleType.TRAINER ? ModifierPoolType.TRAINER : ModifierPoolType.WILD); globalScene.generateEnemyModifiers(); - overrideModifiers(this.scene, false); - this.scene.getEnemyField().forEach(enemy => { - overrideHeldItems(this.scene, enemy, false); + overrideModifiers(false); + globalScene.getEnemyField().forEach(enemy => { + overrideHeldItems(enemy, false); }); } @@ -443,12 +443,12 @@ export class EncounterPhase extends BattlePhase { globalScene.unshiftPhase(new ShinySparklePhase(BattlerIndex.ENEMY + e)); } /** This sets Eternatus' held item to be untransferrable, preventing it from being stolen */ - if (enemyPokemon.species.speciesId === Species.ETERNATUS && (this.scene.gameMode.isBattleClassicFinalBoss(this.scene.currentBattle.waveIndex) || this.scene.gameMode.isEndlessMajorBoss(this.scene.currentBattle.waveIndex))) { - const enemyMBH = this.scene.findModifier(m => m instanceof TurnHeldItemTransferModifier, false) as TurnHeldItemTransferModifier; + if (enemyPokemon.species.speciesId === Species.ETERNATUS && (globalScene.gameMode.isBattleClassicFinalBoss(globalScene.currentBattle.waveIndex) || globalScene.gameMode.isEndlessMajorBoss(globalScene.currentBattle.waveIndex))) { + const enemyMBH = globalScene.findModifier(m => m instanceof TurnHeldItemTransferModifier, false) as TurnHeldItemTransferModifier; if (enemyMBH) { - this.scene.removeModifier(enemyMBH, true); + globalScene.removeModifier(enemyMBH, true); enemyMBH.setTransferrableFalse(); - this.scene.addEnemyModifier(enemyMBH); + globalScene.addEnemyModifier(enemyMBH); } } }); diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index b88cf98faca..e43524ae18c 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -222,32 +222,33 @@ export class GameOverPhase extends BattlePhase { } } + // TODO: Make function use existing getSessionSaveData() function and then modify the values from there. /** * Slightly modified version of {@linkcode GameData.getSessionSaveData}. * @returns A promise containing the {@linkcode SessionSaveData} */ private async getRunHistoryEntry(): Promise { - const preWaveSessionData = await this.scene.gameData.getSession(this.scene.sessionSlotId); + const preWaveSessionData = await globalScene.gameData.getSession(globalScene.sessionSlotId); return { - seed: this.scene.seed, - playTime: this.scene.sessionPlayTime, - gameMode: this.scene.gameMode.modeId, - party: this.scene.getPlayerParty().map(p => new PokemonData(p)), - enemyParty: this.scene.getEnemyParty().map(p => new PokemonData(p)), - modifiers: preWaveSessionData ? preWaveSessionData.modifiers : this.scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)), - enemyModifiers: preWaveSessionData ? preWaveSessionData.enemyModifiers : this.scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)), - arena: new ArenaData(this.scene.arena), - pokeballCounts: this.scene.pokeballCounts, - money: Math.floor(this.scene.money), - score: this.scene.score, - waveIndex: this.scene.currentBattle.waveIndex, - battleType: this.scene.currentBattle.battleType, - trainer: this.scene.currentBattle.trainer ? new TrainerData(this.scene.currentBattle.trainer) : null, - gameVersion: this.scene.game.config.gameVersion, + seed: globalScene.seed, + playTime: globalScene.sessionPlayTime, + gameMode: globalScene.gameMode.modeId, + party: globalScene.getPlayerParty().map(p => new PokemonData(p)), + enemyParty: globalScene.getEnemyParty().map(p => new PokemonData(p)), + modifiers: preWaveSessionData ? preWaveSessionData.modifiers : globalScene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)), + enemyModifiers: preWaveSessionData ? preWaveSessionData.enemyModifiers : globalScene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)), + arena: new ArenaData(globalScene.arena), + pokeballCounts: globalScene.pokeballCounts, + money: Math.floor(globalScene.money), + score: globalScene.score, + waveIndex: globalScene.currentBattle.waveIndex, + battleType: globalScene.currentBattle.battleType, + trainer: globalScene.currentBattle.trainer ? new TrainerData(globalScene.currentBattle.trainer) : null, + gameVersion: globalScene.game.config.gameVersion, timestamp: new Date().getTime(), - challenges: this.scene.gameMode.challenges.map(c => new ChallengeData(c)), - mysteryEncounterType: this.scene.currentBattle.mysteryEncounter?.encounterType ?? -1, - mysteryEncounterSaveData: this.scene.mysteryEncounterSaveData + challenges: globalScene.gameMode.challenges.map(c => new ChallengeData(c)), + mysteryEncounterType: globalScene.currentBattle.mysteryEncounter?.encounterType ?? -1, + mysteryEncounterSaveData: globalScene.mysteryEncounterSaveData } as SessionSaveData; } } diff --git a/src/phases/post-summon-phase.ts b/src/phases/post-summon-phase.ts index 362cef28949..bec211cccb1 100644 --- a/src/phases/post-summon-phase.ts +++ b/src/phases/post-summon-phase.ts @@ -29,7 +29,7 @@ export class PostSummonPhase extends PokemonPhase { applyPostSummonAbAttrs(PostSummonAbAttr, pokemon) .then(() => { - const field = pokemon.isPlayer() ? this.scene.getPlayerField() : this.scene.getEnemyField(); + const field = pokemon.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); field.forEach((p) => applyAbAttrs(CommanderAbAttr, p, null, false)); this.end(); diff --git a/src/phases/switch-phase.ts b/src/phases/switch-phase.ts index 2b3961a2a5b..41ea51e1912 100644 --- a/src/phases/switch-phase.ts +++ b/src/phases/switch-phase.ts @@ -66,7 +66,7 @@ export class SwitchPhase extends BattlePhase { if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) { // Remove any pre-existing PostSummonPhase under the same field index. // Pre-existing PostSummonPhases may occur when this phase is invoked during a prompt to switch at the start of a wave. - this.scene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex); + globalScene.tryRemovePhase(p => p instanceof PostSummonPhase && p.player && p.fieldIndex === this.fieldIndex); const switchType = (option === PartyOption.PASS_BATON) ? SwitchType.BATON_PASS : this.switchType; globalScene.unshiftPhase(new SwitchSummonPhase(switchType, fieldIndex, slotIndex, this.doReturn)); } diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index bfac575ac1d..3fa7209751a 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -43,9 +43,11 @@ export class TrainerVictoryPhase extends BattlePhase { } } // Breeders in Space achievement - if (this.scene.arena.biomeType === Biome.SPACE - && (trainerType === TrainerType.BREEDER || trainerType === TrainerType.EXPERT_POKEMON_BREEDER)) { - this.scene.validateAchv(achvs.BREEDERS_IN_SPACE); + if ( + globalScene.arena.biomeType === Biome.SPACE + && (trainerType === TrainerType.BREEDER || trainerType === TrainerType.EXPERT_POKEMON_BREEDER) + ) { + globalScene.validateAchv(achvs.BREEDERS_IN_SPACE); } globalScene.ui.showText(i18next.t("battle:trainerDefeated", { trainerName: globalScene.currentBattle.trainer?.getName(TrainerSlot.NONE, true) }), null, () => { diff --git a/src/phases/turn-end-phase.ts b/src/phases/turn-end-phase.ts index bc139cbb102..3316f1a7247 100644 --- a/src/phases/turn-end-phase.ts +++ b/src/phases/turn-end-phase.ts @@ -29,7 +29,7 @@ export class TurnEndPhase extends FieldPhase { globalScene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon); if (globalScene.arena.terrain?.terrainType === TerrainType.GRASSY && pokemon.isGrounded()) { - this.scene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), + globalScene.unshiftPhase(new PokemonHealPhase(pokemon.getBattlerIndex(), Math.max(pokemon.getMaxHp() >> 4, 1), i18next.t("battle:turnEndHpRestore", { pokemonName: getPokemonNameWithAffix(pokemon) }), true)); } diff --git a/src/test/moves/effectiveness.test.ts b/src/test/moves/effectiveness.test.ts index 5ad258d7990..7742178f595 100644 --- a/src/test/moves/effectiveness.test.ts +++ b/src/test/moves/effectiveness.test.ts @@ -23,7 +23,7 @@ function testMoveEffectiveness(game: GameManager, move: Moves, targetSpecies: Sp const target = game.scene.addEnemyPokemon(getPokemonSpecies(targetSpecies), 5, TrainerSlot.NONE); if (teraType !== undefined) { - overrideHeldItems(game.scene, target, false); + overrideHeldItems(target, false); } expect(target.getMoveEffectiveness(user, allMoves[move])).toBe(expected); diff --git a/src/test/mystery-encounter/encounters/clowning-around-encounter.test.ts b/src/test/mystery-encounter/encounters/clowning-around-encounter.test.ts index de77e310ed1..5bfab7dfc99 100644 --- a/src/test/mystery-encounter/encounters/clowning-around-encounter.test.ts +++ b/src/test/mystery-encounter/encounters/clowning-around-encounter.test.ts @@ -267,7 +267,7 @@ describe("Clowning Around - Mystery Encounter", () => { itemType = generateModifierType(modifierTypes.LUCKY_EGG) as PokemonHeldItemModifierType; await addItemToPokemon(scene, scene.getPlayerParty()[0], 5, itemType); // 3 Soothe Bell on lead (great tier, but counted as ultra by this ME) - itemType = generateModifierType(scene, modifierTypes.SOOTHE_BELL) as PokemonHeldItemModifierType; + itemType = generateModifierType(modifierTypes.SOOTHE_BELL) as PokemonHeldItemModifierType; await addItemToPokemon(scene, scene.getPlayerParty()[0], 3, itemType); // 5 Soul Dew on lead (rogue) itemType = generateModifierType(modifierTypes.SOUL_DEW) as PokemonHeldItemModifierType; diff --git a/src/test/mystery-encounter/encounters/safari-zone.test.ts b/src/test/mystery-encounter/encounters/safari-zone.test.ts index 5699afe254f..77fbb411ac6 100644 --- a/src/test/mystery-encounter/encounters/safari-zone.test.ts +++ b/src/test/mystery-encounter/encounters/safari-zone.test.ts @@ -85,8 +85,8 @@ describe("Safari Zone - Mystery Encounter", () => { expect(encounter.onInit).toBeDefined(); - encounter.populateDialogueTokensFromRequirements(scene); - const onInitResult = onInit!(scene); + encounter.populateDialogueTokensFromRequirements(); + const onInitResult = onInit!(); expect(onInitResult).toBe(true); }); diff --git a/src/ui/run-info-ui-handler.ts b/src/ui/run-info-ui-handler.ts index d2fc739f6b8..e5f6369e0ea 100644 --- a/src/ui/run-info-ui-handler.ts +++ b/src/ui/run-info-ui-handler.ts @@ -306,10 +306,10 @@ export default class RunInfoUiHandler extends UiHandler { const windowCenterX = runResultWindow.getTopCenter().x; const windowBottomY = runResultWindow.getBottomCenter().y; - const runStatusText = addTextObject(this.scene, windowCenterX, 5, `${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, TextStyle.WINDOW, { fontSize : "60px", lineSpacing: 0.1 }); + const runStatusText = addTextObject(windowCenterX, 5, `${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, TextStyle.WINDOW, { fontSize : "60px", lineSpacing: 0.1 }); runStatusText.setOrigin(0.5, 0); - const currentBiomeText = addTextObject(this.scene, windowCenterX, windowBottomY - 5, `${getBiomeName(this.runInfo.arena.biome)}`, TextStyle.WINDOW, { fontSize: "60px" }); + const currentBiomeText = addTextObject(windowCenterX, windowBottomY - 5, `${getBiomeName(this.runInfo.arena.biome)}`, TextStyle.WINDOW, { fontSize: "60px" }); currentBiomeText.setOrigin(0.5, 1); this.runResultContainer.add([ runStatusText, currentBiomeText ]); @@ -527,7 +527,7 @@ export default class RunInfoUiHandler extends UiHandler { const runTime = Utils.getPlayTimeString(this.runInfo.playTime); runInfoText.appendText(`${i18next.t("runHistory:runLength")}: ${runTime}`, false); const runMoney = Utils.formatMoney(globalScene.moneyFormat, this.runInfo.money); - const moneyTextColor = getTextColor(TextStyle.MONEY_WINDOW, false, this.scene.uiTheme); + const moneyTextColor = getTextColor(TextStyle.MONEY_WINDOW, false, globalScene.uiTheme); runInfoText.appendText(`[color=${moneyTextColor}]${i18next.t("battleScene:moneyOwned", { formattedMoney : runMoney })}[/color]`); runInfoText.setPosition(7, 70); runInfoTextContainer.add(runInfoText); diff --git a/src/ui/settings/abstract-settings-ui-handler.ts b/src/ui/settings/abstract-settings-ui-handler.ts index 2f17d758d0c..1e6ebae5b48 100644 --- a/src/ui/settings/abstract-settings-ui-handler.ts +++ b/src/ui/settings/abstract-settings-ui-handler.ts @@ -136,16 +136,16 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { this.scrollBar.setTotalRows(this.settings.length); // Two-lines message box - this.messageBoxContainer = this.scene.add.container(0, this.scene.scaledCanvas.height); + this.messageBoxContainer = globalScene.add.container(0, globalScene.scaledCanvas.height); this.messageBoxContainer.setName("settings-message-box"); this.messageBoxContainer.setVisible(false); - const settingsMessageBox = addWindow(this.scene, 0, -1, this.scene.scaledCanvas.width - 2, 48); + const settingsMessageBox = addWindow(0, -1, globalScene.scaledCanvas.width - 2, 48); settingsMessageBox.setOrigin(0, 1); this.messageBoxContainer.add(settingsMessageBox); - const messageText = addTextObject(this.scene, 8, -40, "", TextStyle.WINDOW, { maxLines: 2 }); - messageText.setWordWrapWidth(this.scene.game.canvas.width - 60); + const messageText = addTextObject(8, -40, "", TextStyle.WINDOW, { maxLines: 2 }); + messageText.setWordWrapWidth(globalScene.game.canvas.width - 60); messageText.setName("settings-message"); messageText.setOrigin(0, 0); diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 062a444e5fb..0be9101f5d8 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -1074,7 +1074,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.starterSelectMessageBoxContainer.setY(0); this.message.setY(4); } else { - this.starterSelectMessageBoxContainer.setY(this.scene.game.canvas.height / 6); + this.starterSelectMessageBoxContainer.setY(globalScene.game.canvas.height / 6); this.starterSelectMessageBox.setOrigin(0, 1); this.message.setY(singleLine ? -22 : -37); } diff --git a/src/ui/target-select-ui-handler.ts b/src/ui/target-select-ui-handler.ts index e7af0c50e92..0d240d7f22d 100644 --- a/src/ui/target-select-ui-handler.ts +++ b/src/ui/target-select-ui-handler.ts @@ -44,7 +44,7 @@ export default class TargetSelectUiHandler extends UiHandler { this.fieldIndex = args[0] as integer; this.move = args[1] as Moves; this.targetSelectCallback = args[2] as TargetSelectCallback; - const user = this.scene.getPlayerField()[this.fieldIndex]; + const user = globalScene.getPlayerField()[this.fieldIndex]; const moveTargets = getMoveTargets(user, this.move); this.targets = moveTargets.targets;