Module:DropsLineTest: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
 
(58 intermediate revisions by the same user not shown)
Line 1: Line 1:
local Test = {}
local p = {}


function Test.calculatePercentages(frame)
-- Define a function to generate output numbers based on the input
     local args = frame.args
function p.generateOutput(frame)
    local dropRate = args[1] or "0/1" -- Extract the drop rate from the args, default to "0/1"
     local inputNumber = tonumber(frame.args[1]) or 0
   
    local output = {}
     -- Parsing the drop rate
 
     local numerator, denominator = dropRate:match("(%d+)/(%d+)")
    -- Add the input number
    denominator = tonumber(denominator) or 1 -- Convert denominator to a number or default to 1
    table.insert(output, "\" | 1/" .. inputNumber)
 
     -- Calculate percentages and choose color based on the percentage
     local percentages = {0.85, 0.75, 0.70, 0.65, 0.60} -- Percentages
    local colors = {"#ff9999", "#7aa7ff", "#d699ff", "#fff59e", "#b3f1ff"} -- Corresponding colors
      
      
     local percentages = {}
     for i, percent in ipairs(percentages) do
    -- Original number
        local value = math.floor(inputNumber * percent)
    table.insert(percentages, dropRate)
        local color = colors[i]
    -- Donator (85% of original drop rate)
        table.insert(output, "| style=\"background-color: " .. color .. ";\" | 1/" .. value)
    local donatorDenominator = math.floor(denominator * 0.85)
     end
    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
     return table.concat(output, '\n')
end
end


return Test
return p

Latest revision as of 17:59, 7 May 2024

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

local p = {}

-- Define a function to generate output numbers based on the input
function p.generateOutput(frame)
    local inputNumber = tonumber(frame.args[1]) or 0
    local output = {}

    -- Add the input number
    table.insert(output, "\" | 1/" .. inputNumber)

    -- Calculate percentages and choose color based on the percentage
    local percentages = {0.85, 0.75, 0.70, 0.65, 0.60} -- Percentages
    local colors = {"#ff9999", "#7aa7ff", "#d699ff", "#fff59e", "#b3f1ff"} -- Corresponding colors
    
    for i, percent in ipairs(percentages) do
        local value = math.floor(inputNumber * percent)
        local color = colors[i]
        table.insert(output, "| style=\"background-color: " .. color .. ";\" | 1/" .. value)
    end
    
    return table.concat(output, '\n')
end

return p