Module:Statname

-- local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local onmain = require('Module:Mainonly').on_main local string = require('Module:String') local p = {}

-- Converts Aliases into ID's local aliases = require('Module:Statname/aliases')

local txtshdw = "; text-shadow: 1px 1px 1px black" local stats = { ['health']={ name="Health", nameShort="HP", icon="Health icon.png", color="#e73c3c" },   ['defense']={ name="Defense", nameShort="Def", icon="Defense icon.png", color="#00d400" },   ['effective health']={ name="Effective Health", nameShort="EHP", icon="Health icon.png", color="#e73c3c" },   ['strength']={ name="Strength", nameShort="Str", icon="Strength icon.png", color="#e73c3c" },   ['speed']={ name="Speed", nameShort="Spd", icon="Speed icon.png", color="#eee"..txtshdw },   ['crit chance']={ name="Crit Chance", nameShort="Cr Chnc", icon="Crit chance icon.png", color="#5555ff" },   ['crit damage']={ name="Crit Damage", nameShort="Cr Dmg", icon="Crit damage icon.png", color="#5555ff" },   ['intelligence']={ name="Intelligence", nameShort="Int", icon="Intelligence icon.png", color="cyan" },   ['mana']={ name="Mana", nameShort="Mana", icon="Intelligence icon.png", color="cyan" },   ['mana cost']={ name="Mana Cost", nameShort="Mana Cst", icon="Intelligence icon.png", color="cyan" },   ['true defense']={ name="True Defense", nameShort="Tru Def", icon="True Defense icon.png", color="white"..txtshdw },   ['absorption']={ name="Absorption", nameShort="Absorb", icon="Absorption icon.png", color="#ffaa00" },   ['magic find']={ name="Magic Find", nameShort="Mag Fnd", icon="Magic Find icon.png", color="cyan" },   ['pet luck']={ name="Pet Luck", nameShort="Pet Lck", icon="Pet Luck icon.png", color="#FF55FF" },   ['sea creature chance']={ name="Sea Creature Chance", nameShort="SCC", icon="Sea creature chance icon.png", size="16px", color="#00AAAA" },   ['damage']={ name="Damage", nameShort="Dmg", icon="Damage Icon.png", size="16px", color="white"..txtshdw },       ['bonus attack speed']={ name="Bonus Attack Speed", nameShort="Atk Spd", icon="Bonus Attack Speed icon.png", color="#FDED00" },   ['true damage']={ name="True Damage", nameShort="Tru Dmg", icon="True Damage Icon.png", color="white"..txtshdw },   ['fishing speed']={ name="Fishing Speed", nameShort="Fshng Spd", icon="Fishing Rod.png", color="#49e02b" },   ['ability damage']={ name="Ability Damage", nameShort="Ablty Dmg", icon="Ability Damage.png", color="#577cc5" },   ['ferocity']={ name="Ferocity", nameShort="Frcty", icon="Ferocity icon.png", color="#FF5555" }, }

function p.getStatName(frame) local args = getArgs(frame) local statid = args[1] local valBefore = args[2] local isShort = yesno(args["short"]) return p._getStatName(statid, valBefore, isShort) end

function p.getStatNameShort(frame) local args = getArgs(frame) local statid = args[1] local valBefore = args[2] return p._getStatName(statid, valBefore, true) end

function p._getStatName(statid, valBefore, isShort) statid = statid:lower:gsub('_', ' ') statid = aliases[statid] or statid local stat = stats[statid] if not stat then return string.error("Invalid Stat %q", statid) end return string.wrapHtml{ {               valBefore and string.wrapHtml(valBefore, ' ', { style=table.concat{ "color:", stat.color }}) .." " or "", string.makeImage(stat.icon, { size=stat.size or "18x18px", link=stat.name }), string.wrapHtml{ " ",                    " ", {                         style={ ["font-family"]="initial"; }                   }                },                string.makeLink(                    stat.name,                     string.wrapHtml{                         isShort and stat.nameShort or stat.name,                         ' ', {                             style=table.concat{ "color:", stat.color },                        }                    }                ), },           ' ', {                style={ ["white-space"]="nowrap"; }           }        } end

return p