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 p = {}
local Test = {}


function p.determineColor(r)
function Test.calculatePercentages(frame)
     r = tonumber(r) or 0 -- Convert r to a number or default to 0 if nil
     local args = frame.args
     if r <= 1 then
    local dropRate = args[1] or "0/1" -- Extract the drop rate from the args, default to "0/1"
        return "#afeeee"
   
     elseif r <= 25 then
    -- Parsing the drop rate
        return "#56e156"
    local numerator, denominator = dropRate:match("(%d+)/(%d+)")
     elseif r <= 100 then
    denominator = tonumber(denominator) or 1 -- Convert denominator to a number or default to 1
        return "#ffed4c"
   
     elseif r <= 1000 then
    local percentages = {}
        return "#ff863c"
    -- Original number
     elseif r <= 9999999 then
    table.insert(percentages, dropRate)
        return "#ff6262"
    -- Donator (85% of original drop rate)
     else
    local donatorDenominator = math.floor(denominator * 0.85)
        return "#ffffff"
     local donator = string.format("%d/%d", numerator, donatorDenominator)
     end
     table.insert(percentages, donator)
    -- 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


function p.calculateIncreasedRate(r, percentageBoost)
return Test
    local increasedRate = r * (1 + percentageBoost) -- Calculate the increased drop rate
    return increasedRate
end
 
function p.determineCellStyle(r, n, donatorType)
    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 = donatorType and donatorType[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:24, 5 May 2024

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

local Test = {}

function Test.calculatePercentages(frame)
    local args = frame.args
    local dropRate = args[1] or "0/1" -- Extract the drop rate from the args, default to "0/1"
    
    -- Parsing the drop rate
    local numerator, denominator = dropRate:match("(%d+)/(%d+)")
    denominator = tonumber(denominator) or 1 -- Convert denominator to a number or default to 1
    
    local percentages = {}
    -- Original number
    table.insert(percentages, dropRate)
    -- Donator (85% of original drop rate)
    local donatorDenominator = math.floor(denominator * 0.85)
    local donator = string.format("%d/%d", numerator, donatorDenominator)
    table.insert(percentages, donator)
    -- 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

return Test