Module:Infobox/Champion

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_dpl = require('Module:DPLUtil') local util_html = require('Module:HtmlUtil') local util_infobox = require('Module:InfoboxUtil') local util_math = require('Module:MathUtil') local util_table = require('Module:TableUtil') local util_text = require('Module:TextUtil') local util_vars = require('Module:VarsUtil')

local lang = mw.getLanguage('en') local Champion = require('Module:ChampionClass')

local RP_ICON = '' local BE_ICON = ''

local LAYOUT = { tabs = 'ChampionTabsHeader', sections = { 'General Information', 'Statistics', 'Availability' }, contents = { { 'ChampTitle', 'RealName', 'ReleaseDate', 'Tier', 'Origin', 'Class', 'Ability' }, { 'Leveling', 'Health', 'Mana', 'AD', 'AS', 'DPS', 'Range', 'Armor', 'MR', 'PlayerDamage' }, { 'InTFT', 'IsActive' }, },	i18nFile = 'Infobox/Champion', }

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'], }	h.setVariables(args) return { display = h.processDisplay(args, processed), cargo = h.processCargo(args, processed), settings = settings, categories = h.processCategories(args, processed), layout = LAYOUT, } end

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

function h.processDisplay(args, processed) local tbl = { title = args.name, image = args.image or ('%sSquare.png'):format(args.name), imagesize = not (args.image and not args.imagesize) and (args.imagesize or '120px'), ChampTitle = args.title, ReleaseDate = args.releasedate, Cost = ('%s %s %s %s'):format(args.be or , BE_ICON, args.rp or , RP_ICON), Attribute = not args.attribute2 and args.attribute, PrimaryAttribute = args.attribute2 and args.attribute, SecondaryAttribute = args.attribute2, RealName = args.realname, Tier = args.tier, Origin = h.links(args.origin, 'Origin'), Class = h.links(args.class, 'Class'), Ability = args.ability, IsActive = args.active, InTFT = args.intft, Leveling = args.leveling, Health = h.makeLeveledStat(args.hp), Mana = args.mp, AD = h.makeLeveledStat(args.ad), AS = args.as, DPS = h.getDPS(args.ad, args.as), Range = args.range, Armor = args.armor, MR = args.mr, PlayerDamage = h.makeLeveledStat(args.playerdamage), }	return tbl end

function h.links(arg, linktype) local function fmt(str) return util_text.intLink(str .. (' (%s)'):format(linktype), str) end return util_args.splitMapConcat(arg, nil, fmt, ', ') end

function h.makeLeveledStat(str) if not str then return nil end return str:gsub('%s*,%s*', ' / ') end

function h.getDPS(ad, as) local function getOneDPS(adItem) return util_math.roundnum(adItem * as, .01) end return util_args.splitMapConcat(ad, nil, getOneDPS, ' / ') end

function h.stat(base, level) return base and ('%s (+ %s)'):format(base, level) end

function h.processCargo(args, processed) if not util_args.castAsBool(args.intft) then return {} end local tbl = { {			_table = 'Champions', Name = args.name, Markup = Champion(args.name):flairlinked, Title = args.title, ReleaseDate = args.releasedate, Tier = args.tier, Origin = args.origin, Class = args.class, Tier_Linked = util_text.intLink(('Tier %s Champions'):format(args.tier), args.tier), Origin_Linked = h.links(args.origin, 'Origin'), Class_Linked = h.links(args.class, 'Class'), Ability = args.ability, InTFT = util_args.castAsBool(args.intft), IsActive = util_args.castAsBool(args.active), Leveling = args.leveling, Health = h.makeLeveledStat(args.hp), Mana = args.mp, AD = h.makeLeveledStat(args.ad), AttackSpeed = args.as, DPS = h.getDPS(args.ad, args.as), AttackRange = args.range, Armor = args.armor, MR = args.mr, PlayerDamage = h.makeLeveledStat(args.playerdamage), },	}	return tbl end

function h.processCategories(args, processed) local tbl = { 'Champions', util_args.nilToFalse(args.energy) and 'Energy-Based Champions', util_args.castAsBool(args.active) and 'Active Champions' or 'Inactive Champions', }	return tbl end

function h.setVariables(args) util_vars.setObject('ChampionClass', util_text.split(args.class)) util_vars.setObject('ChampionOrigin', util_text.split(args.origin)) end

return p