Module:Sandbox/MonkeysHK

--Get Required Modules local loadLib = require('Module:LoadLib')

loadLib(_G, {	infobox = 'Infobox',	mRarity = 'RarityTier',	mLink = 'Link',	mOdds = 'Odds',	mInvSlot = 'Inventory slot',	{ 'Bazaar', values={ 		bazaarLastUpdatedIcon='lastUpdatedIcon', 		bazaarData='getProductData',		bazaarPurchaseCalc='calcMaterialBuyPrices',		_bazaarPurchaseCalc='_calcMaterialBuyPrices',		getBazaarPriceChange='_getPriceChange',		getBazaarPriceSpred='_getPriceSpread'	} },	templates='String/Templates',	list='List',	ability='Ability',	{ 'Currency', values={ 'currency' } }, })

mw.html.create = require('Module:Html').create local curTitle = mw.title.getCurrentTitle

--Begin Exports local p = {} local yesIcon, noIcon, unknownIcon = templates.yes(1), templates.no(1), templates.unknown(1)

local function yesnodefault(val, yes, no, def) if tostring(val):sub(1, 1) == "u" then return unknownIcon end local bool = yesno(val); if bool == nil then return def or val elseif bool then return yes else return no	end end

function p.infoboxArmor(frame) local args = getArgs(frame) local pagename = curTitle.text or "Miner Armor" local title = args.title or pagename local category_to_add = args.category_to_add or "" local sections = {} local idsExistForAllTabs = true for j = 1,16,1 do		local function argJ(name, default) return args[name..j] or default end local sectionExists = j==1 or argJ("tab") if sectionExists then -- section one does have numbers after params; on 2+ do that local i = j==1 and "" or j			local _i = j==1 and "" or "_"..j -- needed for when a param ends in a number naturally local function argI(name, default) return args[name..i] or args[name.._i] or default end local function sumStat(attr) local ret = 0 for _, piece in ipairs{'helmet_', 'chest_', 'legs_', 'boots_'} do					ret = ret + tonumber(argI(piece..attr)) or 0 end return ret end local function processStat(long, short) return argI(long) or argI(long) or argI(short) end if not (argI("chest_id") and argI("legs_id") and argI("boots_id")) then idsExistForAllTabs = false end -- table of all params for this section local s = {} -- Top level infobox values --0			s.tab = argJ("tab") or argI("tab") -- purposefully use "j" here since default section does actually use "tab1" --1			s.image = argI("image") or pagename..".png" --2			s.caption = argI("caption") or argI("imagecaption") --3			for _,v in ipairs{'helmet','chest','legs','boots'} do				s['slot_'..v] = argI('slot_'..v)				-- If a value is passed in, set to value; if no value is passed in set to page name; if the value passed in is a "no" type value, set to nil s['slot_'..v] = yesno(s['slot_'..v], true) and (s['slot_'..v] or pagename:gsub('%s*Armor$',' '..string.ucfirst(v))) or nil end -- Unless a "false" value is set, show ; if a value that isn't "false" is given, uses that instead. "true" values being passed in break this -- Since slot{} has newlines that messes up formatting here for some reason, remove the newlines s.slot_item = string.wrapHtml(				table.concat(table.map({'helmet','chest','legs','boots'}, function(v)					return s['slot_'..v] and ():format(s['slot_'..v]) or 				end)),				'center') --4			s.type = argI("type") or args["default_type"] or "Armor" --5			s.aka = argI("aka") --6			s.rarity = argI("rarity") and mRarity.link{ argI("rarity"), addcategory = true } --7			s.collection = argI("collection") and mLink.collectionLink{ argI("collection"), showIcon = true } --8			s.combat_level_requirement = argI("combat_level_requirement") --9			s.dungeon_level_requirement = argI("dungeon_level_requirement") --10			s.dungeon_floor_clearing_requirement = argI("dungeon_floor_clearing_requirement") --11			s.hotm_requirement = argI("hotm_requirement") --12			s.other_level_requirement = argI("other_level_requirement") --14			s.source = argI("source") --15			s.obtained = argI("obtained") or argI("obtain") or argI("obtaining") -- Stats group --D0 s.stats = argI("stats") --D1 s.ability_damage = processStat('ability_damage','abdmg') --D2 s.health = processStat('health','hp') --D3 s.defense = processStat('defense','def') --D5 s.strength = processStat('strength','str') --D6 s.crit_chance = processStat('crit_chance','critchance') --D7 s.crit_damage = processStat('crit_damage','critdmg') --D9 s.intelligence = processStat('intelligence','int') --D10 s.speed = processStat('speed','spd') --D11 s.true_defense = processStat('true_defense','trudef') --D12 s.magic_find = processStat('magic_find','mf') --D13 s.fishing_speed = processStat('fishing_speed','fishspd') --D14 s.sea_creature_chance = processStat('sea_creature_chance','scc') --D15 s.ferocity = processStat('ferocity','fer') --D16 s.mining_speed = processStat('mining_speed','mspeed') --D18 s.mining_fortune = processStat('mining_fortune','mfortune') --D19 s.farming_fortune = processStat('farming_fortune','fmfortune') --D20 s.foraging_fortune = processStat('foraging_fortune','frfortune') -- Head, Chest, Legs, Boots Groups table.each( {'helmet_','chest_','legs_','boots_'}, function(a)				table.each( { --R1 'abdmg', --R2 'hp', --R3 'def', --R5 'str', --R6 'critchance', --R7 'critdmg', --R9 'int', --R10'spd', --R11'trudef', --R12'mf', --R13'fishspd', --R14'scc', --R15'fer', --R16'mspeed', --R18'mfortune', --R19'fmfortune', --R20'frfortune', }, function (b) s[a..b] = argI(a..b)				end)			end) -- Special Effects --E0 s.effects = argI("effects") or argI("effect") or argI("special_effect") or argI("additional_effects") --E3 s.full_set_bonus = argI("full_set_bonus") --E5 s.full_set_bonus2 = argI("full_set_bonus2") -- Properties group --K0 s.upgradeable = yesnodefault(argI("upgradeable"), yesIcon, noIcon) --K1 s.enchantable = yesnodefault(argI("enchant") or argI("enchantable"), yesIcon, noIcon) --K2 s.reforgeable = yesnodefault((not isReforgeStone and argI("reforge")) or argI("reforgeable"), yesIcon, noIcon) --K3 s.salable = yesnodefault(argI("salable") or argI("sellable") or true, yesIcon, noIcon) --K4 s.tradeable = yesnodefault(argI("tradeable") or argI("trade") or true, yesIcon, noIcon) --K5 s.auctionable = yesnodefault(argI("auctionable") or true, yesIcon, noIcon) -- Color Group --L0 s.color = argI("color") and "" -- Shop --M0 s.merchant = argI("merchant") and list.npcList{ argI("merchant"), noErr=true } --M1 s.daily_limit = argI("daily_limit") --M2 s.buy = argI("buy") and currency{ argI("buy") } --M3 s.sell = argI("sell") and currency{ argI("sell") } -- Materials --O0 s.raw_materials = argI("raw_materials") and list.resourceList{ image=1, argI("raw_materials") } --O1 s.material_cost = argI("material_cost") and coins{ argI("material_cost") } --O2 s.bazaar_not_including = argI("bazaar_not_including") s.mat_cost_bazaar = argI("mat_cost_bazaar") and bazaarPurchaseCalc{ argI("mat_cost_bazaar") or argI("raw_materials"), not_including = argI("bazaar_not_including") }:gsub("\n", "") --O3 s.raw_materials_upgr = argI("raw_materials_upgr") and list.resourceList{ image=1, argI("raw_materials_upgr") } --O4 s.material_cost_upgr = argI("material_cost_upgr") and coins{ argI("material_cost_upgr") } --O5 s.bazaar_not_including_upgr = argI("bazaar_not_including_upgr") s.mat_cost_bazaar_upgr = argI("mat_cost_bazaar_upgr") and bazaarPurchaseCalc{ argI("mat_cost_bazaar_upgr") or argI("raw_materials_upgr"), not_including = argI("bazaar_not_including_upgr") }:gsub("\n", "") -- Item Metadata for _,v in ipairs{ --Q1 'head_id', --Q2 'chest_id', --Q3 'legging_id', --Q4 'boots_id' } do				s[v] = argI(v) if s[v] then -- Always show ID in all caps s[v] = string.wrapTag(s.id:upper, 'code') -- If array syntax, make a list s[v] = s[v]:gsub(" ", "") -- lazy trim for array; ids never naturally have spaces s[v] = table.concat(mw.text.split(s.id, ","), " ") end end --Q5 s.head_texture = argI("head_texture") or argI("head_tex") s.head_texture = s.head_texture and string.wrapTag(s.head_texture, 'code') for _,v in ipairs{ --Q7 'head_nbt', --Q8 'chest_nbt', --Q9 'legging_nbt', --Q10 'boots_nbt' } do				s[v] = argI(v) and argI(v):gsub("(   +)", " %1") -- Since newlines are being deleted, can't be used; and since exscape br tags, need to make own fake pre tag s[v] = s[v] and string.wrapHtml(s[v],'div',{					style = {						['background-color'] = 'rgba(0,0,0,0.35)',						border = '1px solid #9b8d8e',						overflow = 'auto',						['word-wrap'] = 'normal',						['white-space'] = 'pre',					}				}):gsub("} ", " } ") end -- Push section data into array sections[#sections+1] = s		end end -- Make infobox local ibox = infobox.create ibox:addTitle{ title } local panel = ibox:addPanel for i,sdata in ipairs(sections) do		local section = --0panel:addSection{ label = sdata.tab } section --1|2:addImage{ sdata.image, caption = { sdata.caption }, source="image"..i } --3 :addData{ sdata.slot_item } --4 :addData{ sdata.type, label = "Type" } --5 :addData{ sdata.aka, label = "Also known as" } --6 :addData{ sdata.rarity, label = "Rarity" } --7 :addData{ sdata.collection, label = string.makeLink("Collections", "Collection") } --8 :addData{ sdata.combat_level_requirement, label = "Combat Level Requirement" } --9 :addData{ sdata.dungeon_level_requirement, label = "Dungeon Level Requirement" } --10 :addData{ sdata.dungeon_floor_clearing_requirement, label = "Requires Dungeon Floor Cleared" } --11 :addData{ sdata.hotm_requirement, label = "Heart of the Mountain Level Requirement" } --12 :addData{ sdata.other_level_requirement, label = "Skill Level Requirement" } --14 :addData{ sdata.source, label = "Source" } --15 :addData{ sdata.obtained, label = "Obtained via" } :addGroup{ header = "Stats" } :addPanel{ collapse = "open" } :addSection{ label = "Total" } :addGroup{ name = "infobox-stats-list" } --D0 :addData{ sdata.stats } --D1 :addData{ sdata.ability_damage, label = makeStat("Ability Damage") } --D2 :addData{ sdata.health, label = makeStat("Health") } --D3 :addData{ sdata.defense, label = makeStat("Defense") } --D5 :addData{ sdata.strength, label = makeStat("Strength") } --D6 :addData{ sdata.crit_chance, label = makeStat("Crit Chance") } --D7 :addData{ sdata.crit_damage, label = makeStat("Crit Damage") } --D9 :addData{ sdata.intelligence, label = makeStat("Intelligence") } --D10:addData{ sdata.speed, label = makeStat("Speed") } --D11:addData{ sdata.true_defense, label = makeStat("true defense") } --D12:addData{ sdata.magic_find, label = makeStat("mf") } --D13:addData{ sdata.fishing_speed, label = makeStat("Fishing Speed") } --D14:addData{ sdata.sea_creature_chance, label = makeStat("scc", nil, true) } --D15:addData{ sdata.ferocity, label = makeStat("Ferocity") } --D16:addData{ sdata.mining_speed, label = makeStat("Mining Speed") } --D18:addData{ sdata.mining_fortune, label = makeStat("Mining Fortune", nil, true) } --D19:addData{ sdata.farming_fortune, label = makeStat("Farming Fortune", nil, true) } --D20:addData{ sdata.foraging_fortune, label = makeStat("Foraging Fortune", nil, true) } :done :done :addSection{ label = "Head" } :addGroup{ name = "infobox-stats-list" } --R1 -H:addData{ sdata.helmet_abdmg, label = makeStat("Ability Damage") } --R2 -H:addData{ sdata.helmet_hp, label = makeStat("Health") } --R3 -H:addData{ sdata.helmet_def, label = makeStat("Defense") } --R5 -H:addData{ sdata.helmet_str, label = makeStat("Strength") } --R6 -H:addData{ sdata.helmet_critchance, label = makeStat("Crit Chance") } --R7 -H:addData{ sdata.helmet_critdmg, label = makeStat("Crit Damage") } --R9 -H:addData{ sdata.helmet_int, label = makeStat("Intelligence") } --R10-H:addData{ sdata.helmet_spd, label = makeStat("Speed") } --R11-H:addData{ sdata.helmet_trudef, label = makeStat("true defense") } --R12-H:addData{ sdata.helmet_mf, label = makeStat("mf") } --R13-H:addData{ sdata.helmet_fishspd, label = makeStat("Fishing Speed") } --R14-H:addData{ sdata.helmet_scc, label = makeStat("scc", nil, true) } --R15-H:addData{ sdata.helmet_fer, label = makeStat("Ferocity") } --R16-H:addData{ sdata.helmet_mspeed, label = makeStat("Mining Speed") } --R18-H:addData{ sdata.helmet_mfortune, label = makeStat("Mining Fortune", nil, true) } --R19-H:addData{ sdata.helmet_fmfortune, label = makeStat("Farming Fortune", nil, true) } --R20-H:addData{ sdata.helmet_frfortune, label = makeStat("Foraging Fortune", nil, true) } :done :done :addSection{ label = "Chest" } :addGroup{ name = "infobox-stats-list" } --R1 -C:addData{ sdata.chest_abdmg, label = makeStat("Ability Damage") } --R2 -C:addData{ sdata.chest_hp, label = makeStat("Health") } --R3 -C:addData{ sdata.chest_def, label = makeStat("Defense") } --R5 -C:addData{ sdata.chest_str, label = makeStat("Strength") } --R6 -C:addData{ sdata.chest_critchance, label = makeStat("Crit Chance") } --R7 -C:addData{ sdata.chest_critdmg, label = makeStat("Crit Damage") } --R9 -C:addData{ sdata.chest_int, label = makeStat("Intelligence") } --R10-C:addData{ sdata.chest_spd, label = makeStat("Speed") } --R11-C:addData{ sdata.chest_trudef, label = makeStat("true defense") } --R12-C:addData{ sdata.chest_mf, label = makeStat("mf") } --R13-C:addData{ sdata.chest_fishspd, label = makeStat("Fishing Speed") } --R14-C:addData{ sdata.chest_scc, label = makeStat("scc", nil, true) } --R15-C:addData{ sdata.chest_fer, label = makeStat("Ferocity") } --R16-C:addData{ sdata.chest_mspeed, label = makeStat("Mining Speed") } --R18-C:addData{ sdata.chest_mfortune, label = makeStat("Mining Fortune", nil, true) } --R19-C:addData{ sdata.chest_fmfortune, label = makeStat("Farming Fortune", nil, true) } --R20-C:addData{ sdata.chest_frfortune, label = makeStat("Foraging Fortune", nil, true) } :done :done :addSection{ label = "Legs" } :addGroup{ name = "infobox-stats-list" } --R1 -L:addData{ sdata.legs_abdmg, label = makeStat("Ability Damage") } --R2 -L:addData{ sdata.legs_hp, label = makeStat("Health") } --R3 -L:addData{ sdata.legs_def, label = makeStat("Defense") } --R5 -L:addData{ sdata.legs_str, label = makeStat("Strength") } --R6 -L:addData{ sdata.legs_critchance, label = makeStat("Crit Chance") } --R7 -L:addData{ sdata.legs_critdmg, label = makeStat("Crit Damage") } --R9 -L:addData{ sdata.legs_int, label = makeStat("Intelligence") } --R10-L:addData{ sdata.legs_spd, label = makeStat("Speed") } --R11-L:addData{ sdata.legs_trudef, label = makeStat("true defense") } --R12-L:addData{ sdata.legs_mf, label = makeStat("mf") } --R13-L:addData{ sdata.legs_fishspd, label = makeStat("Fishing Speed") } --R14-L:addData{ sdata.legs_scc, label = makeStat("scc", nil, true) } --R15-L:addData{ sdata.legs_fer, label = makeStat("Ferocity") } --R16-L:addData{ sdata.legs_mspeed, label = makeStat("Mining Speed") } --R18-L:addData{ sdata.legs_mfortune, label = makeStat("Mining Fortune", nil, true) } --R19-L:addData{ sdata.legs_fmfortune, label = makeStat("Farming Fortune", nil, true) } --R20-L:addData{ sdata.legs_frfortune, label = makeStat("Foraging Fortune", nil, true) } :done :done :addSection{ label = "Boots" } :addGroup{ name = "infobox-stats-list" } --R1 -B:addData{ sdata.boots_abdmg, label = makeStat("Ability Damage") } --R2 -B:addData{ sdata.boots_hp, label = makeStat("Health") } --R3 -B:addData{ sdata.boots_def, label = makeStat("Defense") } --R5 -B:addData{ sdata.boots_str, label = makeStat("Strength") } --R6 -B:addData{ sdata.boots_critchance, label = makeStat("Crit Chance") } --R7 -B:addData{ sdata.boots_critdmg, label = makeStat("Crit Damage") } --R9 -B:addData{ sdata.boots_int, label = makeStat("Intelligence") } --R10-B:addData{ sdata.boots_spd, label = makeStat("Speed") } --R11-B:addData{ sdata.boots_trudef, label = makeStat("true defense") } --R12-B:addData{ sdata.boots_mf, label = makeStat("mf") } --R13-B:addData{ sdata.boots_fishspd, label = makeStat("Fishing Speed") } --R14-B:addData{ sdata.boots_scc, label = makeStat("scc", nil, true) } --R15-B:addData{ sdata.boots_fer, label = makeStat("Ferocity") } --R16-B:addData{ sdata.boots_mspeed, label = makeStat("Mining Speed") } --R18-B:addData{ sdata.boots_mfortune, label = makeStat("Mining Fortune", nil, true) } --R19-B:addData{ sdata.boots_fmfortune, label = makeStat("Farming Fortune", nil, true) } --R20-B:addData{ sdata.boots_frfortune, label = makeStat("Foraging Fortune", nil, true) } :done :done :done :done :addGroup{ header = "Special Effects" } --E0 :addData{ sdata.effects } --E3 :addData{ sdata.full_set_bonus, label = ability.fullSetBonus } --E5 :addData{ sdata.full_set_bonus2, label = ability.fullSetBonus } :done :addGroup{ header = "Properties", layout = "horizontal", ['row-items']=2 } --K0 :addData{ sdata.upgradeable, label = "Upgradeable" } --K1 :addData{ sdata.enchantable, label = "Enchantable" } --K2 :addData{ sdata.reforgeable, label = "Reforgeable" } --K3 :addData{ sdata.salable, label = "Salable" } --K4 :addData{ sdata.tradeable, label = "Tradeable" } --K5 :addData{ sdata.auctionable, label = "Auctionable" } :done :addGroup --L0 :addData{ sdata.color, label = "Color" } :done :addGroup{ header = "Shop", layout = "horizontal", ['row-items']=2 } :addGroup{ ['row-items']=1 } --M0 :addData{ sdata.merchant, label = "Merchant"..(sdata.merchant and sdata.merchant:find("%s*%*%s*") and "s" or "") } :done --M1 :addData{ sdata.daily_limit, label = string.makeTitle("Daily Limit", "A limit on how much items of this type a player can buy in one day.") } --M2 :addData{ sdata.buy, label = "Buy" } --M3 :addData{ sdata.sell, label = "Sell" } :done section:addGroup{ header = "Materials" } --O0 :addData{ sdata.raw_materials, label=string.makeTitle("Raw Materials", "All materials in their most basic form needed to obtain the item.") } --O1 :addData{ sdata.material_cost, label=string.makeTitle("Material cost", "Cost to buy all necessary materials from merchants.") } --O2 :addData{ sdata.mat_cost_bazaar, label=string.makeTitle("Bazaar Material cost", "Cost to buy all necessary materials from the Bazaar.") } --O3 :addData{ sdata.raw_materials_upgr, label=string.makeTitle("Raw Materials to upgrade", "All materials in their most basic form needed to obtain the item.") } --O4 :addData{ sdata.material_cost_upgr, label=string.makeTitle("Material cost to upgrade", "Cost to buy all necessary materials from merchants.") } --O5 :addData{ sdata.mat_cost_bazaar_upgr, label=string.makeTitle("Bazaar Material cost to upgrade", "Cost to buy all necessary materials from the Bazaar.") } :done :addGroup{ header = "Trade", layout = "horizontal" } --P0 :addData{ sdata.trade_requirement, label = "Requires" } --P1 :addData{ sdata.trade_from, label = "From" } --P2 :addData{ sdata.trade_to, label = "To" } :done :addGroup{ header = "Item Metadata", ['row-items']=1, collapse="closed" } --Q1 :addData{ sdata.head_id, label = "Helmet Item ID" } --Q2 :addData{ sdata.chest_id, label = "Chestplate Item ID" } --Q3 :addData{ sdata.legging_id, label = "Leggings Item ID" } --Q4 :addData{ sdata.boots_id, label = "Boots Item ID" } --Q5 :addData{ sdata.head_texture, label = "Head Texture" } --Q7 :addData{ sdata.head_nbt, label = "Helmet NBT Data" } --Q8 :addData{ sdata.chest_nbt, label = "Chestplate NBT Data" } --Q9 :addData{ sdata.legging_nbt, label = "Leggings NBT Data" } --Q10 :addData{ sdata.boots_nbt, label = "Boots NBT Data" } :done end return table.concat{ ibox:preprocess, curTitle.namespace == 0 and ((category_to_add or "") .. ' ') or '', curTitle.namespace == 0 and not idsExistForAllTabs and "" or "", } end

--Finish Module/Exports return p