Updated game info with rewards in BattleScene

Updated game info with more info about the game state
pull/647/head
Frederico Santos 2024-05-08 17:59:31 +01:00
parent 62224aa3c9
commit d453d4c163
2 changed files with 37 additions and 10 deletions

View File

@ -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);
}
}

View File

@ -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));
}