Module:Rarity
From ARC Raiders Wiki
More actions
Provides rarity type data and rendering for use in templates like Template:Rarity.
local getArgs = require('Module:Arguments').getArgs
local p = {}
local rarityData = {
common = '#6c6c6c',
uncommon = '#26bf57',
rare = '#00a9f2',
epic = '#cc3099',
legendary = '#ffc600'
}
-- Normalizes input to a valid rarityData key
local function normalizeInput(input)
if not input or input == '' then return nil end
local key = string.lower(input)
return rarityData[key] and key or nil
end
-- Renders an error message for an unknown rarity type
local function renderError(input)
local text = 'Unknown rarity type: ' .. (input or 'nil')
return '<span style="color:red;">' .. text .. '</span>'
end
-- Returns a color hexcode for the given color
function p.main(frame)
local args = getArgs(frame)
local key = normalizeInput(args.rarity or args[1])
if not key then return renderError(args.rarity or args[1]) end
return rarityData[key]
end
return p