From bddb1fd5ce591e02779a05ba06767af3b2e812dc Mon Sep 17 00:00:00 2001 From: Lloyd Delacroix Date: Sun, 19 May 2024 23:18:34 -0400 Subject: [PATCH] Added Unlocking Egg Moves with Candy --- src/locales/de/starter-select-ui-handler.ts | 1 + src/locales/en/starter-select-ui-handler.ts | 1 + src/locales/es/starter-select-ui-handler.ts | 1 + src/locales/fr/starter-select-ui-handler.ts | 1 + src/locales/it/starter-select-ui-handler.ts | 1 + .../pt_BR/starter-select-ui-handler.ts | 1 + .../zh_CN/starter-select-ui-handler.ts | 1 + src/ui/starter-select-ui-handler.ts | 56 +++++++++++++++++++ 8 files changed, 63 insertions(+) diff --git a/src/locales/de/starter-select-ui-handler.ts b/src/locales/de/starter-select-ui-handler.ts index 0723c14ad82..327957ec41f 100644 --- a/src/locales/de/starter-select-ui-handler.ts +++ b/src/locales/de/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "Wähle die gewünschte Attacke.", "unlockPassive": "Passiv-Skill freischalten", "reduceCost": "Preis reduzieren", + "learnEggMove": "Lerne Eierangriff", "cycleShiny": "R: Schillernd Ja/Nein", "cycleForm": "F: Form ändern", "cycleGender": "G: Geschlecht ändern", diff --git a/src/locales/en/starter-select-ui-handler.ts b/src/locales/en/starter-select-ui-handler.ts index 19f8649dcc3..18476c0054d 100644 --- a/src/locales/en/starter-select-ui-handler.ts +++ b/src/locales/en/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "Select a move to swap with", "unlockPassive": "Unlock Passive", "reduceCost": "Reduce Cost", + "learnEggMove": "Learn Egg Move", "cycleShiny": "R: Cycle Shiny", "cycleForm": 'F: Cycle Form', "cycleGender": 'G: Cycle Gender', diff --git a/src/locales/es/starter-select-ui-handler.ts b/src/locales/es/starter-select-ui-handler.ts index 79bf6f9476e..944873b9528 100644 --- a/src/locales/es/starter-select-ui-handler.ts +++ b/src/locales/es/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "Elige el movimiento que sustituirá a", "unlockPassive": "Añadir Pasiva", "reduceCost": "Reducir Coste", + "learnEggMove": "Aprende ataque de huevo", "cycleShiny": "R: Cambiar Shiny", "cycleForm": 'F: Cambiar Forma', "cycleGender": 'G: Cambiar Género', diff --git a/src/locales/fr/starter-select-ui-handler.ts b/src/locales/fr/starter-select-ui-handler.ts index 380f4e9fd56..faf8d9c5e6e 100644 --- a/src/locales/fr/starter-select-ui-handler.ts +++ b/src/locales/fr/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "Sélectionnez laquelle échanger avec", "unlockPassive": "Débloquer Passif", "reduceCost": "Diminuer le cout", + "learnEggMove": "Apprendre l'attaque aux œufs", "cycleShiny": "R: » Chromatiques", "cycleForm": "F: » Formes", "cycleGender": "G: » Sexes", diff --git a/src/locales/it/starter-select-ui-handler.ts b/src/locales/it/starter-select-ui-handler.ts index f2b44c37297..b66c8b82695 100644 --- a/src/locales/it/starter-select-ui-handler.ts +++ b/src/locales/it/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "Seleziona una mossa da scambiare con", "unlockPassive": "Sblocca Passiva", "reduceCost": "Riduci Costo", + "learnEggMove": "Impara l'attacco dell'uovo", "cycleShiny": "R: Alterna Shiny", "cycleForm": 'F: Alterna Forma', "cycleGender": 'G: Alterna Sesso', diff --git a/src/locales/pt_BR/starter-select-ui-handler.ts b/src/locales/pt_BR/starter-select-ui-handler.ts index 7d77f48f290..707c40adf9d 100644 --- a/src/locales/pt_BR/starter-select-ui-handler.ts +++ b/src/locales/pt_BR/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "Escolha o movimento que substituirá", "unlockPassive": "Aprender Passiva", "reduceCost": "Reduzir Custo", + "learnEggMove": "Aprenda Mov. de Ovo", "cycleShiny": "R: Mudar Shiny", "cycleForm": 'F: Mudar Forma', "cycleGender": 'G: Mudar Gênero', diff --git a/src/locales/zh_CN/starter-select-ui-handler.ts b/src/locales/zh_CN/starter-select-ui-handler.ts index 0713b454376..eaacda3fc11 100644 --- a/src/locales/zh_CN/starter-select-ui-handler.ts +++ b/src/locales/zh_CN/starter-select-ui-handler.ts @@ -30,6 +30,7 @@ export const starterSelectUiHandler: SimpleTranslationEntries = { "selectMoveSwapWith": "选择要替换成的招式", "unlockPassive": "解锁被动", "reduceCost": "降低花费", + "learnEggMove": "学习鸡蛋攻击", "cycleShiny": "R: 切换闪光", "cycleForm": 'F: 切换形态', "cycleGender": 'G: 切换性别', diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index c3681651964..6592fcb1933 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -86,6 +86,27 @@ function getValueReductionCandyCounts(baseValue: integer): [integer, integer] { } } +function getEggMoveCandyCount(baseValue: integer): integer { + switch (baseValue) { + case 1: + return 50; + case 2: + return 45; + case 3: + return 40; + case 4: + return 30; + case 5: + return 25; + case 6: + return 20; + case 7: + return 15; + default: + return 10; + } +} + const gens = [ i18next.t("starterSelectUiHandler:gen1"), i18next.t("starterSelectUiHandler:gen2"), @@ -999,6 +1020,41 @@ export default class StarterSelectUiHandler extends MessageUiHandler { itemArgs: starterColors[this.lastSpecies.speciesId] }); } + const eggMovesAvailableCount = speciesEggMoves[this.lastSpecies.speciesId].length; + const eggMovesLearnedCount = starterData.eggMoves; + //There's probably a more elegant way to do the bitwise comparison + if (eggMovesAvailableCount != 0 && eggMovesLearnedCount != (Math.pow(2, eggMovesAvailableCount) - 1)) { + const eggMoveCost = getEggMoveCandyCount(speciesStarters[this.lastSpecies.speciesId]); + options.push({ + label: `x${eggMoveCost} ${i18next.t("starterSelectUiHandler:learnEggMove")}`, + handler: () => { + if (candyCount >= eggMoveCost || 1==1) { + //starterData.valueReduction++; + console.log("Egg Move Value: " + this.scene.gameData.starterData[this.lastSpecies.speciesId].eggMoves); + for (let em = 0; em < 4; em++) { + if (!(this.scene.gameData.starterData[this.lastSpecies.speciesId].eggMoves & Math.pow(2, em))) { + this.scene.gameData.setEggMoveUnlocked(this.lastSpecies, em); + break; + } + } + starterData.candyCount -= eggMoveCost; + this.pokemonCandyCountText.setText(`x${starterData.candyCount}`); + this.scene.gameData.saveSystem().then(success => { + if (!success) + return this.scene.reset(true); + }); + this.updateStarterValueLabel(this.cursor); + this.tryUpdateValue(0); + ui.setMode(Mode.STARTER_SELECT); + this.scene.playSound('buy'); + return true; + } + return false; + }, + item: 'candy', + itemArgs: starterColors[this.lastSpecies.speciesId] + }); + } options.push({ label: i18next.t("menu:cancel"), handler: () => {