From 58d533fb348170fb83c2ff1850c0dd67ac682f69 Mon Sep 17 00:00:00 2001 From: Felix Staud Date: Fri, 12 Jul 2024 11:17:01 -0700 Subject: [PATCH] migrate lost at sea encounter to new dialogue pattern --- .../dialogue/lost-at-sea-dialogue.ts | 45 -------- .../encounters/lost-at-sea-encounter.ts | 103 +++++++++++++----- 2 files changed, 75 insertions(+), 73 deletions(-) delete mode 100644 src/data/mystery-encounters/dialogue/lost-at-sea-dialogue.ts diff --git a/src/data/mystery-encounters/dialogue/lost-at-sea-dialogue.ts b/src/data/mystery-encounters/dialogue/lost-at-sea-dialogue.ts deleted file mode 100644 index 3e0e69c1a97..00000000000 --- a/src/data/mystery-encounters/dialogue/lost-at-sea-dialogue.ts +++ /dev/null @@ -1,45 +0,0 @@ -import MysteryEncounterDialogue from "#app/data/mystery-encounters/mystery-encounter-dialogue"; - -const namepsace = "mysteryEncounter:lostAtSea"; - -export const LostAtSeaDialogue: MysteryEncounterDialogue = { - intro: [ - { - text: `${namepsace}:intro`, - }, - ], - encounterOptionsDialogue: { - title: `${namepsace}:title`, - description: `${namepsace}:description`, - query: `${namepsace}:query`, - options: [ - { - buttonLabel: `${namepsace}:option:1:label`, - buttonTooltip: `${namepsace}:option:1:tooltip`, - selected: [ - { - text: `${namepsace}:option:1:selected`, - }, - ], - }, - { - buttonLabel: `${namepsace}:option:2:label`, - buttonTooltip: `${namepsace}:option:2:tooltip`, - selected: [ - { - text: `${namepsace}:option:2:selected`, - }, - ], - }, - { - buttonLabel: `${namepsace}:option:3:label`, - buttonTooltip: `${namepsace}:option:3:tooltip`, - selected: [ - { - text: `${namepsace}:option:3:selected`, - }, - ], - }, - ], - }, -}; diff --git a/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts b/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts index fb902bb9958..b4525176cf1 100644 --- a/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts +++ b/src/data/mystery-encounters/encounters/lost-at-sea-encounter.ts @@ -7,7 +7,10 @@ import MysteryEncounter, { MysteryEncounterBuilder, MysteryEncounterTier, } from "../mystery-encounter"; -import { MysteryEncounterOptionBuilder } from "../mystery-encounter-option"; +import { + EncounterOptionMode, + MysteryEncounterOptionBuilder, +} from "../mystery-encounter-option"; import { applyDamageToPokemon, leaveEncounterWithoutBattle, @@ -20,6 +23,8 @@ import { * The higher the more damage taken (100% = instant KO). */ const DAMAGE_PERCENTAGE: number = 30; // 0 - 100 +/** The i18n namespace for the encounter */ +const namepsace = "mysteryEncounter:lostAtSea"; let waterPkm: PlayerPokemon; let flyingPkm: PlayerPokemon; @@ -32,6 +37,7 @@ let flyingPkm: PlayerPokemon; export const LostAtSeaEncounter: MysteryEncounter = MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.LOST_AT_SEA) .withEncounterTier(MysteryEncounterTier.COMMON) + .withSceneWaveRangeRequirement(11, 179) .withIntroSpriteConfigs([ { fileRoot: "pokemon", @@ -44,7 +50,11 @@ export const LostAtSeaEncounter: MysteryEncounter = alpha: 0.25, }, ]) - .withSceneWaveRangeRequirement(11, 179) + .withIntroDialogue([ + { + text: `${namepsace}:intro`, + }, + ]) .withOnInit((scene: BattleScene) => { const allowedPokemon = scene .getParty() @@ -69,46 +79,80 @@ export const LostAtSeaEncounter: MysteryEncounter = return true; }) - /** - * Option 1: Use a (non fainted) water pokemon to guide you back. - * Receives EXP similar to defeating a Lapras - */ + .withTitle(`${namepsace}:title`) + .withDescription(`${namepsace}:description`) + .withQuery(`${namepsace}:query`) .withOption( + /** + * Option 1: Use a (non fainted) water pokemon to guide you back. + * Receives EXP similar to defeating a Lapras + */ new MysteryEncounterOptionBuilder() .withPokemonTypeRequirement(Type.WATER, true, 1) + .withOptionMode(EncounterOptionMode.DISABLED_OR_DEFAULT) + .withDialogue({ + buttonLabel: `${namepsace}:option:1:label`, + buttonTooltip: `${namepsace}:option:1:tooltip`, + selected: [ + { + text: `${namepsace}:option:1:selected`, + }, + ], + }) .withOptionPhase(async (scene: BattleScene) => - handleGuidingOption(scene, waterPkm) + handleGuidingOptionPhase(scene, waterPkm) ) .build() ) - /** - * Option 2: Use a (non fainted) flying pokemon to guide you back. - * Receives EXP similar to defeating a Lapras - */ .withOption( + /** + * Option 2: Use a (non fainted) flying pokemon to guide you back. + * Receives EXP similar to defeating a Lapras + */ new MysteryEncounterOptionBuilder() .withPokemonTypeRequirement(Type.FLYING, true, 1) + .withOptionMode(EncounterOptionMode.DISABLED_OR_DEFAULT) + .withDialogue({ + buttonLabel: `${namepsace}:option:2:label`, + buttonTooltip: `${namepsace}:option:2:tooltip`, + selected: [ + { + text: `${namepsace}:option:2:selected`, + }, + ], + }) .withOptionPhase(async (scene: BattleScene) => - handleGuidingOption(scene, flyingPkm) + handleGuidingOptionPhase(scene, flyingPkm) ) .build() ) - /** - * Option 3: Wander aimlessly. All pokemons lose 30% of their HP (or KO on 0 HP). - */ - .withOptionPhase(async (scene: BattleScene) => { - const allowedPokemon = scene - .getParty() - .filter((p) => p.isAllowedInBattle()); + .withSimpleOption( + /** + * Option 3: Wander aimlessly. All pokemons lose {@linkcode DAMAGE_PERCENTAGE}}% of their HP (or KO on 0 HP). + */ + { + buttonLabel: `${namepsace}:option:3:label`, + buttonTooltip: `${namepsace}:option:3:tooltip`, + selected: [ + { + text: `${namepsace}:option:3:selected`, + }, + ], + }, + async (scene: BattleScene) => { + const allowedPokemon = scene + .getParty() + .filter((p) => p.isAllowedInBattle()); - allowedPokemon.forEach((pkm) => { - const percentage = DAMAGE_PERCENTAGE / 100; - const damage = Math.floor(pkm.getMaxHp() * percentage); - return applyDamageToPokemon(pkm, damage); - }); - leaveEncounterWithoutBattle(scene); - return true; - }) + allowedPokemon.forEach((pkm) => { + const percentage = DAMAGE_PERCENTAGE / 100; + const damage = Math.floor(pkm.getMaxHp() * percentage); + return applyDamageToPokemon(pkm, damage); + }); + leaveEncounterWithoutBattle(scene); + return true; + } + ) .build(); /** @@ -128,7 +172,10 @@ function findPokemonByType(party: PlayerPokemon[], type: Type) { * @param scene Battle scene * @param guidePokemon pokemon choosen as a guide */ -function handleGuidingOption(scene: BattleScene, guidePokemon: PlayerPokemon) { +function handleGuidingOptionPhase( + scene: BattleScene, + guidePokemon: PlayerPokemon +) { /** Base EXP value for guiding pokemon. Currently Lapras base-value */ const baseExpValue: number = 187;