Fix candy menu not showing for species with only 1 starter move

This commit is contained in:
Flashfyre 2024-04-13 19:21:59 -04:00
parent 608c024749
commit 61ce0887ef
1 changed files with 85 additions and 85 deletions

View File

@ -784,103 +784,103 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return true; return true;
} }
}); });
const starterData = this.scene.gameData.starterData[this.lastSpecies.speciesId]; }
const candyCount = starterData.candyCount; const starterData = this.scene.gameData.starterData[this.lastSpecies.speciesId];
const passiveAttr = starterData.passiveAttr; const candyCount = starterData.candyCount;
if (passiveAttr & PassiveAttr.UNLOCKED) { const passiveAttr = starterData.passiveAttr;
if (!(passiveAttr & PassiveAttr.ENABLED)) { if (passiveAttr & PassiveAttr.UNLOCKED) {
options.push({ if (!(passiveAttr & PassiveAttr.ENABLED)) {
label: 'Enable Passive',
handler: () => {
starterData.passiveAttr |= PassiveAttr.ENABLED;
ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined);
return true;
}
});
} else {
options.push({
label: 'Disable Passive',
handler: () => {
starterData.passiveAttr ^= PassiveAttr.ENABLED;
ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined);
return true;
}
});
}
}
const showUseCandies = () => {
const options = [];
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
const passiveCost = getPassiveCandyCount(speciesStarters[this.lastSpecies.speciesId]);
options.push({
label: `x${passiveCost} Unlock Passive (${allAbilities[starterPassiveAbilities[this.lastSpecies.speciesId]].name})`,
handler: () => {
if (candyCount >= passiveCost) {
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
starterData.candyCount -= passiveCost;
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
this.scene.gameData.saveSystem().then(success => {
if (!success)
return this.scene.reset(true);
});
ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined);
return true;
}
return false;
},
item: 'candy',
itemArgs: starterColors[this.lastSpecies.speciesId]
});
}
const valueReduction = starterData.valueReduction;
if (valueReduction < 2) {
const reductionCost = getValueReductionCandyCounts(speciesStarters[this.lastSpecies.speciesId])[valueReduction];
options.push({
label: `x${reductionCost} Reduce Cost`,
handler: () => {
if (candyCount >= reductionCost) {
starterData.valueReduction++;
starterData.candyCount -= reductionCost;
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({ options.push({
label: 'Cancel', label: 'Enable Passive',
handler: () => { handler: () => {
starterData.passiveAttr |= PassiveAttr.ENABLED;
ui.setMode(Mode.STARTER_SELECT); ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined);
return true; return true;
} }
}); });
ui.setModeWithoutClear(Mode.OPTION_SELECT, { } else {
options: options, options.push({
yOffset: 47 label: 'Disable Passive',
handler: () => {
starterData.passiveAttr ^= PassiveAttr.ENABLED;
ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined);
return true;
}
}); });
}; }
}
const showUseCandies = () => {
const options = [];
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
const passiveCost = getPassiveCandyCount(speciesStarters[this.lastSpecies.speciesId]);
options.push({
label: `x${passiveCost} Unlock Passive (${allAbilities[starterPassiveAbilities[this.lastSpecies.speciesId]].name})`,
handler: () => {
if (candyCount >= passiveCost) {
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
starterData.candyCount -= passiveCost;
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
this.scene.gameData.saveSystem().then(success => {
if (!success)
return this.scene.reset(true);
});
ui.setMode(Mode.STARTER_SELECT);
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined);
return true;
}
return false;
},
item: 'candy',
itemArgs: starterColors[this.lastSpecies.speciesId]
});
}
const valueReduction = starterData.valueReduction;
if (valueReduction < 2) {
const reductionCost = getValueReductionCandyCounts(speciesStarters[this.lastSpecies.speciesId])[valueReduction];
options.push({
label: `x${reductionCost} Reduce Cost`,
handler: () => {
if (candyCount >= reductionCost) {
starterData.valueReduction++;
starterData.candyCount -= reductionCost;
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({ options.push({
label: 'Use Candies', label: 'Cancel',
handler: () => { handler: () => {
ui.setMode(Mode.STARTER_SELECT).then(() => showUseCandies()); ui.setMode(Mode.STARTER_SELECT);
return true; return true;
} }
}); });
} ui.setModeWithoutClear(Mode.OPTION_SELECT, {
options: options,
yOffset: 47
});
};
options.push({
label: 'Use Candies',
handler: () => {
ui.setMode(Mode.STARTER_SELECT).then(() => showUseCandies());
return true;
}
});
options.push({ options.push({
label: 'Cancel', label: 'Cancel',
handler: () => { handler: () => {