From 9dae28f26413bd2ffb409bec5132c48b2e5ab8ac Mon Sep 17 00:00:00 2001 From: ThePsychedelicSeal <116048497+ThePsychedelicSeal@users.noreply.github.com> Date: Wed, 6 Nov 2024 09:42:39 -0700 Subject: [PATCH] [Misc] Adding Type, Current HP, Max HP, & Status to updateGameInfo() (#4756) * Adding to window.gameInfo Added type -> not working currentHP -> not working maxHP status * Adding to updateGameInfo() * Update pokemon.ts * Modifying battle-scene.ts Added code to get Form and Tera Type Typo fixed in pokemon.ts * Output type names/etc instead of numbers --------- Co-authored-by: ThePsychedelicSeal Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> --- src/battle-scene.ts | 20 +++++++++++++++----- src/phases/command-phase.ts | 2 ++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index d17c62c6e0e..d1d520f5f9d 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -38,7 +38,7 @@ import PokemonData from "#app/system/pokemon-data"; import { Nature } from "#app/data/nature"; import { FormChangeItem, pokemonFormChanges, SpeciesFormChange, SpeciesFormChangeManualTrigger, SpeciesFormChangeTimeOfDayTrigger, SpeciesFormChangeTrigger } from "#app/data/pokemon-forms"; import { FormChangePhase } from "#app/phases/form-change-phase"; -import { getTypeRgb } from "#app/data/type"; +import { getTypeRgb, Type } from "#app/data/type"; import PokemonSpriteSparkleHandler from "#app/field/pokemon-sprite-sparkle-handler"; import CharSprite from "#app/ui/char-sprite"; import DamageNumberHandler from "#app/field/damage-number-handler"; @@ -98,6 +98,7 @@ import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; import { ExpGainsSpeed } from "#enums/exp-gains-speed"; import { BattlerTagType } from "#enums/battler-tag-type"; import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#app/data/balance/starters"; +import { StatusEffect } from "#enums/status-effect"; export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; @@ -2982,12 +2983,21 @@ export default class BattleScene extends SceneBase { updateGameInfo(): void { const gameInfo = { - playTime: this.sessionPlayTime ? this.sessionPlayTime : 0, + playTime: this.sessionPlayTime ?? 0, gameMode: this.currentBattle ? this.gameMode.getName() : "Title", biome: this.currentBattle ? getBiomeName(this.arena.biomeType) : "", - wave: this.currentBattle?.waveIndex || 0, - party: this.party ? this.party.map(p => { - return { name: p.name, level: p.level }; + wave: this.currentBattle?.waveIndex ?? 0, + party: this.party ? this.party.map((p) => { + return { + name: p.name, + form: p.getFormKey(), + types: p.getTypes().map((type) => Type[type]), + teraType: p.getTeraType() !== Type.UNKNOWN ? Type[p.getTeraType()] : "", + level: p.level, + currentHP: p.hp, + maxHP: p.getMaxHp(), + status: p.status?.effect ? StatusEffect[p.status.effect] : "" + }; }) : [], modeChain: this.ui?.getModeChain() ?? [], }; diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index b99eb8d1b2e..547805ec1d1 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -32,6 +32,8 @@ export class CommandPhase extends FieldPhase { start() { super.start(); + this.scene.updateGameInfo(); + const commandUiHandler = this.scene.ui.handlers[Mode.COMMAND]; if (commandUiHandler) { if (this.scene.currentBattle.turn === 1 || commandUiHandler.getCursor() === Command.POKEMON) {