From d517b4fb9ee829be27fad314e1c3fc96dd22c2c7 Mon Sep 17 00:00:00 2001 From: MarshRey Date: Sat, 18 May 2024 11:31:28 -0600 Subject: [PATCH] Uniformly picking pokemon - Constructed an array with the point values repeated based on the number of pokemon with that point value - Tested mobile capabilities and found the system runs better than previously --- src/ui/starter-select-ui-handler.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 0f42ab21a6e..92b1e6ffcac 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -1899,8 +1899,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } // Randomly select a point value from the available point values - // TODO: Random generation is with bias based on how many pokemon are in each point value - const randomPointValue = availablePointValues[Utils.randInt(availablePointValues.length, 0)]; + // Construct an array with the point values repeated based on the number of pokemon with that point value + // This array is used to randomly select a point value with bias + const pointValueArray = availablePointValues.reduce((acc, value) => { + const numPokemon = this.possibleStarterPokemon[value].length; + for (let i = 0; i < numPokemon; i++) { + acc.push(value); + } + return acc; + }, []); + 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 const speciesInf = this.possibleStarterPokemon[randomPointValue][Utils.randInt(this.possibleStarterPokemon[randomPointValue].length, 0)]; @@ -1944,6 +1953,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { return true; } + // deprecated function _generateRandomStarter(): boolean { var generatedValidPokemon:boolean = false; var hasValidPokemon:boolean = false; @@ -2018,7 +2028,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } isValidStarter(species): bigint { - const useOnlyOwnedPokemon:boolean = false; + const useOnlyOwnedPokemon:boolean = true; if (useOnlyOwnedPokemon) { return this.scene.gameData.dexData[species.speciesId].caughtAttr; }