-- Main

return function(weightTable: { [string]: number }): string
	local total: number = 0
	for _, chance: number in pairs(weightTable) do
		total += chance
	end

	local pickedNumber: number = rand:NextInteger(1, total)

	local pickTotal: number = 0
	for name: string, chance: number in pairs(weightTable) do
		pickTotal += chance

		if pickTotal > pickedNumber then
			return name
		end
	end

	error("Something went wrong :(")
end
