mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-17 05:42:18 +02:00
Code Cleanup + Bug Fix
- Removed unused code - Adjusted comment for better readability - Going back to home screen while Randomize is selected no longer keeps it highlighted when reentering starter select
This commit is contained in:
parent
d10d734d36
commit
c09839a654
@ -721,6 +721,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.setGenMode(true);
|
this.setGenMode(true);
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
this.tryUpdateValue(0);
|
this.tryUpdateValue(0);
|
||||||
|
this.setRandomizeMode(false);
|
||||||
|
|
||||||
handleTutorial(this.scene, Tutorial.Starter_Select);
|
handleTutorial(this.scene, Tutorial.Starter_Select);
|
||||||
|
|
||||||
@ -1865,7 +1866,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Using a list of all possible starters, generates a dictionary of all possible owned starters by point value
|
// Using a list of all possible starters, generates a dictionary of all possible owned starters by point value
|
||||||
// {value: [speciesA, speciesB, speciesC, ...]}
|
// {value: [[speciesA, gen, species], ...]}
|
||||||
prepopulateRandomStarterPokemonDictionary(): void {
|
prepopulateRandomStarterPokemonDictionary(): void {
|
||||||
this.possibleStarterPokemon = {};
|
this.possibleStarterPokemon = {};
|
||||||
for (let g = 0; g < this.genSpecies.length; g++) {
|
for (let g = 0; g < this.genSpecies.length; g++) {
|
||||||
@ -1880,7 +1881,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(this.possibleStarterPokemon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using possibleStarterPokemon
|
// Using possibleStarterPokemon
|
||||||
@ -1909,16 +1909,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
const randomPointValue = pointValueArray[Utils.randInt(pointValueArray.length, 0)];
|
const randomPointValue = pointValueArray[Utils.randInt(pointValueArray.length, 0)];
|
||||||
// const randomPointValue = availablePointValues[Utils.randInt(availablePointValues.length, 0)];
|
|
||||||
|
|
||||||
// Randomly select a pokemon from the list of pokemon with the selected point value
|
// Randomly select a pokemon from the list of pokemon with the selected point value
|
||||||
const speciesInf = this.possibleStarterPokemon[randomPointValue][Utils.randInt(this.possibleStarterPokemon[randomPointValue].length, 0)];
|
const speciesInf = this.possibleStarterPokemon[randomPointValue][Utils.randInt(this.possibleStarterPokemon[randomPointValue].length, 0)];
|
||||||
const species = speciesInf[0];
|
const species = speciesInf[0];
|
||||||
const gen = speciesInf[1];
|
const gen = speciesInf[1];
|
||||||
const speciesId = speciesInf[2];
|
const speciesId = speciesInf[2];
|
||||||
// console.log("choosing point value", randomPointValue, "species", speciesId, "gen", gen);
|
|
||||||
// console.log("global species", species);
|
|
||||||
// console.log("local species", this.genSpecies[gen][speciesId]);
|
|
||||||
|
|
||||||
// The value is guaranteed to be less than the value limit so no need to check, simple call suffices
|
// The value is guaranteed to be less than the value limit so no need to check, simple call suffices
|
||||||
this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId));
|
this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId));
|
||||||
@ -1929,6 +1925,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
cursorObj.setPosition(-100, -100);
|
cursorObj.setPosition(-100, -100);
|
||||||
|
|
||||||
// Generate the nature, ability, and moveset for the pokemon
|
// Generate the nature, ability, and moveset for the pokemon
|
||||||
|
// TODO: Add support for more than the default ability, natures, etc.
|
||||||
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null;
|
this.speciesStarterDexEntry = species ? this.scene.gameData.dexData[species.speciesId] : null;
|
||||||
this.dexAttrCursor = species ? this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true) : 0n;
|
this.dexAttrCursor = species ? this.scene.gameData.getSpeciesDefaultDexAttr(species, false, true) : 0n;
|
||||||
this.abilityCursor = species ? this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species) : 0;
|
this.abilityCursor = species ? this.scene.gameData.getStarterSpeciesDefaultAbilityIndex(species) : 0;
|
||||||
@ -1949,8 +1946,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
// Remove the selected pokemon from the dictionary
|
// Remove the selected pokemon from the dictionary
|
||||||
this.possibleStarterPokemon[randomPointValue].splice(this.possibleStarterPokemon[randomPointValue].indexOf(speciesInf), 1);
|
this.possibleStarterPokemon[randomPointValue].splice(this.possibleStarterPokemon[randomPointValue].indexOf(speciesInf), 1);
|
||||||
// console.log("removed", speciesId, "from", randomPointValue);
|
|
||||||
// console.log(this.possibleStarterPokemon[randomPointValue]);
|
|
||||||
// If there is no more pokemon for this key, remove the key
|
// If there is no more pokemon for this key, remove the key
|
||||||
if (this.possibleStarterPokemon[randomPointValue].length === 0) {
|
if (this.possibleStarterPokemon[randomPointValue].length === 0) {
|
||||||
delete this.possibleStarterPokemon[randomPointValue];
|
delete this.possibleStarterPokemon[randomPointValue];
|
||||||
@ -1958,7 +1954,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
// deprecated function
|
|
||||||
|
|
||||||
|
// Deprecated function for less efficient random starter generation
|
||||||
_generateRandomStarter(): boolean {
|
_generateRandomStarter(): boolean {
|
||||||
var generatedValidPokemon:boolean = false;
|
var generatedValidPokemon:boolean = false;
|
||||||
var hasValidPokemon:boolean = false;
|
var hasValidPokemon:boolean = false;
|
||||||
@ -2032,6 +2030,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
isValidStarter(species): bigint {
|
isValidStarter(species): bigint {
|
||||||
const useOnlyOwnedPokemon:boolean = true;
|
const useOnlyOwnedPokemon:boolean = true;
|
||||||
if (useOnlyOwnedPokemon) {
|
if (useOnlyOwnedPokemon) {
|
||||||
|
Loading…
Reference in New Issue
Block a user