[Bug][UI] Fixes to Run History Logging (#4716)
* new function * weak attempt of documentation * mysterious chest handled...? maybe. * override comments * one more instruction * fixing up the logging lol * lah * fixing it up * coommrent * lalal * run info fixes * Addressed PigeonBar's comments * Centered run info text + fixed trainer sprites. * Fixed function name. * Update tsdoc in `overrides.ts` Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Fix tsdoc comment * sligthly rewrite centering of biome and wave text in run info --------- Co-authored-by: frutescens <info@laptop> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> Co-authored-by: Moka <millennium.stitcher@gmail.com>
This commit is contained in:
parent
fad29ffc51
commit
2b59a53285
|
@ -34,6 +34,7 @@ export const MysteriousChestEncounter: MysteryEncounter =
|
|||
MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.MYSTERIOUS_CHEST)
|
||||
.withEncounterTier(MysteryEncounterTier.COMMON)
|
||||
.withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES)
|
||||
.withScenePartySizeRequirement(2, 6, true)
|
||||
.withAutoHideIntroVisuals(false)
|
||||
.withCatchAllowed(true)
|
||||
.withIntroSpriteConfigs([
|
||||
|
|
|
@ -290,7 +290,10 @@ export function applyDamageToPokemon(scene: BattleScene, pokemon: PlayerPokemon,
|
|||
if (damage <= 0) {
|
||||
console.warn("Healing pokemon with `applyDamageToPokemon` is not recommended! Please use `applyHealToPokemon` instead.");
|
||||
}
|
||||
|
||||
// If a Pokemon would faint from the damage applied, its HP is instead set to 1.
|
||||
if (pokemon.isAllowedInBattle() && pokemon.hp - damage <= 0) {
|
||||
damage = pokemon.hp - 1;
|
||||
}
|
||||
applyHpChangeToPokemon(scene, pokemon, -damage);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,11 @@ class DefaultOverrides {
|
|||
// MYSTERY ENCOUNTER OVERRIDES
|
||||
// -------------------------
|
||||
|
||||
/** 1 to 256, set to null to ignore */
|
||||
/**
|
||||
* `1` (almost never) to `256` (always), set to `null` to disable the override
|
||||
*
|
||||
* Note: Make sure `STARTING_WAVE_OVERRIDE > 10`, otherwise MEs won't trigger
|
||||
*/
|
||||
readonly MYSTERY_ENCOUNTER_RATE_OVERRIDE: number | null = null;
|
||||
readonly MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier | null = null;
|
||||
readonly MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType | null = null;
|
||||
|
|
|
@ -23,6 +23,12 @@ import * as Utils from "#app/utils";
|
|||
import { PlayerGender } from "#enums/player-gender";
|
||||
import { TrainerType } from "#enums/trainer-type";
|
||||
import i18next from "i18next";
|
||||
import { SessionSaveData } from "#app/system/game-data";
|
||||
import PersistentModifierData from "#app/system/modifier-data";
|
||||
import PokemonData from "#app/system/pokemon-data";
|
||||
import ChallengeData from "#app/system/challenge-data";
|
||||
import TrainerData from "#app/system/trainer-data";
|
||||
import ArenaData from "#app/system/arena-data";
|
||||
import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
|
||||
|
||||
export class GameOverPhase extends BattlePhase {
|
||||
|
@ -109,7 +115,7 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.scene.gameData.gameStats.dailyRunSessionsWon++;
|
||||
}
|
||||
}
|
||||
this.scene.gameData.saveRunHistory(this.scene, this.scene.gameData.getSessionSaveData(this.scene), this.isVictory);
|
||||
|
||||
const fadeDuration = this.isVictory ? 10000 : 5000;
|
||||
this.scene.fadeOutBgm(fadeDuration, true);
|
||||
const activeBattlers = this.scene.getField().filter(p => p?.isActive(true));
|
||||
|
@ -135,8 +141,11 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.scene.unshiftPhase(new GameOverModifierRewardPhase(this.scene, modifierTypes.VOUCHER_PREMIUM));
|
||||
}
|
||||
}
|
||||
this.getRunHistoryEntry().then(runHistoryEntry => {
|
||||
this.scene.gameData.saveRunHistory(this.scene, runHistoryEntry, this.isVictory);
|
||||
this.scene.pushPhase(new PostGameOverPhase(this.scene, endCardPhase));
|
||||
this.end();
|
||||
});
|
||||
};
|
||||
|
||||
if (this.isVictory && this.scene.gameMode.isClassic) {
|
||||
|
@ -212,5 +221,34 @@ export class GameOverPhase extends BattlePhase {
|
|||
this.firstRibbons.push(getPokemonSpecies(pokemon.species.getRootSpeciesId(forStarter)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Slightly modified version of {@linkcode GameData.getSessionSaveData}.
|
||||
* @returns A promise containing the {@linkcode SessionSaveData}
|
||||
*/
|
||||
private async getRunHistoryEntry(): Promise<SessionSaveData> {
|
||||
const preWaveSessionData = await this.scene.gameData.getSession(this.scene.sessionSlotId);
|
||||
return {
|
||||
seed: this.scene.seed,
|
||||
playTime: this.scene.sessionPlayTime,
|
||||
gameMode: this.scene.gameMode.modeId,
|
||||
party: this.scene.getPlayerParty().map(p => new PokemonData(p)),
|
||||
enemyParty: this.scene.getEnemyParty().map(p => new PokemonData(p)),
|
||||
modifiers: preWaveSessionData ? preWaveSessionData.modifiers : this.scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
|
||||
enemyModifiers: preWaveSessionData ? preWaveSessionData.enemyModifiers : this.scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
|
||||
arena: new ArenaData(this.scene.arena),
|
||||
pokeballCounts: this.scene.pokeballCounts,
|
||||
money: Math.floor(this.scene.money),
|
||||
score: this.scene.score,
|
||||
waveIndex: this.scene.currentBattle.waveIndex,
|
||||
battleType: this.scene.currentBattle.battleType,
|
||||
trainer: this.scene.currentBattle.trainer ? new TrainerData(this.scene.currentBattle.trainer) : null,
|
||||
gameVersion: this.scene.game.config.gameVersion,
|
||||
timestamp: new Date().getTime(),
|
||||
challenges: this.scene.gameMode.challenges.map(c => new ChallengeData(c)),
|
||||
mysteryEncounterType: this.scene.currentBattle.mysteryEncounter?.encounterType ?? -1,
|
||||
mysteryEncounterSaveData: this.scene.mysteryEncounterSaveData
|
||||
} as SessionSaveData;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||
this.runResultContainer = this.scene.add.container(0, 24);
|
||||
const runResultWindow = addWindow(this.scene, 0, 0, this.statsBgWidth - 11, 65);
|
||||
runResultWindow.setOrigin(0, 0);
|
||||
runResultWindow.setName("Run_Result_Window");
|
||||
this.runResultContainer.add(runResultWindow);
|
||||
if (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) {
|
||||
this.parseRunResult();
|
||||
|
@ -254,8 +255,6 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||
* Mystery Encounters contain sprites associated with MEs + the title of the specific ME.
|
||||
*/
|
||||
private parseRunStatus() {
|
||||
const runStatusText = addTextObject(this.scene, 6, 5, `${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex} - ${getBiomeName(this.runInfo.arena.biome)}`, TextStyle.WINDOW, { fontSize : "65px", lineSpacing: 0.1 });
|
||||
|
||||
const enemyContainer = this.scene.add.container(0, 0);
|
||||
this.runResultContainer.add(enemyContainer);
|
||||
if (this.runInfo.battleType === BattleType.WILD) {
|
||||
|
@ -271,7 +270,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||
const pokeball = this.scene.add.sprite(0, 0, "pb");
|
||||
pokeball.setFrame(getPokeballAtlasKey(p.pokeball));
|
||||
pokeball.setScale(0.5);
|
||||
pokeball.setPosition(52 + ((i % row_limit) * 8), (i <= 2) ? 18 : 25);
|
||||
pokeball.setPosition(58 + ((i % row_limit) * 8), (i <= 2) ? 18 : 25);
|
||||
enemyContainer.add(pokeball);
|
||||
});
|
||||
const trainerObj = this.runInfo.trainer.toTrainer(this.scene);
|
||||
|
@ -286,7 +285,7 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||
const descContainer = this.scene.add.container(0, 0);
|
||||
const textBox = addTextObject(this.scene, 0, 0, boxString, TextStyle.WINDOW, { fontSize : "35px", wordWrap: { width: 200 }});
|
||||
descContainer.add(textBox);
|
||||
descContainer.setPosition(52, 29);
|
||||
descContainer.setPosition(55, 32);
|
||||
this.runResultContainer.add(descContainer);
|
||||
} else if (this.runInfo.battleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
const encounterExclaim = this.scene.add.sprite(0, 0, "encounter_exclaim");
|
||||
|
@ -303,7 +302,17 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||
this.runResultContainer.add([ encounterExclaim, subSprite, descContainer ]);
|
||||
}
|
||||
|
||||
this.runResultContainer.add(runStatusText);
|
||||
const runResultWindow = this.runResultContainer.getByName("Run_Result_Window") as Phaser.GameObjects.Image;
|
||||
const windowCenterX = runResultWindow.getTopCenter().x;
|
||||
const windowBottomY = runResultWindow.getBottomCenter().y;
|
||||
|
||||
const runStatusText = addTextObject(this.scene, windowCenterX, 5, `${i18next.t("saveSlotSelectUiHandler:wave")} ${this.runInfo.waveIndex}`, TextStyle.WINDOW, { fontSize : "60px", lineSpacing: 0.1 });
|
||||
runStatusText.setOrigin(0.5, 0);
|
||||
|
||||
const currentBiomeText = addTextObject(this.scene, windowCenterX, windowBottomY - 5, `${getBiomeName(this.runInfo.arena.biome)}`, TextStyle.WINDOW, { fontSize: "60px" });
|
||||
currentBiomeText.setOrigin(0.5, 1);
|
||||
|
||||
this.runResultContainer.add([ runStatusText, currentBiomeText ]);
|
||||
this.runContainer.add(this.runResultContainer);
|
||||
}
|
||||
|
||||
|
@ -387,12 +396,12 @@ export default class RunInfoUiHandler extends UiHandler {
|
|||
tObjSprite.setPosition(-9, -3);
|
||||
tObjPartnerSprite.setScale(0.55);
|
||||
doubleContainer.add([ tObjSprite, tObjPartnerSprite ]);
|
||||
doubleContainer.setPosition(28, 40);
|
||||
doubleContainer.setPosition(28, 34);
|
||||
}
|
||||
enemyContainer.add(doubleContainer);
|
||||
} else {
|
||||
const scale = (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) ? 0.35 : 0.65;
|
||||
const position = (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) ? [ 12, 28 ] : [ 32, 36 ];
|
||||
const scale = (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) ? 0.35 : 0.55;
|
||||
const position = (this.runDisplayMode === RunDisplayMode.RUN_HISTORY) ? [ 12, 28 ] : [ 30, 32 ];
|
||||
tObjSprite.setScale(scale, scale);
|
||||
tObjSprite.setPosition(position[0], position[1]);
|
||||
enemyContainer.add(tObjSprite);
|
||||
|
|
Loading…
Reference in New Issue