Module:Boss collection log calculator

local yesno = require ("Module:Yesno") local p = {}

function p.main(frame) math.randomseed(os.time) local args = frame:getParent.args local denominator = 200 local loops = denominator * 1000 local drops = {} local killCount = 0 local threshold = denominator / 5 local range = {} local rangeCount = 0

for i=0,loops do   local value = math.math.random(1, denominator) killCount = killCount + 1 if killCount >= threshold * 9 then if value >= 1 and value <= 10 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 8 then if value >= 1 and value <= 9 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 7 then if value >= 1 and value <= 8 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 6 then if value >= 1 and value <= 7 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 5 then if value >= 1 and value <= 6 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 4 then if value >= 1 and value <= 5 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 3 then if value >= 1 and value <= 4 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 2 then if value >= 1 and value <= 3 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif killCount >= threshold * 1 then if value >= 1 and value <= 2 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end elseif value == 1 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 killCount = 0 end if range[1] > 0 then if killCount < 3 then i = i + killCount end range[1] = 0 rangeCount = rangeCount + 1 killCount = 0 end end local averageKills = loops / drop[1] local finalRangeCount = loops / rangeCount return averageKills end

return p