Module:GuyPerfect

-- Helper Functions ---

-- Mapping of game codes to full game names local GAMES = { S = "Splatoon", S2 = "Splatoon 2" }

-- Common infobox opener function OpenInfobox(color, title) -- Outer container local ret = ""

-- Inner client area ret = ret .. ""

-- Title ret = ret .. "" .. title .. " "

return ret end

-- Common parameters opener function OpenParams return "" end

-- Common infobox and parameters closer function CloseAll return "  " end

-- Produce a parameter row for an infobox function ParamRow(color, label, content)

-- Outer label container, styles the left vertical edge local ret = ""

-- Inner label container, styles the horizontal edges and background ret = ret .. ""

-- Parameter contents return ret .. label .. "  " .. content .. " " end

-- Produce an image and a link for a parameter row function ParamImageLink(filename, link, opacity) local img = "" if opacity then img = "" .. img .. " "   end return img .. " " .. link .. "" end

-- Infoboxes --

-- Gear function Gear(frame) local color = frame:expandTemplate { title = "SiteColor", args = { GAMES[frame.args.game] } } local ret = OpenInfobox(color, frame.args.name)

-- Image ret = ret .. "[[File:" .. frame.args.game ..         "_Gear_" .. frame.args.category .. "_" .. frame.args.name ..         ".png|128x128px]] "

-- Parameters ret = ret .. OpenParams

-- Category row if frame.args.category then ret = ret .. ParamRow(color, "Category", ParamImageLink( "S2_Icon_" .. frame.args.category .. ".png", frame.args.category, 0.5))   end

-- Brand row if frame.args.brand then ret = ret .. ParamRow(color, "Brand", ParamImageLink( frame.args.game .. "_Brand_" .. frame.args.brand .. ".png", frame.args.brand ))   end

-- Ability row if frame.args.ability then ret = ret .. ParamRow(color, "Ability", ParamImageLink( frame.args.game .. "_Ability_" .. frame.args.ability .. ".png", frame.args.ability ))   end

-- Cost row if frame.args.cost then ret = ret .. ParamRow(color, "Cost", frame:expandTemplate           { title = "Cost", args = {                frame.args.game, frame.args.cost, "cash", "link"            } }        ) end

-- SplatNet 2 row if frame.args.splatnet2 then ret = ret .. ParamRow(color, "SplatNet 2", frame:expandTemplate           { title = "Cost", args = {                frame.args.game, frame.args.splatnet2, "cash", "link"            } }        ) end

-- Rarity row if frame.args.rarity then ret = ret .. ParamRow(color, "Rarity", frame:expandTemplate           { title = "Rarity", args = { frame.args.rarity } }        ) end

ret = ret .. CloseAll if frame.args.nowiki ~= nil then ret = ret:gsub("%<", "&lt;"):gsub("%[", "[") end return ret end

-- Module return { gear = Gear }