what would be the most accurate rarity logic for example for pet system?
here is what i made for it
function EggService:SelectRandomPet(eggname: string)
local totalchance = 0
local tempchance = 0
for _, chance in pairs(EggModule.GetAllPets(eggname)) do
totalchance += chance
end
local RandomNum = math.random() * totalchance
for petname, chance in pairs(EggModule.GetAllPets(eggname)) do
tempchance += chance
if RandomNum <= tempchance then
return petname
end
end
end
do you think its accurate ?