From 98dd5ea09b93bdcd164f4db9771f7f8c42e862fc Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Sat, 13 Jul 2024 23:40:11 -0400 Subject: [PATCH] Bug Fixes I heard you liked bug fixes so I gave you bug fixes with your bug fixes --- src/battle-scene.ts | 3 ++- src/battle.ts | 1 + src/field/pokemon.ts | 2 ++ src/logger.ts | 16 +++++++++++++++- src/phases.ts | 1 - src/system/settings/settings.ts | 18 +++++++++++++++++- src/ui/menu-ui-handler.ts | 18 ++++++++++++++++++ src/ui/party-ui-handler.ts | 2 ++ src/ui/save-slot-select-ui-handler.ts | 2 +- 9 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 3058ff044da..31474292b31 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -122,7 +122,8 @@ export default class BattleScene extends SceneBase { public enableRetries: boolean = false; public damageDisplay: string = "Off"; public lazyReloads: boolean = false; - public menuChangesBiome: boolean; + public menuChangesBiome: boolean = false; + public showAutosaves: boolean = false; /** * Determines the condition for a notification should be shown for Candy Upgrades * - 0 = 'Off' diff --git a/src/battle.ts b/src/battle.ts index 3f2519df3e8..9f9f431b8ec 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -363,6 +363,7 @@ export default class Battle { const ret = Utils.randSeedInt(range, min); this.battleSeedState = Phaser.Math.RND.state(); Phaser.Math.RND.state(state); + //scene.setScoreText("RNG: " + tempRngCounter + " (Last sim: " + this.rngCounter + ")") scene.rngCounter = tempRngCounter; scene.rngSeedOverride = tempSeedOverride; return ret; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 0fb74d51304..68e16b919ab 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -108,6 +108,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { private shinySparkle: Phaser.GameObjects.Sprite; + public partyslot: integer; + constructor(scene: BattleScene, x: number, y: number, species: PokemonSpecies, level: integer, abilityIndex?: integer, formIndex?: integer, gender?: Gender, shiny?: boolean, variant?: Variant, ivs?: integer[], nature?: Nature, dataSource?: Pokemon | PokemonData) { super(scene, x, y); diff --git a/src/logger.ts b/src/logger.ts index a09e2b667c8..097ca536518 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -87,6 +87,8 @@ export function getLogs() { * @returns The name of the game mode, for use in naming a game log. */ export function getMode(scene: BattleScene) { + if (scene.gameMode == undefined) + return "???" switch (scene.gameMode.modeId) { case GameModes.CLASSIC: return "Classic" @@ -625,6 +627,16 @@ export function logShop(scene: BattleScene, floor: integer, action: string) { console.log(drpd) localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) } +export function logCapture(scene: BattleScene, floor: integer, target: EnemyPokemon) { + //if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) + var drpd = getDRPD(scene) + console.log("Log Capture", drpd) + var wv: Wave = getWave(drpd, floor, scene) + var pkslot = target.partyslot + wv.pokemon[pkslot].captured = true; + console.log(drpd) + localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) +} /** * Retrieves a wave from the DRPD. If the wave doesn't exist, it creates a new one. * @param drpd The document to read from. @@ -804,6 +816,8 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot: console.log("Log Enemy Pokemon", drpd) var wv: Wave = getWave(drpd, floor, scene) var pk: PokeData = exportPokemon(pokemon, encounterRarity) + pk.source = pokemon + pokemon.partyslot = slot; if (wv.pokemon[slot] != undefined) { if (encounterRarity == "" || encounterRarity == undefined) { if (wv.pokemon[slot].rarity != undefined && wv.pokemon[slot].rarity != "???") pk.rarity = wv.pokemon[slot].rarity @@ -1124,7 +1138,7 @@ function printWave(inData: string, indent: string, wave: Wave): string { inData += indent + " ]" } } else { - inData += ",\n" + indent + " \"actions\": []" + inData += ",\n" + indent + " \"actions\": [\"[No actions?]\"]" } inData += ",\n " + indent + "\"shop\": \"" + wave.shop + "\"" inData += ",\n " + indent + "\"biome\": \"" + wave.biome + "\"" diff --git a/src/phases.ts b/src/phases.ts index 9c9654206ca..cf2cd208a13 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -5717,7 +5717,6 @@ export class AttemptCapturePhase extends PokemonPhase { this.scene.ui.setMode(Mode.PARTY, PartyUiMode.RELEASE, this.fieldIndex, (slotIndex: integer, _option: PartyOption) => { this.scene.ui.setMode(Mode.MESSAGE).then(() => { if (slotIndex < 6) { - LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Release " + LoggerTools.playerPokeName(this.scene, slotIndex)) addToParty(); } else { promptRelease(); diff --git a/src/system/settings/settings.ts b/src/system/settings/settings.ts index e1ef70898be..24de349327f 100644 --- a/src/system/settings/settings.ts +++ b/src/system/settings/settings.ts @@ -101,7 +101,8 @@ export const SettingKeys = { Show_BGM_Bar: "SHOW_BGM_BAR", Damage_Display: "DAMAGE_DISPLAY", LazyReloads: "FLAG_EVERY_RESET_AS_RELOAD", - FancyBiome: "FANCY_BIOMES" + FancyBiome: "FANCY_BIOMES", + ShowAutosaves: "SHOW_AUTOSAVES" }; /** @@ -543,6 +544,19 @@ export const Setting: Array = [ type: SettingType.DISPLAY, requireReload: true }, + { + key: SettingKeys.ShowAutosaves, + label: "Show Autosaves", + options: [{ + label: "Off", + value: "Off" + }, { + label: "On", + value: "On" + }], + default: 0, + type: SettingType.DISPLAY, + }, { key: SettingKeys.Master_Volume, label: i18next.t("settings:masterVolume"), @@ -656,6 +670,8 @@ export function setSetting(scene: BattleScene, setting: string, value: integer): scene.lazyReloads = Setting[index].options[value].value == "On" case SettingKeys.FancyBiome: scene.menuChangesBiome = Setting[index].options[value].value == "On" + case SettingKeys.ShowAutosaves: + scene.showAutosaves = Setting[index].options[value].value == "On" case SettingKeys.Skip_Seen_Dialogues: scene.skipSeenDialogues = Setting[index].options[value].value === "On"; break; diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 571a09f3b37..4a4d074aec7 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -22,6 +22,7 @@ enum MenuOptions { MANAGE_DATA, COMMUNITY, SAVE_AND_QUIT, + SAVE_AND_REFRESH, LOG_OUT } @@ -356,6 +357,23 @@ export default class MenuUiHandler extends MessageUiHandler { error = true; } break; + case MenuOptions.SAVE_AND_REFRESH: + if (this.scene.currentBattle) { + success = true; + if (this.scene.currentBattle.turn > 1) { + ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => { + ui.setOverlayMode(Mode.CONFIRM, () => this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)), () => { + ui.revertMode(); + ui.showText(null, 0); + }, false, -98); + }); + } else { + this.scene.gameData.saveAll(this.scene, true, true, true, true).then(() => this.scene.reset(true)); + } + } else { + error = true; + } + break; case MenuOptions.LOG_OUT: success = true; const doLogout = () => { diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 8a89722dca3..528730ad770 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -21,6 +21,7 @@ import MoveInfoOverlay from "./move-info-overlay"; import i18next from "i18next"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { Moves } from "#enums/moves"; +import * as LoggerTools from "../logger"; const defaultMessage = i18next.t("partyUiHandler:choosePokemon"); @@ -932,6 +933,7 @@ export default class PartyUiHandler extends MessageUiHandler { this.clearPartySlots(); this.scene.removePartyMemberModifiers(slotIndex); const releasedPokemon = this.scene.getParty().splice(slotIndex, 1)[0]; + LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, `Release ${releasedPokemon.name} (Slot ${slotIndex + 1})`) releasedPokemon.destroy(); this.populatePartySlots(); if (this.cursor >= this.scene.getParty().length) { diff --git a/src/ui/save-slot-select-ui-handler.ts b/src/ui/save-slot-select-ui-handler.ts index 8adfa4a72e7..fa1dced0035 100644 --- a/src/ui/save-slot-select-ui-handler.ts +++ b/src/ui/save-slot-select-ui-handler.ts @@ -206,7 +206,7 @@ export default class SaveSlotSelectUiHandler extends MessageUiHandler { this.scene.add.existing(sessionSlot); this.sessionSlotsContainer.add(sessionSlot); this.sessionSlots.push(sessionSlot); - if (this.uiMode != SaveSlotUiMode.SAVE) { + if (this.uiMode != SaveSlotUiMode.SAVE && this.scene.showAutosaves) { for (var j = 0; j < LoggerTools.autoCheckpoints.length; j++) { var k = "sessionData" + (s ? s : "") + "_Guest_auto" + j if (localStorage.getItem(k) != null) {