Documentation for this module may be created at Module:Boss pets calculator/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local dropChance = tonumber(args.denominator) or 5000
local threshold = tonumber(args.threshold) or 1000
local kills = 1000000
local playerKillCount = tonumber(args.killCount) or 0
local currentKillCount = playerKillCount
local startKillCount = 0
local endKillCount = 0
local petsAcquired = 0
local leastKills = kills
local mostKills = 0
local pet = 0
if threshold <= 0 then
threshold = kills
end
math.randomseed(os.time())
for i=1,kills do
local petRNG = math.random(1, dropChance)
if petRNG <= math.min(math.floor(currentKillCount / threshold) + 1, 10) then
pet = pet + 1
end
currentKillCount = currentKillCount + 1
if pet > 0 then
petsAcquired = petsAcquired + 1
pet = 0
endKillCount = i
local totalKills = endKillCount - startKillCount
if totalKills > mostKills then
mostKills = totalKills
end
if totalKills < leastKills then
leastKills = totalKills
end
startKillCount = i
currentKillCount = playerKillCount
end
end
local averageKills = kills / petsAcquired
local s = "<div style=\"font-weight:bold\">" .. string.format("%.0f", kills) .. " bosses died in a click of a button!<br>The boss pet was acquired after " .. string.format("%.0f", averageKills) .. " kills on average, across a sample size of " .. string.format("%.0f", kills) .. " boss kills.<br>The least amount of kills it took to acquire a boss pet was " .. string.format("%.0f", leastKills) .. " kill(s).<br>The most amount of kills it took to acquire a boss pet was " .. string.format("%.0f", mostKills) .. " kills.</div>"
return s
end
return p