Module:Sandbox/TheTrueShaman

local p = {} local getArgs = require('Module:Arguments').getArgs local loader = require('Module:Loader')

local string, table, yesno = loader.require('String', 'Table', 'Yesno')

local armorData = loader.require('Module:Armor/Data') local reforges = loader.require('Module:Reforge/Data') local getArgs = require('Module:Arguments').getArgs

function p.getArmorData(frame) local args = getArgs(frame) local armor = (args[1] or args['armor']):lower local growth = args['growth'] or 5 local protection = args['protection'] or 5 local hpb = args[2] or args['hpb'] local fpb = args[3] or args['fpb'] local reforge = args[4] or args['reforge'] or nil return p._getArmorData(armor, growth, protection, hpb + fpb, reforge) end

function p._getArmorData(armorname, growth, protection, hpb, reforge) local armor = armorData[armorname] -- D for Data because these abbreviations come from the Armor/Data module local statsD = {'hp', 'def', 'cc', 'cd', 'str', 'int', 'spd', 'scc', 'td'} local piecesD = {'head', 'chest', 'legs', 'boots', 'total'} -- R for reforge because these abbreviations come from the Reforge/Data module local statsR = {'bas', 'cc', 'cd', 'def', 'fer', 'hp', 'int', 'mf', 'mnf', 'mns', 'scc', 'spd', 'str'} local armorstats = {helmet = {}, chestplate = {}, leggings = {}, boots = {}, total = {}} for i = 1,4,1 do 		local piece = piecesD[i] local piecestats = {hp={}, def={}, cc={}, cd={}, str={}, int={}, spd={}, scc={}, td={}} for a = 1,9,1 do			if armor['stats'][piece][statsD[a]] then piecestats[statsD[a]]['base'] = armor['stats'][piece][statsD[a]] end end if growth ~= 0 then piecestats['hp']['enchants'] = 15*growth end if protection ~= 0 then piecestats['def']['enchants'] = 3*protection end if hpb ~= 0 then piecestats['hp']['hpb'] = 4*hpb piecestats['def']['hpb'] = 2*hpb end if reforge and reforges['Armor'][reforge] then for a = 1,#statsR,1 do 				if reforges['Armor'][reforge]['stats'][armor['rarity']][statsR[a]] then piecestats[statsR[a]]['reforge'] = reforges['Armor'][reforge]['stats'][armor['rarity']][statsR[a]] end end end if armor['kind'] then if armor['kind'] == 'varied' then piecestats['kind'] = armor['piece']['kind'] else piecestats['kind'] = armor['kind'] end end armorstats[i] = piecestats end local armornames = {'helmet', 'chestplate', 'leggings', 'boots', 'total'} -- O for Ordered, because this is the order in which the stats show up in-game (too many stats variables I know) local statsO = {'str', 'cc', 'cd', 'bas', 'hp', 'def', 'spd', 'int', 'fer', 'mf', 'td', 'mns', 'mnf', 'scc'} local thingy = {'base', 'enchants', 'hpb', 'reforge'} local helmetData = armorstats[1] local chestData = armorstats[2] local legsData = armorstats[3] local bootsData = armorstats[4] local totalData local namethuhcgbv for i = 1,#statsO,1 do		if helmetData[statsO[i]] then if not x[statsO[i]] then x[statsO[i]] = {} end for a = 1,#thingy,1 do				if helmetData[statsO[i]][thingy[a]] then x[statsO[i]][thingy[a]] = helmetData[statsO[i]][thingy[a]] end end end end local function getDefaultImage(pType, pIsLink) local link = table.concat{"File:", title:gsub("Armor", pType), ".png"} if pIsLink then link = table.concat{"40px|center"} end return link end local function makeImageCell(pRow, pData, pType) local td = pRow:tag("td"):attr("id", pType) if pData["exists"] or defaultImages then if pData["img"] then td:addClass("as2x2-icon"):wikitext(table.concat{""}) elseif pData["color"] then td:addClass("as2x2-icon"):wikitext(table.concat{""}) elseif defaultImages then td:wikitext(getDefaultImage(pType, true)) else td:wikitext(" ") end else td:attr("colspan", 2):css{ ["border-right-width"]="2px" }:wikitext("") end return td	end local function makeCellCollapsible(pCell, pCollapsed) pCell :addClass("mw-collapsible") :attr("id", "mw-customcollapsible-pcb-toggle-button") if pCollapsed then pCell:addClass("mw-collapsed") end end local function makeDataCell(pRow, pData) if pData["exists"] then local td = row:tag("td"):wikitext(pData["statslist"]) :css({ ["border-right-width"]="2px" }) if showPcb or showPcbR1 then -- make cell collapsible makeCellCollapsible(td) -- add a second collapsed cell to allow user to toggle between both cells local td2 = row:tag("td"):css({ ["border-right-width"]="2px" }) makeCellCollapsible(td2, true) if pData["pcb"] or pData["pcb_desc"] then if pData["pcb"] then td2:tag("div"):wikitext(pieceBonus{ pData["pcb"] }) end td2:wikitext(pData["pcb_desc"]) else td2:wikitext("") end end end end local t = {} t[#t+1] = " Armor Stats \n" t[#t+1] = " Note: You Can Click on the Orange Button below to Show/Hide the Piece Bonuses \n" local wikitable = mw.html.create("table"):addClass("wikitable armorstats2x2"):css{ ["border-width"]="2px", ["border-color"]="#aaa" }; wikitable:tag("tr"):tag("th"):attr("colspan", 4) :tag("div") :addClass("mw-customtoggle-pcb-toggle-button wikia-menu-button hidden"):css{ padding="3px" } :wikitext(pcbToggleButtonName or "Click Here to Show Piece Bonuses") wikitable:tag("tr") :tag("th"):attr("colspan", 2):css{ ["border-right-width"]="2px" } :wikitext(helmetData["special_name"] or "Helmet"):done :tag("th"):attr("colspan", 2) :wikitext(chestData["special_name"] or "Chestplate"):done row = wikitable:tag("tr") makeImageCell(row, helmetData, "Helmet") makeDataCell(row, helmetData) makeImageCell(row, chestData, "Chestplate") makeDataCell(row, chestData) wikitable:tag("tr") :tag("th"):attr("colspan", 2):css{ ["border-right-width"]="2px", ["border-top-width"]="2px" } :wikitext(legsData["special_name"] or "Leggings"):done :tag("th"):attr("colspan", 2):css{ ["border-top-width"]="2px" } :wikitext(bootsData["special_name"] or "Boots"):done -- Legs / Boots image and data row row = wikitable:tag("tr") makeImageCell(row, legsData, "Leggings") makeDataCell(row, legsData) makeImageCell(row, bootsData, "Boots") makeDataCell(row, bootsData) row = wikitable:tag("tr") td = row:tag("th"):attr("colspan", 4):wikitext("Total"):css{ ["border-right-width"]="2px", ["border-top-width"]="2px" } makeCellCollapsible(td) row = wikitable:tag("tr") td = row:tag("td"):attr("colspan", 4):wikitext(totalData["statslist"]):css{ ["border-right-width"]="2px" } makeCellCollapsible(td) t[#t+1] = tostring(wikitable) if additionalEffects then t[#t+1] = additionalEffects.."

"	end	return table.concat(t); end

return p