-- Weighted selection
-- 100 total weight

petModule.rarities = {
	
	["Legendary"] = 5; -- 5% chance

	["Rare"] = 15; -- 15% chance
	
	["Uncommon"] = 30; -- 30% chance
	
	["Common"] = 50; -- 50% chance

}

petModule.chooseRandomPet = function()

	local randomNumber = math.random(1,100)
	
	local counter = 0
	
	for rarity, weight in pairs(petModule.rarities) do
		counter = counter + weight
		if randomNumber <= counter then
			
			local rarityTable = petModule.pets[rarity]
			local chosenPet = rarityTable[math.random(1,#rarityTable)]
			
			return chosenPet
			
		end
	end
	
	
end

return petModule
