Module:Infobox/Item

local lang = mw.getLanguage('en') local util_infobox = require('Module:InfoboxUtil') local util_html = require('Module:HtmlUtil') local util_cargo = require('Module:CargoUtil') local util_dpl = require('Module:DPLUtil') local util_table = require('Module:TableUtil') local util_args = require('Module:ArgsUtil')

local GOLD_ICON = ''

local LAYOUT = { tabs = 'ItemTabsHeader', sections = { 'Consumable', 'Passive', 'Active', 'Statistics', 'Builds From', 'Builds Into' }, contents = { { 'consumable', consumable = 'wide' }, { 'passive1', 'passive2', 'passive3', 'passive4', passive1 = 'wide', passive2 = 'wide', passive3 = 'wide', passive4 = 'wide' }, { 'active', active = 'wide' }, { 'Limitations', 'MapAvailability', 'Tier', 'ItemCode', 'Health', 'HPRegen', 'Mana', 'ManaRegen', 'Energy', 'EnergyRegen', 'AD', 'Crit', 'AS', 'LifeSteal', 'ArmorPen', 'Range', 'SpellPower', 'CDR', 'SpellVamp', 'MPen', 'Armor', 'MR', 'Movespeed', 'Tenacity', 'GoldGen', 'OnHit', 'BonusHP', 'Healing' }, { 'buildsfrom', buildsfrom = 'wide' }, { 'buildsinto', buildsinto = 'wide' }, },	classes = { consumable = 'infobox-item-passive', passive1 = 'infobox-item-passive', passive2 = 'infobox-item-passive', passive3 = 'infobox-item-passive', passive4 = 'infobox-item-passive', active = 'infobox-item-passive', },	i18nFile = 'Infobox/Item' }

local h = {} local p = {} function p.main(args) local processed = h.getProcessed(args) local settings = { lc = processed.lc, nocargo = mw.title.getCurrentTitle.nsText ~= '' or args.nocargo, nocat = mw.title.getCurrentTitle.nsText ~= '' or args['no-cat'], }	local output = { display = h.processDisplay(args, processed), cargo = h.processCargo(args, processed), settings = settings, categories = h.processCategories(args, processed), layout = LAYOUT, }	return output end

function h.getProcessed(args) local tbl = { pagename = mw.title.getCurrentTitle.text, }	return tbl end

function h.processDisplay(args, processed) local recipe_tbl = { args['special recipe'] or args['recipe 1'] and util_table.concatFromArgs(args, 'recipe ', ' + ', h.printItem), args.gold and ('%s %s'):format(args.gold, GOLD_ICON) }	local tbl = { --names = util_infobox.statDisplays(LAYOUT.contents[4]), title = args.name, notice = args.removedin and ('Item was removed in Patch %s.'):format(args.removedin) or util_args.castAsBool(args.isremoved) and 'Item has been removed.', image = args.image or ('%s.png'):format(args.name), imagesize = args.imagesize or '64px', imagecaption = args.lore, passive1 = args.passive1, passive2 = args.passive2, passive3 = args.passive3, passive4 = args.passive4, consumable = args.consumable, active = args.active, AD = args.ad, LifeSteal = args.ls, Health = args.hp, HPRegen = args.hpregen, Armor = args.armor, MR = args.mr, AttackDamage = args.ad, Crit = args.crit, AS = args.as, LifeSteal = args.ls, ArPen = args.armorpen, Range = args.range, Mana = args.mana, ManaRegen = args.manaregen, Energy = args.energy, EnergyRegen = args.energyregen, SpellPower = args.sp, CDR = args.cdr, SpellVamp = args.spellvamp, MPen = args.magicpen, Movespeed = args.ms, Tenacity = args.tenacity, GoldGen = args.goldgen and ('+%s per 10 seconds'):format(args.goldgen), OnHit = args.onhit, BonusHP = args.bonushp, Healing = args.healing, Limitations = args.limit, Tier = args.tier, ItemCode = args['item code'], recipe = util_table.concat(recipe_tbl,' + '), TotalCost = args.totalgold and ("Total Cost: %s %s"):format(args.totalgold, GOLD_ICON), SoldFor = args.sold and ("Sold For: %s %s"):format(args.sold, GOLD_ICON), buildsinto = h.getBuildsInto(args.name), buildsfrom = util_args.splitMapConcat(args.recipe, nil, h.printItem), }	return tbl end

function h.getBuildsInto(item) local tbl = util_cargo.getOrderedList(h.getBuildsIntoQuery(item)) return next(tbl) and util_table.concat(tbl, '', h.printItem) end

function h.getBuildsIntoQuery(item) local tbl = { tables = 'Items', where = ('Recipe HOLDS "%s"'):format(item), fields = 'Name', orderBy = 'Name', groupBy = 'Name', }	return tbl end

function h.printItem(item) return (''):format(item, item) end

function h.processCargo(args, processed) local tbl = { {			_table = 'Items', Name = args.name, Tier = args.tier, Recipe = args.recipe, AD = args.ad, Armor = args.armor, }	}	return tbl end

function h.processCategories(args, processed) local tbl = { 'Items', args.tier and ('%s Items'):format(args.tier), args.isremoved and 'Removed Items', args.removedin and 'Removed Items', }	return tbl end

return p