From 514055dcd8fa6a308a2ffd108022b5168adb5d09 Mon Sep 17 00:00:00 2001 From: frutescens Date: Sat, 28 Sep 2024 08:57:05 -0700 Subject: [PATCH] set up descriptions --- .../utils/encounter-phase-utils.ts | 1 + src/ui/run-info-ui-handler.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 6cb5848dca8..172a6dc725b 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -37,6 +37,7 @@ import { GameOverPhase } from "#app/phases/game-over-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { PartyExpPhase } from "#app/phases/party-exp-phase"; import { Variant } from "#app/data/variant"; +import { MysteryEncounterType } from "#enums/mystery-encounter-type"; /** * Animates exclamation sprite over trainer's head at start of encounter diff --git a/src/ui/run-info-ui-handler.ts b/src/ui/run-info-ui-handler.ts index 8426976643e..b8899836ee3 100644 --- a/src/ui/run-info-ui-handler.ts +++ b/src/ui/run-info-ui-handler.ts @@ -271,6 +271,19 @@ export default class RunInfoUiHandler extends UiHandler { pokeball.setPosition(52 + ((i % row_limit) * 8), (i <= 2) ? 25 : 32); enemyContainer.add(pokeball); }); + const trainerObj = this.runInfo.trainer.toTrainer(this.scene); + const RIVAL_TRAINER_ID_THRESHOLD = 375; + let trainerName = ""; + if (this.runInfo.trainer.trainerType >= RIVAL_TRAINER_ID_THRESHOLD) { + trainerName = (trainerObj.variant === TrainerVariant.FEMALE) ? i18next.t("trainerNames:rival_female") : i18next.t("trainerNames:rival"); + } else { + trainerName = trainerObj.getName(0, true); + } + const boxString = i18next.t(trainerObj.variant !== TrainerVariant.DOUBLE ? "battle:trainerAppeared" : "battle:trainerAppearedDouble", { trainerName: trainerName }).replace(/\n/g, " "); + const descContainer = this.scene.add.container(0, 0); + this.provideDesc(descContainer, boxString); + descContainer.setPosition(52, 38); + this.runResultContainer.add(descContainer); } else if (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER) { console.log(this.runInfo.mysteryEncounterType); } @@ -429,6 +442,12 @@ export default class RunInfoUiHandler extends UiHandler { enemyContainer.add(enemyPartyContainer); } + provideDesc(descContainer: Phaser.GameObjects.Container, desc: string) { + const textBox = addTextObject(this.scene, 0, 0, desc, TextStyle.MESSAGE, { fontSize : "35px", wordWrap: {width: 150} }); + console.log(textBox.width); + descContainer.add(textBox); + } + /** * Shows information about the run like the run's mode, duration, luck, money, and player held items * The values for luck and money are from the end of the run, not the player's luck at the start of the run.