mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
adds failsafe for when randomizer can't find a Pokemon
This commit is contained in:
@@ -128,12 +128,18 @@ def getRandomPokemon(originalPokemon,bstRange,maxDexNumber)
|
||||
bstMax = originalBst+bstRange
|
||||
|
||||
foundAPokemon = false
|
||||
int i=0
|
||||
while ! foundAPokemon
|
||||
newPoke = rand(maxDexNumber-1)+1
|
||||
newPokeBST = getBaseStatsTotal(newPoke)
|
||||
if newPokeBST >= bstMin && newPokeBST <= bstMax
|
||||
foundAPokemon = true
|
||||
end
|
||||
i+=1
|
||||
if i %10 ==0
|
||||
bstMin-=5
|
||||
bstMax+=5
|
||||
end
|
||||
end
|
||||
return newPoke
|
||||
end
|
||||
|
||||
@@ -278,8 +278,13 @@ def getNewSpecies(oldSpecies,bst_range=50, ignoreRivalPlaceholder = false, maxDe
|
||||
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
|
||||
newspecies_dex = rand(maxDexNumber - 1) + 1
|
||||
i=0
|
||||
while bstOk(newspecies_dex,oldSpecies_dex,bst_range)
|
||||
newspecies_dex = rand(maxDexNumber - 1) + 1
|
||||
i+=1
|
||||
if i%10 == 0
|
||||
bst_range += 5
|
||||
end
|
||||
end
|
||||
return newspecies_dex
|
||||
end
|
||||
@@ -290,10 +295,15 @@ def getNewCustomSpecies(oldSpecies,customSpeciesList,bst_range=50, ignoreRivalPl
|
||||
return oldSpecies_dex if (oldSpecies_dex == Settings::RIVAL_STARTER_PLACEHOLDER_SPECIES && !ignoreRivalPlaceholder)
|
||||
return oldSpecies_dex if oldSpecies_dex >= Settings::ZAPMOLCUNO_NB
|
||||
i = rand(customSpeciesList.length - 1) + 1
|
||||
n=0
|
||||
newspecies_dex = customSpeciesList[i]
|
||||
while bstOk(newspecies_dex,oldSpecies_dex,bst_range)
|
||||
i = rand(customSpeciesList.length - 1)#+1
|
||||
newspecies_dex = customSpeciesList[i]
|
||||
n+=1
|
||||
if n % 10 == 0
|
||||
bst_range+=5
|
||||
end
|
||||
end
|
||||
return newspecies_dex
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user