I'm working on a job system where you can mine different types of ores in a discord bot. Depending on your skill, the chances (stored in a database) to receive certain ores change. Some will have a 0% chance at certain skill levels. At Skill 1 the chances will be the following:
let coal_chance = 80
let copper_chance = 15
let iron_chance = 5
let gold_chance = 0
let diamond_chance = 0
let emerald_chance = 0
And at Skill 2 the following:
let coal_chance = 50
let copper_chance = 35
let iron_chance = 10
let gold_chance = 5
let diamond_chance = 0
let emerald_chance = 0
And so on. My question is, how can I make a chance system based on these percentages?
I tried making a system using Math.Random()
and an if statement, but since I have to check for a different amount of values each time I would have to make one for every skill level, and if I ever wanted to set the chance of a certain ore to 0% inside the database, I would also have to change the code.