Last active
January 25, 2024 05:17
-
-
Save Hidden50/20028e647375a5e7d28ec85583bb543f to your computer and use it in GitHub Desktop.
Calculate the chance for a pokemon to fit 9 hp slots, for the 9500 HP challenge in Pokemon Quest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Calculate the chance for a pokemon to fit 9 hp slots, for the 9500 HP challenge in Pokemon Quest | |
use on the browser console at https://hidden50.github.io/pq/ | |
*/ | |
(function () { | |
const impossibleDishes = ["Grass_basic", "Poison_basic", "Bug_basic", "Flying_basic", "Electric_basic", "Ambrosia_basic", "Fighting_basic", "Water_special", "Psychic_special", "Fighting_special"]; | |
const dataCopy = JSON.parse(JSON.stringify(app.pokeData)); | |
const list = []; | |
for (const pokemon of dataCopy) { | |
// extract the relevant properties from the pokedex | |
const {name, recipes, stoneSlots} = pokemon; | |
// skip evolved pokemon | |
if (!recipes) { | |
continue; | |
} | |
// calculate the chance to fit 9 hp stones | |
const {hpChanceWeight, atkChanceWeight, multiSlotChances} = stoneSlots; | |
const [multiBaseChance, multiGolfChance, multiKangChance, multiBothChance] = multiSlotChances; | |
const challengeChance = app.math.slotProbability(0, 9, hpChanceWeight, atkChanceWeight, multiBothChance); | |
for (const [dish, chance] of Object.entries(recipes)) { | |
// delete impossible dishes | |
if (impossibleDishes.includes(dish)) { | |
delete recipes[dish]; | |
} | |
// multiply the dish chances with the challenge chance | |
recipes[dish] = challengeChance * +chance.substr(0, chance.length - 1); | |
} | |
list.push({name, recipes, challengeChance}); | |
} | |
return list.sort( (x,y) => Object.values(y.recipes)[0] - Object.values(x.recipes)[0] ); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment