Module:UprisingEquipmentInfobox

local p = {} local defaults = { image = "", name = "", description = "", tier = "", evolution = "", stars = "", maxstarcount = "", type = "", gearsetname = "", gearsetdisplayname = "", baselevel = "", levelcap = "?", navnext = "", basestat = "", credits = "", -- Attack attack = "", attackmin = "", attackbase = "", attackmax = "", -- Armor armor = "", armormin = "", armorbase = "", armormax = "", -- Utility utility = "", utilitymin = "", utilitybase = "", utilitymax = "", -- Mods mod1name = "", mod1value = "", mod2name = "", mod2value = "", mod3name = "", mod3value = "", mod4name = "", mod4value = "", mod5name = "", mod5value = "", mod6name = "", mod6value = "", upgradecomponent1name = "", upgradecomponent1type = "", upgradecomponent1prefix = "", upgradecomponent1count = "", upgradecomponent2name = "", upgradecomponent2type = "", upgradecomponent2prefix = "", upgradecomponent2count = "", upgradecomponent3name = "", upgradecomponent3type = "", upgradecomponent3prefix = "", upgradecomponent3count = "", upgradecost = "", sellpricemin = "", sellpricemax = "", noimagebg = "" }

function Yesno(val, default) val = type(val) == 'string' and mw.ustring.lower(val) or val if val == nil then return nil elseif val == true or val == 'yes' or val == 'y'		or val == 'true' or val == 't'		or tonumber(val) == 1 then return true elseif val == false or val == 'no' or val == 'n'		or val == 'false' or val == 'f'		or tonumber(val) == 0 then return false else return default end end

function p._genStars(frame, args, getValue) local stars = tonumber(getValue('stars', false) or 0) local maxStarCount = tonumber(getValue('maxstarcount', false) or 0) local noMinWidth = getValue('nominwidth', false) local minWidth = getValue('minwidth', false) or '250px' local minWidthStr = '' if noMinWidth == nil or Yesno(noMinWidth, false) == false then minWidthStr = 'min-width:' .. minWidth .. ';'   end

local out = ' ' if stars > 0 then for i=1,stars do           out = out .. '&#9733;'       end end if maxStarCount > stars then for i=stars,maxStarCount do           out = out .. '&#9734;'       end end out = out .. ' '    return out end

function resolveType(_type) _type = mw.ustring.lower(_type) if type == 'weapon' then return 'weapon' end return '' end

function p._genInfo(frame, args, getValue) local _type = getValue('type', '') local base = getValue('baseStat', false) or getValue('base', '') local element = getValue('element', false) local faction = getValue('faction', false)

local out = '' out = out .. '' out = out .. 'Type:' .. _type .. '' out = out .. 'Base:' .. base .. '' if faction then out = out .. 'Faction:' .. faction .. '' end if element then out = out .. 'Element:</dt>' .. element .. '</dd>' end out = out .. '</dl>' out = out .. ' '   return out end

function p._genNav(frame, args, getValue) local navNext = getValue('navNext', false) local navPrev = getValue('navPrev', false)

local out = ' ' out = out .. '<div style="float:right;font-family:magistral_medium,arial,helvetica,sans-serif;">' if navNext then out = out .. 'Next &#62;' else out = out .. ' Next &#62; ' end out = out .. ' '       out = out .. '<div style="float:right;font-family:magistral_medium,arial,helvetica,sans-serif;">' if navPrev then out = out .. '&#60; Prev' else out = out .. ' &#60; Prev ' end out = out .. ' '   out = out .. ' '   return out end

function _genStatsTableCell(name, value, colspan) local _colspan = colspan and (' colspan="' .. colspan .. '" ') or '' local _name = mw.ustring.lower(name) local bgColor = 'rgb(18, 48, 98)' local txtColor = 'rgba(54, 148, 202, 0.4)' local displayName = '' local shortName = '' if name == 'attack' then bgColor = 'rgb(18, 48, 98)' txtColor = 'rgba(54, 148, 202, 0.4)' displayName = 'Attack' shortName = 'Attack' elseif name == 'armor' then bgColor = 'rgb(33, 29, 66)' txtColor = 'rgba(120, 93, 136, 0.4)' displayName = 'Armor' shortName = 'Armor' elseif name == 'Utility' then bgColor = 'rgb(23, 38, 46)' txtColor = 'rgba(35, 149, 115, 0.4)' displayName = 'Utility' shortName = 'Utility' elseif name == 'ranged' then bgColor = 'rgb(18, 48, 98)' txtColor = 'rgba(54, 148, 202, 0.4)' displayName = 'Ranged' shortName = 'Ranged' elseif name == 'dodge' then bgColor = 'rgb(33, 29, 66)' txtColor = 'rgba(120, 93, 136, 0.4)' displayName = 'Dodge' shortName = 'Dodge' elseif name == 'attackspeed' or name == 'attack speed' then bgColor = 'rgb(18, 48, 98)' txtColor = 'rgba(54, 148, 202, 0.4)' displayName = 'Attack Speed' shortName = 'Attk Spd' elseif name == 'levelcap' or name == 'level cap' or name == 'max upgrade level' then bgColor = 'rgb(206, 204, 77)' txtColor = 'rgba(0, 0, 0, 0.4)' displayName = 'Max Upgrade Level' shortName = 'Max Upgrade Level' else if type(name) == 'string' then displayName = name shortName = name end end local out = '<td ' .. colspan .. ' style="text-align:center;background-color:' .. bgColor .. ';padding:5px 5px;border-color:#BFDAEB;" title="' .. displayName .. '">' out = out .. '<div style="font-size: 1.5em; font-weight: 400; color: ' .. txtColor .. ';white-space:nowrap;line-height:0.75em;">' .. shortName .. ' '   out = out .. ' ' .. value .. ' '   out = out .. ' '   return out end

function p._genStatsTable(frame, args, getValue) local attack = getValue('attack', '?') local armor = getValue('armor', '?') local utility = getValue('utility', '?') local ranged = getValue('ranged', '?') local dodge = getValue('dodge', '?') local attackspeed = getValue('attackspeed', '?') local levelCap = getValue('levelcap', false)

local out = ' ' return out end

function p._genInfobox(frame, args, getValue, argNames) local noImageBG = getValue('noimagebg', true) local infoboxArgs = { name = '', description = '', tier = '1', stars = '0', maxStarCount = '0', credits = '?' }   local setIBoxValue = function(key, oKey, val) if mw.ustring.match(k, '^(attack|armor|utility)(min|max|base)$') ~= nil then infoboxArgs[oKey] = ' ' .. val .. ' '       else infoboxArgs[oKey] = val end end for k, v in pairs(args) do       if argNames[k] ~= nil then -- infoboxArgs[argNames[k]] = getValue(k, true) setIBoxValue(k, argNames[k], getValue(k, true)) else setIBoxValue(k, k, getValue(k, true)) -- infoboxArgs[k] = getValue(k, true) end end infoboxArgs.name = ' ' .. infoboxArgs.name .. ' '   infoboxArgs.description = ' ' .. (infoboxArgs.description or '') .. ' '   infoboxArgs.stars = p._genStars(frame, args, getValue) infoboxArgs.info = p._genInfo(frame, args, getValue) infoboxArgs.credits = '<span style="font-family:magistral_medium,arial,helvetica,sans-serif;font-size:22px;"> ' .. infoboxArgs.credits .. ' '   infoboxArgs.statTable = p._genStatsTable(frame, args, getValue) infoboxArgs.navigation = p._genNav(frame, args, getValue) local out = ' ' out = out .. frame:expandTemplate{title = 'UprisingEquipmentInfobox/main2', args = infoboxArgs} out = out .. ' '   return out -- return frame:preprocess(out) end

function p._main(frame, args, getValue, argNames) local _get = args.get if _get ~= nil and _get ~= '' and _get ~= 'infobox' then _get = mw.ustring.lower(tostring(_get)) if _get == 'starsrender' then return p._genStars(frame, args, getValue, argNames) elseif _get == 'row' or _get == 'rowfull' then -- ToDo return '' elseif mw.ustring.match(_get, '^iconborder') ~= nil then -- ToDo return '' elseif getValue(_get, true) ~= nil then return getValue(_get, true) end end return p._genInfobox(frame, args, getValue, argNames) end

function p.main(frame) local args = {} local argNames = {} local tmp = {} if frame == mw.getCurrentFrame then tmp = frame:getParent.args else tmp = frame.args end for k,v in pairs(tmp) do       local lKey = mw.ustring.lower(value) argNames[lKey] = key if v ~= nil and mw.text.trim(tostring(v)) ~= '' then local isNum = mw.text.trim(tostring(v)):match('^%s*(%d+)%s*$') if isNum ~= nil then args[lKey] = tonumber(isNum) elseif type(v) == 'string' then args[lKey] = mw.text.trim(v) else args[lKey] = v           end end end local getValue = function(name, useDefault) local key = mw.ustring.lower(name) if not args[key] then if type(useDefault) == 'string' or type(useDefault) == 'number' then return useDefault elseif not useDefault then return nil else return defaults[key] end end return args[key] end return p._main(frame, args, getValue, argNames) end

return p