Adds the ability for users to spend candy to max a random IV

pull/804/head
td76099 2024-05-12 18:52:56 -04:00
parent 9e453c5b0f
commit 61203ff358
7 changed files with 65 additions and 6 deletions

View File

@ -28,5 +28,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
"cycleNature": "N: Wesen Ändern",
"cycleVariant": "V: Seltenheit ändern",
"enablePassive": "Passiv-Skill aktivieren",
"disablePassive": "Passiv-Skill deaktivieren"
"disablePassive": "Passiv-Skill deaktivieren",
"maxIV": "Max a Random IV"
}

View File

@ -28,5 +28,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
"cycleNature": 'N: Cycle Nature',
"cycleVariant": 'V: Cycle Variant',
"enablePassive": "Enable Passive",
"disablePassive": "Disable Passive"
"disablePassive": "Disable Passive",
"maxIV": "Max a Random IV"
}

View File

@ -28,5 +28,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
"cycleNature": 'N: Cambiar Naturaleza',
"cycleVariant": 'V: Cambiar Variante',
"enablePassive": "Activar Pasiva",
"disablePassive": "Desactivar Pasiva"
"disablePassive": "Desactivar Pasiva",
"maxIV": "Max a Random IV"
}

View File

@ -28,5 +28,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
"cycleNature": "N: » Natures",
"cycleVariant": "V: » Variants",
"enablePassive": "Activer Passif",
"disablePassive": "Désactiver Passif"
"disablePassive": "Désactiver Passif",
"maxIV": "Max a Random IV"
}

View File

@ -28,5 +28,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
"cycleNature": 'N: Alterna Natura',
"cycleVariant": 'V: Alterna Variante',
"enablePassive": "Attiva Passiva",
"disablePassive": "Disattiva Passiva"
"disablePassive": "Disattiva Passiva",
"maxIV": "Max a Random IV"
}

View File

@ -28,5 +28,6 @@ export const starterSelectUiHandler: SimpleTranslationEntries = {
"cycleNature": 'N: 切换性格',
"cycleVariant": 'V: 切换变种',
"enablePassive": "启用被动",
"disablePassive": "禁用被动"
"disablePassive": "禁用被动",
"maxIV": "Max a Random IV"
}

View File

@ -86,6 +86,27 @@ function getValueReductionCandyCounts(baseValue: integer): [integer, integer] {
}
}
function getMaxIVCandyCount(baseValue: integer): integer {
switch (baseValue) {
case 1:
return 30;
case 2:
return 25;
case 3:
return 20;
case 4:
return 15;
case 5:
return 12;
case 6:
return 10;
case 7:
return 8;
default:
return 5;
}
}
const gens = [ 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX' ];
export default class StarterSelectUiHandler extends MessageUiHandler {
@ -929,6 +950,38 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
itemArgs: starterColors[this.lastSpecies.speciesId]
});
}
const dexData = this.scene.gameData.dexData[this.lastSpecies.speciesId];
if (dexData.ivs.findIndex(iv => iv <= 30) != -1) {
const maxIVCost = getMaxIVCandyCount(speciesStarters[this.lastSpecies.speciesId]);
options.push({
label: `x${maxIVCost} ${i18next.t("starterSelectUiHandler:maxIV")}`,
handler: () => {
if (candyCount >= maxIVCost){
let ivSelected = false;
let randomIV = 0
while (!ivSelected){
randomIV = Math.floor(Math.random()*6);
ivSelected = dexData.ivs[randomIV] == 31 ? false : true
}
dexData.ivs[randomIV] = 31
starterData.candyCount -= maxIVCost;
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
this.scene.gameData.saveSystem().then(success => {
if (!success)
return this.scene.reset(true);
});
this.toggleStatsMode(false);
this.toggleStatsMode(true);
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: () => {