Module:AB2 rank colors

local getArgs = require('Module:Common').getArgs

-- HTML colors: https://www.w3.org/TR/css-color-3/#svg-color local HTMLColors = { ['vanilla_card'] = 'powderblue', ['vanilla_slingshot'] = 'sienna', ['bronze'] = 'goldenrod', ['silver'] = 'silver', ['gold'] = 'gold', ['azure'] = 'slateblue', ['emerald'] = 'limegreen', ['amethyst'] = 'plum', ['diamond'] = 'palegreen', ['legendary'] = 'darkorange', }

local materialKeys = { 'bronze', 'silver', 'gold', 'azure', 'emerald', 'amethyst', 'diamond', }

local p = {}

p.getHTMLColor = function(frame) local args = getArgs(frame) local key = string.lower(args[1]) return HTMLColors[key] end

p.getHTMLColorByCardRank = function(frame) local args = getArgs(frame) local rank = tonumber(args[1]) if rank <= 1 then return HTMLColors['vanilla_card'] elseif rank >= 51 then return HTMLColors['legendary'] else -- rank >= 2, rank <= 50 return HTMLColors[materialKeys[(rank - 2) % 7 + 1]] end end

p.getHTMLColorBySlingshotRank = function(frame) local args = getArgs(frame) local rank = tonumber(args[1]) if rank <= 0 then return HTMLColors['vanilla_slingshot'] elseif rank >= 50 then return HTMLColors['legendary'] else -- rank >= 1, rank <= 49 return HTMLColors[materialKeys[(rank - 1) % 7 + 1]] end end

return p