Skip to content

Commit

Permalink
Resolve merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DayKev committed Dec 2, 2024
1 parent 15280c0 commit 9d5a318
Show file tree
Hide file tree
Showing 24 changed files with 83 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/data/battler-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }));
}

/**
Expand All @@ -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);
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down
26 changes: 6 additions & 20 deletions src/data/mystery-encounters/utils/encounter-phase-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down Expand Up @@ -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[]) {
Expand All @@ -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
Expand All @@ -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.
*/
Expand All @@ -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.
*/
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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
Expand All @@ -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
*/
Expand All @@ -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) {
Expand All @@ -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)
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/data/trainer-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
10 changes: 5 additions & 5 deletions src/field/anims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
}
9 changes: 5 additions & 4 deletions src/field/mystery-encounter-intro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand All @@ -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 });
Expand Down Expand Up @@ -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);
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/phases/battle-end-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 9d5a318

Please sign in to comment.