Module:DropsLineTest: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1: Line 1:
local Test = {}
local p = {}


function Test.calculatePercentages(frame)
function p.determineColor(r)
     local args = frame.args
     r = tonumber(r) or 0 -- Convert r to a number or default to 0 if nil
    local dropRate = args[1] or "0/1" -- Extract the drop rate from the args, default to "0/1"
     if r <= 1 then
   
        return "#afeeee"
    -- Parsing the drop rate
     elseif r <= 25 then
    local numerator, denominator = dropRate:match("(%d+)/(%d+)")
        return "#56e156"
    denominator = tonumber(denominator) or 1 -- Convert denominator to a number or default to 1
     elseif r <= 100 then
   
        return "#ffed4c"
     local percentages = {}
     elseif r <= 1000 then
    -- Original number
        return "#ff863c"
    table.insert(percentages, dropRate)
     elseif r <= 9999999 then
     -- Donator (85% of original drop rate)
        return "#ff6262"
    local donatorDenominator = math.floor(denominator * 0.85)
     else
    local donator = string.format("%d/%d", numerator, donatorDenominator)
        return "#ffffff"
     table.insert(percentages, donator)
     end
    -- Super donator (75% of original drop rate)
    local superDonatorDenominator = math.floor(denominator * 0.75)
    local superDonator = string.format("%d/%d", numerator, superDonatorDenominator)
    table.insert(percentages, superDonator)
     -- Extreme donator (70% of original drop rate)
    local extremeDonatorDenominator = math.floor(denominator * 0.70)
    local extremeDonator = string.format("%d/%d", numerator, extremeDonatorDenominator)
     table.insert(percentages, extremeDonator)
    -- Legendary donator (65% of original drop rate)
    local legendaryDonatorDenominator = math.floor(denominator * 0.65)
    local legendaryDonator = string.format("%d/%d", numerator, legendaryDonatorDenominator)
     table.insert(percentages, legendaryDonator)
    -- Royal donator (60% of original drop rate)
    local royalDonatorDenominator = math.floor(denominator * 0.60)
    local royalDonator = string.format("%d/%d", numerator, royalDonatorDenominator)
    table.insert(percentages, royalDonator)
      
    return percentages
end
end


return Test
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

Revision as of 16:29, 5 May 2024

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