Module:DropsLineTest

From Roat Pkz
Revision as of 16:29, 5 May 2024 by Hefner (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:DropsLineTest/doc

local p = {}

function p.determineColor(r)
    r = tonumber(r) or 0 -- Convert r to a number or default to 0 if nil
    if r <= 1 then
        return "#afeeee"
    elseif r <= 25 then
        return "#56e156"
    elseif r <= 100 then
        return "#ffed4c"
    elseif r <= 1000 then
        return "#ff863c"
    elseif r <= 9999999 then
        return "#ff6262"
    else
        return "#ffffff"
    end
end

function p.calculateIncreasedRate(r, percentageBoost)
    local increasedRate = r * (1 + percentageBoost) -- Calculate the increased drop rate
    return increasedRate
end

function p.determineCellStyle(r, n, donatorTypes)
    r = tonumber(r) or 0 -- Convert r to a number or default to 0 if nil
    local color
    if n == 1 then
        color = p.determineColor(r)
    else
        local percentageBoost = donatorTypes and donatorTypes[n - 1] or 0 -- Get the percentage boost for the donator type
        local increasedRate = p.calculateIncreasedRate(r, percentageBoost)
        color = p.determineColor(increasedRate)
    end
    return string.format('style="background-color: %s;"', color)
end

return p