Module:DropsLineTest: Difference between revisions
Jump to navigation
Jump to search
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 16: | Line 16: | ||
return "#ffffff" | return "#ffffff" | ||
end | end | ||
end | |||
function p.calculateIncreasedRates(r) | |||
local rates = {} | |||
for i = 2, 6 do | |||
local percentageBoost = (i - 1) * 0.15 -- Calculate the percentage boost | |||
local increasedRate = r * (1 + percentageBoost) -- Calculate the increased drop rate | |||
rates[i] = increasedRate | |||
end | |||
return rates | |||
end | end | ||
Line 24: | Line 34: | ||
color = p.determineColor(r) | color = p.determineColor(r) | ||
else | else | ||
local increasedRates = p.calculateIncreasedRates(r) | |||
local | local increasedRate = increasedRates[n] or 0 -- Get the corresponding increased rate | ||
color = p.determineColor( | color = p.determineColor(increasedRate) | ||
end | end | ||
return string.format('style="background-color: %s;"', color) | return string.format('style="background-color: %s;"', color) |
Revision as of 16:21, 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.calculateIncreasedRates(r)
local rates = {}
for i = 2, 6 do
local percentageBoost = (i - 1) * 0.15 -- Calculate the percentage boost
local increasedRate = r * (1 + percentageBoost) -- Calculate the increased drop rate
rates[i] = increasedRate
end
return rates
end
function p.determineCellStyle(r, n)
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 increasedRates = p.calculateIncreasedRates(r)
local increasedRate = increasedRates[n] or 0 -- Get the corresponding increased rate
color = p.determineColor(increasedRate)
end
return string.format('style="background-color: %s;"', color)
end
return p