From ac2e78129e490f20fa8f037d88ff52df029a397b Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 15 May 2024 11:42:18 -0400 Subject: [PATCH 1/3] Add Save and Quit option to replace Return to Title --- src/locales/de/menu-ui-handler.ts | 2 +- src/locales/en/menu-ui-handler.ts | 2 +- src/locales/es/menu-ui-handler.ts | 2 +- src/locales/fr/menu-ui-handler.ts | 2 +- src/locales/it/menu-ui-handler.ts | 2 +- src/locales/pt_BR/menu-ui-handler.ts | 2 +- src/locales/zh_CN/menu-ui-handler.ts | 2 +- src/system/game-data.ts | 7 +++++-- src/ui/menu-ui-handler.ts | 19 +++++++++++-------- 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/locales/de/menu-ui-handler.ts b/src/locales/de/menu-ui-handler.ts index e330b7269..0197598cb 100644 --- a/src/locales/de/menu-ui-handler.ts +++ b/src/locales/de/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Eier-Gacha", "MANAGE_DATA": "Daten verwalten", "COMMUNITY": "Community", - "RETURN_TO_TITLE": "Zurück zum Titelbildschirm", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "Ausloggen", "slot": "Slot {{slotNumber}}", "importSession": "Sitzung importieren", diff --git a/src/locales/en/menu-ui-handler.ts b/src/locales/en/menu-ui-handler.ts index 5fde37ae3..eb8e474ee 100644 --- a/src/locales/en/menu-ui-handler.ts +++ b/src/locales/en/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Egg Gacha", "MANAGE_DATA": "Manage Data", "COMMUNITY": "Community", - "RETURN_TO_TITLE": "Return To Title", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "Log Out", "slot": "Slot {{slotNumber}}", "importSession": "Import Session", diff --git a/src/locales/es/menu-ui-handler.ts b/src/locales/es/menu-ui-handler.ts index ba7ea78fd..ebb76de6f 100644 --- a/src/locales/es/menu-ui-handler.ts +++ b/src/locales/es/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Gacha de Huevos", "MANAGE_DATA": "Gestionar Datos", "COMMUNITY": "Comunidad", - "RETURN_TO_TITLE": "Volver al Título", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "Cerrar Sesión", "slot": "Ranura {{slotNumber}}", "importSession": "Importar Sesión", diff --git a/src/locales/fr/menu-ui-handler.ts b/src/locales/fr/menu-ui-handler.ts index 54328a05e..3233ec09e 100644 --- a/src/locales/fr/menu-ui-handler.ts +++ b/src/locales/fr/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Gacha-Œufs", "MANAGE_DATA": "Mes données", "COMMUNITY": "Communauté", - "RETURN_TO_TITLE": "Écran titre", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "Déconnexion", "slot": "Emplacement {{slotNumber}}", "importSession": "Importer session", diff --git a/src/locales/it/menu-ui-handler.ts b/src/locales/it/menu-ui-handler.ts index 9def62d8d..3e4362e76 100644 --- a/src/locales/it/menu-ui-handler.ts +++ b/src/locales/it/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Gacha Uova", "MANAGE_DATA": "Gestisci Dati", "COMMUNITY": "Community", - "RETURN_TO_TITLE": "Ritorna al Titolo", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "Disconnettiti", "slot": "Slot {{slotNumber}}", "importSession": "Importa Sessione", diff --git a/src/locales/pt_BR/menu-ui-handler.ts b/src/locales/pt_BR/menu-ui-handler.ts index 2e4d798cf..bfe863e38 100644 --- a/src/locales/pt_BR/menu-ui-handler.ts +++ b/src/locales/pt_BR/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Gacha de Ovos", "MANAGE_DATA": "Gerenciar Dados", "COMMUNITY": "Comunidade", - "RETURN_TO_TITLE": "Voltar ao Início", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "Logout", "slot": "Slot {{slotNumber}}", "importSession": "Importar Sessão", diff --git a/src/locales/zh_CN/menu-ui-handler.ts b/src/locales/zh_CN/menu-ui-handler.ts index 0405b3ece..a4d343f6d 100644 --- a/src/locales/zh_CN/menu-ui-handler.ts +++ b/src/locales/zh_CN/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "扭蛋机", "MANAGE_DATA": "管理数据", "COMMUNITY": "社区", - "RETURN_TO_TITLE": "返回标题画面", + "SAVE_AND_QUIT": "Save and Quit", "LOG_OUT": "登出", "slot": "存档位 {{slotNumber}}", "importSession": "导入存档", diff --git a/src/system/game-data.ts b/src/system/game-data.ts index c635d66c1..2691e79be 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -358,12 +358,15 @@ export class GameData { if (cachedSystemData.timestamp > systemData.timestamp) { console.debug('Use cached system'); systemData = cachedSystemData; + systemDataStr = cachedSystemDataStr; } else this.clearLocalData(); } console.debug(systemData); + localStorage.setItem(`data_${loggedInUser.username}`, encrypt(systemDataStr, bypassLogin)); + /*const versions = [ this.scene.game.config.gameVersion, data.gameVersion || '0.0.0' ]; if (versions[0] !== versions[1]) { @@ -876,7 +879,7 @@ export class GameData { }) as SessionSaveData; } - saveAll(scene: BattleScene, skipVerification: boolean = false, sync: boolean = false, useCachedSession: boolean = false): Promise { + saveAll(scene: BattleScene, skipVerification: boolean = false, sync: boolean = false, useCachedSession: boolean = false, useCachedSystem: boolean = false): Promise { return new Promise(resolve => { Utils.executeIf(!skipVerification, updateUserInfo).then(success => { if (success !== null && !success) @@ -886,7 +889,7 @@ export class GameData { const sessionData = useCachedSession ? this.parseSessionData(decrypt(localStorage.getItem(`sessionData${scene.sessionSlotId ? scene.sessionSlotId : ''}_${loggedInUser.username}`), bypassLogin)) : this.getSessionSaveData(scene); const maxIntAttrValue = Math.pow(2, 31); - const systemData = this.getSystemSaveData(); + const systemData = useCachedSystem ? this.parseSystemData(decrypt(localStorage.getItem(`data_${loggedInUser.username}`), bypassLogin)) : this.getSystemSaveData(); const request = { system: systemData, diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index bf0326676..fb253d94f 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -20,7 +20,7 @@ export enum MenuOptions { EGG_GACHA, MANAGE_DATA, COMMUNITY, - RETURN_TO_TITLE, + SAVE_AND_QUIT, LOG_OUT } @@ -297,15 +297,18 @@ export default class MenuUiHandler extends MessageUiHandler { ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.communityConfig); success = true; break; - case MenuOptions.RETURN_TO_TITLE: + case MenuOptions.SAVE_AND_QUIT: if (this.scene.currentBattle) { success = true; - ui.showText(i18next.t("menuUiHandler:losingProgressionWarning"), null, () => { - ui.setOverlayMode(Mode.CONFIRM, () => this.scene.reset(true), () => { - ui.revertMode(); - ui.showText(null, 0); - }, false, -98); - }); + 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; From fcffa000c5285beb2b31199cdfc3c64612771602 Mon Sep 17 00:00:00 2001 From: Lugiad Date: Wed, 15 May 2024 17:45:15 +0200 Subject: [PATCH 2/3] French translation Save and Quit --- src/locales/fr/menu-ui-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/fr/menu-ui-handler.ts b/src/locales/fr/menu-ui-handler.ts index 3233ec09e..20e667546 100644 --- a/src/locales/fr/menu-ui-handler.ts +++ b/src/locales/fr/menu-ui-handler.ts @@ -9,7 +9,7 @@ export const menuUiHandler: SimpleTranslationEntries = { "EGG_GACHA": "Gacha-Œufs", "MANAGE_DATA": "Mes données", "COMMUNITY": "Communauté", - "SAVE_AND_QUIT": "Save and Quit", + "SAVE_AND_QUIT": "Sauver & quitter", "LOG_OUT": "Déconnexion", "slot": "Emplacement {{slotNumber}}", "importSession": "Importer session", From 9197f9f070370cf06134106aed5a5fedf3fb0d17 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 14 May 2024 07:26:32 +1000 Subject: [PATCH 3/3] Limit rare eggs to e4+ and fix trainer boss check Also fixes weighting to account for adjusted level ranges --- src/data/trainer-config.ts | 12 +++++++++--- src/field/pokemon.ts | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 36d76edcf..5284773e4 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -855,14 +855,20 @@ export const trainerConfigs: TrainerConfigs = { }), [TrainerType.RIVAL_6]: new TrainerConfig(++t).setName('Finn').setHasGenders('Ivy').setHasCharSprite().setTitle('Rival').setBoss().setStaticParty().setMoneyMultiplier(3).setEncounterBgm('final').setBattleBgm('battle_rival_3').setPartyTemplates(trainerPartyTemplates.RIVAL_6) .setPartyMemberFunc(0, getRandomPartyMemberFunc([ Species.VENUSAUR, Species.CHARIZARD, Species.BLASTOISE, Species.MEGANIUM, Species.TYPHLOSION, Species.FERALIGATR, Species.SCEPTILE, Species.BLAZIKEN, Species.SWAMPERT, Species.TORTERRA, Species.INFERNAPE, Species.EMPOLEON, Species.SERPERIOR, Species.EMBOAR, Species.SAMUROTT, Species.CHESNAUGHT, Species.DELPHOX, Species.GRENINJA, Species.DECIDUEYE, Species.INCINEROAR, Species.PRIMARINA, Species.RILLABOOM, Species.CINDERACE, Species.INTELEON, Species.MEOWSCARADA, Species.SKELEDIRGE, Species.QUAQUAVAL ], TrainerSlot.TRAINER, true, - p => p.setBoss(true, 3)) - ) + p => { + p.setBoss(true, 3); + p.generateAndPopulateMoveset(); + })) .setPartyMemberFunc(1, getRandomPartyMemberFunc([ Species.PIDGEOT, Species.NOCTOWL, Species.SWELLOW, Species.STARAPTOR, Species.UNFEZANT, Species.TALONFLAME, Species.TOUCANNON, Species.CORVIKNIGHT, Species.KILOWATTREL ], TrainerSlot.TRAINER, true, - p => p.setBoss(true, 2))) + p => { + p.setBoss(true, 2); + p.generateAndPopulateMoveset(); + })) .setPartyMemberFunc(2, getSpeciesFilterRandomPartyMemberFunc((species: PokemonSpecies) => !pokemonEvolutions.hasOwnProperty(species.speciesId) && !pokemonPrevolutions.hasOwnProperty(species.speciesId) && species.baseTotal >= 450)) .setSpeciesFilter(species => species.baseTotal >= 540) .setPartyMemberFunc(5, getRandomPartyMemberFunc([ Species.RAYQUAZA ], TrainerSlot.TRAINER, true, p => { p.setBoss(); + p.generateAndPopulateMoveset(); p.pokeball = PokeballType.MASTER_BALL; p.shiny = true; p.variant = 1; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 48287cf39..eb08af3da 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -1229,14 +1229,20 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { for (let i = 0; i < 3; i++) { const moveId = speciesEggMoves[this.species.getRootSpeciesId()][i]; if (!movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(' (N)')) - movePool.push([moveId, Math.min(this.level * 0.5, 40)]); + movePool.push([moveId, 40]); } + const moveId = speciesEggMoves[this.species.getRootSpeciesId()][3]; + if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(' (N)') && !this.isBoss()) // No rare egg moves before e4 + movePool.push([moveId, 30]); if (this.fusionSpecies) { for (let i = 0; i < 3; i++) { const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][i]; if (!movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(' (N)')) - movePool.push([moveId, Math.min(this.level * 0.5, 30)]); + movePool.push([moveId, 40]); } + const moveId = speciesEggMoves[this.fusionSpecies.getRootSpeciesId()][3]; + if (this.level >= 170 && !movePool.some(m => m[0] === moveId) && !allMoves[moveId].name.endsWith(' (N)') && !this.isBoss()) // No rare egg moves before e4 + movePool.push([moveId, 30]); } } }