Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

To edit the documentation or categories for this module, click here. This module has an i18n file. Click here to edit it.


local lang = mw.getLanguage('en')
local teamhist = require('Module:Infobox/TeamHist')
local util_infobox = require('Module:InfoboxUtil')
local util_html = require('Module:HtmlUtil')
local util_cargo = require('Module:CargoUtil')
local util_table = require('Module:TableUtil')
local util_args = require('Module:ArgsUtil')
local Item = require('Module:Item')

local MAPS = {
	ALL = '<abbr title="All Maps">ALL</abbr>',
	SR = '<abbr title="Summoner\'s Rift">SR</abbr>',
	TT = '<abbr title="Twisted Treeline">TR</abbr>',
	CS = '<abbr title="Crystal Scar">CS</abbr>',
	HA = '<abbr title="Howling Abyss">HA</abbr>',
	BMB = '<abbr title="Black Market Brawlers">BMB</abbr>',
	NB = '<abbr title="Nexus Blitz">NB</abbr>',
}

local GOLD_ICON = '[[File:Goldcurrency.png|20px|link=]]'

local Infobox = require('Module:Infobox'):extends()

local h = {}

local p = {}

function p.main(frame)
	local args = util_args.merge()
	return Infobox(args):run()
end

Infobox.LAYOUT = {
	tabs = 'ItemTabsHeader',
	sections = { 'Consumable', 'Passive', 'Active', 'Statistics', 'Additional Information', 'Recipe', 'Builds Into' },
	contents = {
		{ 'consumable', consumable = 'wide' },
		{ 'passive1', 'passive2', 'passive3', 'passive4', passive1 = 'wide', passive2 = 'wide', passive3 = 'wide', passive4 = 'wide' },
		{ 'active', active = 'wide' },
		{ 'Health', 'HPRegen', 'Mana', 'ManaRegen', 'Energy', 'EnergyRegen', 'AD', 'Crit', 'ASDisplay', 'LifeSteal', 'ArmorPen', 'Range', 'AP', 'AbilityHaste', 'CDRDisplay', 'Omnivamp', 'PhysVamp', 'SpellVamp', 'MPen', 'Armor', 'MR',  'MovespeedPercent', 'MovespeedFlat', 'Tenacity', 'GoldGen', 'OnHit', 'BonusHP', 'Healing', 'HSPower', 'SlowResist', },
		{ 'Limitations', 'MapAvailability', 'Tier', 'ItemCode' },
		{ 'recipe', 'TotalCost', 'SoldFor', recipe = 'wide', TotalCost = 'wide', SoldFor = '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',
	},
}

Infobox.type = 'Item'

function Infobox:castArgs(args)
	for _, arg in ipairs({ 'cdr', 'as', 'ms', 'crit', 'ov', 'pv', 'spellvamp' }) do
		if args[arg] then
			args[arg] = args[arg]:gsub('%%', '')
		end
	end
end

function Infobox:getDisplay(args, processed)
	local display = self:super('getDisplay', 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(self.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 ('ItemSquare%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,
		Health = args.hp,
		HPRegen = args.hpregen,
		Armor = args.armor,
		MR = args.mr,
		AttackDamage = args.ad,
		Crit = args.crit and args.crit .. '%',
		ASDisplay = args.as and args.as .. '%',
		LifeSteal = args.ls and args.ls .. '%',
		ArmorPen = args.armorpen,
		Range = args.range,
		Mana = args.mana,
		ManaRegen = args.manaregen,
		Energy = args.energy,
		EnergyRegen = args.energyregen,
		AP = args.ap,
		CDRDisplay = args.cdr and args.cdr .. '%',
		AbilityHaste = args.ah ,
		Omnivamp = args.ov and args.ov .. '%',
		PhysVamp = args.pv and args.pv .. '%',
		SpellVamp = args.spellvamp and args.spellvamp .. '%',
		MPen = args.magicpen,
		MovespeedPercent = args.ms_percent and args.ms_percent .. '%',
		MovespeedFlat = args.ms_flat,
		Tenacity = args.tenacity and args.tenacity .. '%',
		GoldGen = args.goldgen and ('+%s per 10 seconds'):format(args.goldgen),
		OnHit = args.onhit,
		BonusHP = args.bonushp,
		Healing = args.healing,
		HSPower = args.hsp and args.hsp .. '%',
		SlowResist = args.sr and args.sr .. '%',
		
		Limitations = args.limit,
		MapAvailability = args.map1 and util_table.concatFromArgs(args, 'map', ', ', h.printMap),
		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 = args['used in 1'] and util_table.concatFromArgs(args, 'used in ', ' ', h.printItem),
	}
	return Infobox.mergeDisplay(display, tbl)
end

function h.printMap(map)
	return MAPS[map]
end

function h.printItem(item)
	return Item(item):filelink{size = 32}
end

function Infobox:getCargo(args, processed)
	local cargo = self:super('getCargo', args, processed)
	local tbl = {
		{
			_table = 'Items',
			Name = args.name,
			AD = args.ad,
			LifeSteal = args.ls,
			Health = args.hp,
			HPRegen = args.hpregen,
			Armormor = 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,
			AP = args.ap,
			CDR = args.cdr,
			AbilityHaste = args.ah,
			Omnivamp = args.ov,
			PhysVamp = args.pv,
			SpellVamp = args.spellvamp,
			MPen = args.magicpen,
			MovespeedFlat = args.ms_flat,
			MovespeedPercent = args.ms_percent,
			Tenacity = args.tenacity,
			GoldGen = args.goldgen,
			OnHit = args.onhit,
			BonusHP = args.bonushp,
			Healing = args.healing,
			HSPower = args.hsp,
			SlowResist = args.sr
		}
	}
	return util_table.mergeArrays(cargo, tbl)
end

function Infobox:getCategories(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
Advertisement