From d453d4c163b220689d26ffdad6e3d7cfd240c99d Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Wed, 8 May 2024 17:59:31 +0100 Subject: [PATCH] Updated game info with rewards in BattleScene Updated game info with more info about the game state --- src/battle-scene.ts | 33 +++++++++++++++++++++++++++------ src/phases.ts | 14 ++++++++++---- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 3971ca66b..4992b011d 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -17,7 +17,7 @@ import { TextStyle, addTextObject } from './ui/text'; import { Moves } from "./data/enums/moves"; import { allMoves } from "./data/move"; import { initMoves } from './data/move'; -import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from './modifier/modifier-type'; +import { ModifierPoolType, ModifierTypeOption, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getPartyLuckValue } from './modifier/modifier-type'; import AbilityBar from './ui/ability-bar'; import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability'; import { allAbilities } from "./data/ability"; @@ -43,7 +43,7 @@ import { Gender } from './data/gender'; import UIPlugin from 'phaser3-rex-plugins/templates/ui/ui-plugin'; import { addUiThemeOverrides } from './ui/ui-theme'; import PokemonData from './system/pokemon-data'; -import { Nature } from './data/nature'; +import { Nature, getNatureName } from './data/nature'; import { SpeciesFormChangeTimeOfDayTrigger, SpeciesFormChangeTrigger, pokemonFormChanges } from './data/pokemon-forms'; import { FormChangePhase, QuietFormChangePhase } from './form-change-phase'; import { BattleSpec } from './enums/battle-spec'; @@ -1939,15 +1939,36 @@ export default class BattleScene extends SceneBase { return false; } - updateGameInfo(): void { + updateGameInfo(rewards: ModifierTypeOption[] = null): void { + const getPartyInfo = (pokemon: Pokemon): any => { + return { + name: pokemon.name, + level: pokemon.level, + moves: pokemon.isPlayer() ? pokemon.moveset.map(move => { + return { + name: move.getName(), + ppLeft: move.getMovePp() - move.ppUsed, + totalPp: move.getMovePp() + }; + }) : [], + nature: getNatureName(pokemon.nature, false, false, true), + ability: pokemon.getAbility().name, + hiddenAbility: pokemon.getPassiveAbility().name, + pokedexEntry: pokemon.species.speciesId.toString(), + stats: pokemon.isPlayer() ? pokemon.stats.map(p => p) : [], + ivs: pokemon.isPlayer() ? pokemon.ivs.map(p => p): [], + }; + }; + const gameInfo = { 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 }; - }) : [] + party: this.party ? this.party.map(getPartyInfo) : [], + enemy: this.getEnemyField() ? this.getEnemyField().map(getPartyInfo) : [], + rewards: rewards ? rewards.map(r => r.type.name) : [], }; (window as any).gameInfo = gameInfo; + console.log(gameInfo); } } \ No newline at end of file diff --git a/src/phases.ts b/src/phases.ts index 8de21a0dc..83d2bfff5 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -1669,6 +1669,7 @@ export class CommandPhase extends FieldPhase { start() { super.start(); + this.scene.updateGameInfo(); if (this.fieldIndex) { const allyCommand = this.scene.currentBattle.turnCommands[this.fieldIndex - 1]; if (allyCommand.command === Command.BALL || allyCommand.command === Command.RUN) @@ -3350,20 +3351,24 @@ export class VictoryPhase extends PokemonPhase { this.scene.pushPhase(new TrainerVictoryPhase(this.scene)); if (this.scene.gameMode.isEndless || !this.scene.gameMode.isWaveFinal(this.scene.currentBattle.waveIndex)) { this.scene.pushPhase(new EggLapsePhase(this.scene)); - if (this.scene.currentBattle.waveIndex % 10) + if (this.scene.currentBattle.waveIndex % 10) { this.scene.pushPhase(new SelectModifierPhase(this.scene)); + } else if (this.scene.gameMode.isDaily) { this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.EXP_CHARM)); if (this.scene.currentBattle.waveIndex > 10 && !this.scene.gameMode.isWaveFinal(this.scene.currentBattle.waveIndex)) this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.GOLDEN_POKEBALL)); } else { const superExpWave = !this.scene.gameMode.isEndless ? (this.scene.offsetGym ? 0 : 20) : 10; - if (this.scene.gameMode.isEndless && this.scene.currentBattle.waveIndex === 10) + if (this.scene.gameMode.isEndless && this.scene.currentBattle.waveIndex === 10){ this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.EXP_SHARE)); - if (this.scene.currentBattle.waveIndex <= 750 && (this.scene.currentBattle.waveIndex <= 500 || (this.scene.currentBattle.waveIndex % 30) === superExpWave)) + } + if (this.scene.currentBattle.waveIndex <= 750 && (this.scene.currentBattle.waveIndex <= 500 || (this.scene.currentBattle.waveIndex % 30) === superExpWave)){ this.scene.pushPhase(new ModifierRewardPhase(this.scene, (this.scene.currentBattle.waveIndex % 30) !== superExpWave || this.scene.currentBattle.waveIndex > 250 ? modifierTypes.EXP_CHARM : modifierTypes.SUPER_EXP_CHARM)); - if (this.scene.currentBattle.waveIndex <= 150 && !(this.scene.currentBattle.waveIndex % 50)) + } + if (this.scene.currentBattle.waveIndex <= 150 && !(this.scene.currentBattle.waveIndex % 50)){ this.scene.pushPhase(new ModifierRewardPhase(this.scene, modifierTypes.GOLDEN_POKEBALL)); + } if (this.scene.gameMode.isEndless && !(this.scene.currentBattle.waveIndex % 50)) { this.scene.pushPhase(new ModifierRewardPhase(this.scene, !(this.scene.currentBattle.waveIndex % 250) ? modifierTypes.VOUCHER_PREMIUM : modifierTypes.VOUCHER_PLUS)); this.scene.pushPhase(new AddEnemyBuffModifierPhase(this.scene)); @@ -4441,6 +4446,7 @@ export class SelectModifierPhase extends BattlePhase { return !cost; }; + this.scene.updateGameInfo(typeOptions); this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), typeOptions, modifierSelectCallback, this.getRerollCost(typeOptions, this.scene.lockModifierTiers)); }