diff --git a/src/data/mystery-encounter.ts b/src/data/mystery-encounter.ts index 6a81e473724..51f3eb4f662 100644 --- a/src/data/mystery-encounter.ts +++ b/src/data/mystery-encounter.ts @@ -86,7 +86,7 @@ export default interface MysteryEncounter { * Can be set for uses programatic dialogue during an encounter (storing the name of one of the party's pokemon, etc.) * Example use: see MYSTERIOUS_CHEST */ - dialogueTokens?: Map; + dialogueTokens?: Map; /** * Should be set depending upon option selected as part of an encounter * For example, if there is no battle as part of the encounter/selected option, should be set to NO_BATTLE @@ -139,7 +139,7 @@ export default class MysteryEncounter implements MysteryEncounter { // Reset any dirty flags or encounter data this.lockEncounterRewardTiers = true; - this.dialogueTokens = new Map; + this.dialogueTokens = new Map; this.enemyPartyConfigs = []; this.introVisuals = null; this.misc = null; @@ -264,20 +264,20 @@ export default class MysteryEncounter implements MysteryEncounter { */ populateDialogueTokensFromRequirements?() { if (this.primaryPokemon?.length > 0) { - this.dialogueTokens.set(/@ec\{primaryName\}/gi, this.primaryPokemon.name); + this.dialogueTokens.set("primaryName", [/@ec\{primaryName\}/gi, this.primaryPokemon.name]); for (const req of this.primaryPokemonRequirements) { if (!req.invertQuery) { const entry: [RegExp, string] = req.getMatchingDialogueToken("primary", this.primaryPokemon); - this.dialogueTokens.set(entry[0], entry[1]); + this.dialogueTokens.set("primary", entry); } } } if (this.secondaryPokemonRequirements?.length > 0 && this.secondaryPokemon?.length > 0) { - this.dialogueTokens.set(/@ec\{secondaryName\}/gi, this.secondaryPokemon[0].name); + this.dialogueTokens.set("secondaryName", [/@ec\{secondaryName\}/gi, this.secondaryPokemon[0].name]); for (const req of this.secondaryPokemonRequirements) { if (!req.invertQuery) { const entry: [RegExp, string] = req.getMatchingDialogueToken("secondary", this.secondaryPokemon[0]); - this.dialogueTokens.set(entry[0], entry[1]); + this.dialogueTokens.set("secondary", entry); } } } @@ -285,20 +285,20 @@ export default class MysteryEncounter implements MysteryEncounter { const opt = this.options[i]; const j = i + 1; if (opt.primaryPokemonRequirements?.length > 0 && opt.primaryPokemon?.length > 0) { - this.dialogueTokens.set(new RegExp("@ec\{option" + j + "PrimaryName\\}", "gi"), opt.primaryPokemon.name); + this.dialogueTokens.set("option" + j + "PrimaryName", [new RegExp("@ec\{option" + j + "PrimaryName\\}", "gi"), opt.primaryPokemon.name]); for (const req of opt.primaryPokemonRequirements) { if (!req.invertQuery) { const entry: [RegExp, string] = req.getMatchingDialogueToken("option" + j + "Primary", opt.primaryPokemon); - this.dialogueTokens.set(entry[0], entry[1]); + this.dialogueTokens.set("option" + j + "Primary", entry); } } } if (opt.secondaryPokemonRequirements?.length > 0 && opt.secondaryPokemon?.length > 0) { - this.dialogueTokens.set(new RegExp("@ec\{option" + j + "SecondaryName\\}", "gi"), opt.secondaryPokemon[0].name); + this.dialogueTokens.set("option" + j + "SecondaryName", [new RegExp("@ec\{option" + j + "SecondaryName\\}", "gi"), opt.secondaryPokemon[0].name]); for (const req of opt.secondaryPokemonRequirements) { if (!req.invertQuery) { const entry: [RegExp, string] = req.getMatchingDialogueToken("option" + j + "Secondary", opt.secondaryPokemon[0]); - this.dialogueTokens.set(entry[0], entry[1]); + this.dialogueTokens.set("option" + j + "Secondary", entry); } } } @@ -317,7 +317,7 @@ export class MysteryEncounterBuilder implements Partial { primaryPokemonRequirements?: EncounterPokemonRequirement[] = []; secondaryPokemonRequirements ?: EncounterPokemonRequirement[] = []; excludePrimaryFromSupportRequirements?: boolean; - dialogueTokens?: Map; + dialogueTokens?: Map; doEncounterRewards?: (scene: BattleScene) => boolean; onInit?: (scene: BattleScene) => boolean; hideBattleIntroMessage?: boolean; diff --git a/src/data/mystery-encounters/dark-deal.ts b/src/data/mystery-encounters/dark-deal.ts index bf75a10f661..5b99a128f3e 100644 --- a/src/data/mystery-encounters/dark-deal.ts +++ b/src/data/mystery-encounters/dark-deal.ts @@ -92,7 +92,7 @@ export const DarkDealEncounter: MysteryEncounter = new MysteryEncounterBuilder() // Will never return last battle able mon and instead pick fainted/unable to battle const removedPokemon = getRandomPlayerPokemon(scene, false, true); scene.removePokemonFromPlayerParty(removedPokemon); - scene.currentBattle.mysteryEncounter.dialogueTokens.set( /@ec\{pokeName\}/gi, removedPokemon.name); + scene.currentBattle.mysteryEncounter.dialogueTokens.set("pokeName", [/@ec\{pokeName\}/gi, removedPokemon.name]); // Store removed pokemon types scene.currentBattle.mysteryEncounter.misc = [removedPokemon.species.type1]; diff --git a/src/data/mystery-encounters/fight-or-flight.ts b/src/data/mystery-encounters/fight-or-flight.ts index f447e77134e..8290604d207 100644 --- a/src/data/mystery-encounters/fight-or-flight.ts +++ b/src/data/mystery-encounters/fight-or-flight.ts @@ -47,7 +47,7 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil const tier = scene.currentBattle.waveIndex > 160 ? ModifierTier.MASTER : scene.currentBattle.waveIndex > 110 ? ModifierTier.ROGUE : scene.currentBattle.waveIndex > 60 ? ModifierTier.ULTRA : ModifierTier.GREAT; regenerateModifierPoolThresholds(scene.getParty(), ModifierPoolType.PLAYER, 0); // refresh player item pool const item = getPlayerModifierTypeOptions(1, scene.getParty(), [], { guaranteedModifierTiers: [tier]})[0]; - scene.currentBattle.mysteryEncounter.dialogueTokens.set(/@ec\{itemName\}/gi, item.type.name); + scene.currentBattle.mysteryEncounter.dialogueTokens.set("itemName", [/@ec\{itemName\}/gi, item.type.name]); scene.currentBattle.mysteryEncounter.misc = item; instance.spriteConfigs = [ @@ -92,7 +92,7 @@ export const FightOrFlightEncounter: MysteryEncounter = new MysteryEncounterBuil const config = scene.currentBattle.mysteryEncounter.enemyPartyConfigs[0]; config.pokemonConfigs[0].tags = [BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON]; config.pokemonConfigs[0].mysteryEncounterBattleEffects = (pokemon: Pokemon) => { - pokemon.scene.currentBattle.mysteryEncounter.dialogueTokens.set(/@ec\{enemyPokemon\}/gi, pokemon.name); + pokemon.scene.currentBattle.mysteryEncounter.dialogueTokens.set("enemyPokemon", [/@ec\{enemyPokemon\}/gi, pokemon.name]); queueEncounterMessage(pokemon.scene, "mysteryEncounter:fight_or_flight_boss_enraged"); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [BattleStat.ATK, BattleStat.DEF, BattleStat.SPATK, BattleStat.SPDEF, BattleStat.SPD], 1)); }; diff --git a/src/data/mystery-encounters/mysterious-chest.ts b/src/data/mystery-encounters/mysterious-chest.ts index 8e31a433313..68fae514b22 100644 --- a/src/data/mystery-encounters/mysterious-chest.ts +++ b/src/data/mystery-encounters/mysterious-chest.ts @@ -69,7 +69,7 @@ export const MysteriousChestEncounter: MysteryEncounter = new MysteryEncounterBu const highestLevelPokemon = getHighestLevelPlayerPokemon(scene, true); koPlayerPokemon(highestLevelPokemon); - scene.currentBattle.mysteryEncounter.dialogueTokens.set(/@ec\{pokeName\}/gi, highestLevelPokemon.name); + scene.currentBattle.mysteryEncounter.dialogueTokens.set("pokeName", [/@ec\{pokeName\}/gi, highestLevelPokemon.name]); // Show which Pokemon was KOed, then leave encounter with no rewards // Does this synchronously so that game over doesn't happen over result message await showEncounterText(scene, "mysteryEncounter:mysterious_chest_option_1_bad_result") diff --git a/src/data/mystery-encounters/mystery-encounter-utils.ts b/src/data/mystery-encounters/mystery-encounter-utils.ts index 3c9ee48c9ba..912db218c42 100644 --- a/src/data/mystery-encounters/mystery-encounter-utils.ts +++ b/src/data/mystery-encounters/mystery-encounter-utils.ts @@ -131,8 +131,8 @@ export function getTextWithEncounterDialogueTokens(scene: BattleScene, textKey: const dialogueTokens = scene.currentBattle?.mysteryEncounter?.dialogueTokens; if (dialogueTokens) { - dialogueTokens.forEach((value, key) => { - textString = textString.replace(key, value); + dialogueTokens.forEach((value) => { + textString = textString.replace(value[0], value[1]); }); } @@ -450,7 +450,7 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p const pokemon = scene.getParty()[slotIndex]; const secondaryOptions = onPokemonSelected(pokemon); if (!secondaryOptions) { - scene.currentBattle.mysteryEncounter.dialogueTokens.set(/@ec\{selectedPokemon\}/gi, pokemon.name); + scene.currentBattle.mysteryEncounter.dialogueTokens.set("selectedPokemon", [/@ec\{selectedPokemon\}/gi, pokemon.name]); resolve(true); return; } @@ -464,7 +464,7 @@ export function selectPokemonForOption(scene: BattleScene, onPokemonSelected: (p const onSelect = option.handler; option.handler = () => { onSelect(); - scene.currentBattle.mysteryEncounter.dialogueTokens.set(/@ec\{selectedPokemon\}/gi, pokemon.name); + scene.currentBattle.mysteryEncounter.dialogueTokens.set("selectedPokemon", [/@ec\{selectedPokemon\}/gi, pokemon.name]); resolve(true); return true; }; diff --git a/src/data/mystery-encounters/training-session.ts b/src/data/mystery-encounters/training-session.ts index 8fb0fcde3ec..105de4415a1 100644 --- a/src/data/mystery-encounters/training-session.ts +++ b/src/data/mystery-encounters/training-session.ts @@ -77,8 +77,8 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu }; const onBeforeRewardsPhase = () => { - encounter.dialogueTokens.set(/@ec\{stat1\}/gi, "-"); - encounter.dialogueTokens.set(/@ec\{stat2\}/gi, "-"); + encounter.dialogueTokens.set("stat1", [/@ec\{stat1\}/gi, "-"]); + encounter.dialogueTokens.set("stat2", [/@ec\{stat2\}/gi, "-"]); // Add the pokemon back to party with IV boost const ivIndexes = []; playerPokemon.ivs.forEach((iv, index) => { @@ -100,9 +100,9 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu const ivToChange = ivIndexes.pop(); let newVal = ivToChange.iv; if (improvedCount === 0) { - encounter.dialogueTokens.set(/@ec\{stat1\}/gi, getIvName(ivToChange.index)); + encounter.dialogueTokens.set("stat1", [/@ec\{stat1\}/gi, getIvName(ivToChange.index)]); } else { - encounter.dialogueTokens.set(/@ec\{stat2\}/gi, getIvName(ivToChange.index)); + encounter.dialogueTokens.set("stat2", [/@ec\{stat2\}/gi, getIvName(ivToChange.index)]); } // Corrects required encounter breakpoints to be continuous for all IV values @@ -148,7 +148,7 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu label: getNatureName(nature, true, true, true, scene.uiTheme), handler: () => { // Pokemon and second option selected - encounter.dialogueTokens.set(/@ec\{nature\}/gi, getNatureName(nature)); + encounter.dialogueTokens.set("nature", [/@ec\{nature\}/gi, getNatureName(nature)]); encounter.misc = { playerPokemon: pokemon, chosenNature: nature @@ -201,15 +201,15 @@ export const TrainingSessionEncounter: MysteryEncounter = new MysteryEncounterBu const speciesForm = !!pokemon.getFusionSpeciesForm() ? pokemon.getFusionSpeciesForm() : pokemon.getSpeciesForm(); const abilityCount = speciesForm.getAbilityCount(); const abilities = new Array(abilityCount).fill(null).map((val, i) => allAbilities[speciesForm.getAbility(i)]); - return abilities.map((ability: Ability) => { + return abilities.map((ability: Ability, index) => { const option: OptionSelectItem = { label: ability.name, handler: () => { // Pokemon and ability selected - encounter.dialogueTokens.set(/@ec\{ability\}/gi, ability.name); + encounter.dialogueTokens.set("ability", [/@ec\{ability\}/gi, ability.name]); encounter.misc = { playerPokemon: pokemon, - abilityIndex: ability + abilityIndex: index }; return true; }, diff --git a/src/phases.ts b/src/phases.ts index c6cda964e18..ffd9c0b609a 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -295,14 +295,6 @@ export class TitlePhase extends Phase { }, keepOpen: true }, - { - label: i18next.t("menu:settings"), - handler: () => { - this.scene.ui.setOverlayMode(Mode.SETTINGS); - return true; - }, - keepOpen: true - }, { label: i18next.t("menu:settings"), handler: () => {