Module:Armor/StatsList

local statName = require(Module:Statname).getStatName local string = require('Module:String')

return function(item, noStatsValue) local t = {} local statFormat1 = '%s: %s' local statFormat2 = '%s: %s&#32;(%s)' local function parseStat(val, stat, percent) if not val or val == '' then return end percent = percent or '' if type(val) == 'number' and val > 0 then t[#t+1] = string.format('%s: +%s', statName{stat}, val..percent) elseif type(val) ~= "table" and string.match(val, '^([^%D]+)$') and not val[2] then t[#t+1] = string.format('%s: %s', statName{stat}, val..percent) elseif type(val) == 'table' and string.match(val[1] or '', '^([^%D]+)$') then t[#t+1] = string.format('%s: +%s&#32;(%s)', statName{stat}, val[1]..percent, val[2]) elseif type(val) == "table" and val.lower then t[#t+1] = string.format('%s: %s-%s', statName{stat}, (val.lower > 0 and '+' or '')..val.lower..percent, val.upper..percent) elseif type(val) == "table" and type(val[2]) ~= "string" then t[#t+1] = string.format('%s: %s&#32;(%s)', statName{stat}, val[1]..percent, val[2]) elseif tostring(val):match('([%+%-]?)(%d+)%-(%d+)') then t[#t+1] = string.format('%s: %s%s', statName{stat}, not val:match('^[%-%+]') and '+' or , val:gsub('%%$', )..percent) else t[#t+1] = string.format('%s: %s</li>', statName{stat}, val..percent) end end --Damage parseStat(item.dmg, 'dmg') --Strength parseStat(item.str, 'str') --Crit Chance parseStat(item.cc, 'cc', '%') --Crit Damage parseStat(item.cd, 'cd', '%') --Attack Speed parseStat(item.as, 'as', '%') --Intelligence parseStat(item.int, 'int') --Speed parseStat(item.spd, 'spd', '%') --Health parseStat(item.hp, 'hp') --Defense parseStat(item.def, 'def') --True Defense parseStat(item.td, 'td') --Ferocity parseStat(item.fer, 'fer') --Sea Creature Chance parseStat(item.scc, 'scc', '%') --Fishing Speed parseStat(item.fs, 'fs', '%') if #t == 0 then return noStatsValue end return string.wrapHtml{ t,      '<ul>', { style="list-style-type:square;"; }   } end