Module:Infobox/Agent

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_html = require('Module:HtmlUtil') local util_infobox = require('Module:InfoboxUtil') local util_news = require("Module:NewsUtil") local util_table = require('Module:TableUtil') local util_text = require("Module:TextUtil") local util_title = require("Module:TitleUtil") local util_vars = require("Module:VarsUtil")

local lang = mw.getLanguage('en') local i18n = require('Module:i18nUtil') local Country = require('Module:Country')

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

Infobox.type = 'Agent'

Infobox.LAYOUT = { tabs = 'AgentTabsHeader', sections = { 'General Information', 'Developer' }, contents = { { 'AgentTitle', 'RealName', 'Class', 'Origin', 'Quote', 'ReleaseDate', 'Description' }, { 'KeyDdragon', 'KeyInt' }, }, }

local h = {} local p = {}

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

function Infobox:validateArgs(args) end

function Infobox:castArgs(args) args.origin = Country(args.origin) end

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

function Infobox:getDisplay(args, processed) local display = self:super('getDisplay', args, processed) local tbl = { title = args.name, image = args.image or ('Agent %s Half.png'):format(args.name), imagesize = not (args.image and not args.imagesize) and (args.imagesize or '300px'), AgentTitle = args.title, Class = args.class, Origin = args.origin and args.origin:flair, Quote = args.quote, ReleaseDate = args.releasedate, RealName = args.realname, Description = args.desc,

KeyDdragon = args.key_ddragon, KeyInt = args.key_int, }	return Infobox.mergeDisplay(display, tbl) end

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

function Infobox:getCargo(args, processed) local cargo = self:super('getCargo', args, processed) if util_args.castAsBool(args.nocargo) then return cargo end local tbl = { {			_table = 'Agents', Name = args.name, Title = args.title, Class = args.class, Origin = args.origin and args.origin:flair, Quote = args.quote, ReleaseDate = args.releasedate, RealName = args.realname, KeyDdragon = args.key_ddragon, KeyInteger = args.key_int, },	}	tbl[#tbl+1] = h.getNewsLine(args, processed) return util_table.mergeArrays(cargo, tbl) end

function h.getNewsLine(args, processed) if util_args.castAsBool(args.notreleased) then return end util_news.setId args.date = lang:formatDate('Y-m-d', args.releasedate) args.Sentence = i18n.default(		'NewsSentence',		util_text.intLinkOrText(args.name)	) local tbl = { Subject = 'Riot', SubjectLink = 'Portal:Agents', SubjectType = 'Tournament', Region = 'International', }	util_table.mergeDontOverwrite(tbl, util_news.getNewsCargoFieldsFromArgs(args)) return tbl end

function Infobox:getCategories(args, processed) local categories = self:super('getCategories', args, processed) local tbl = { 'Agents' }	return util_table.mergeArrays(categories, tbl) end

function Infobox:getVariables(args, processed) local variables = self:super('getVariables', args, processed) local tbl = { }	return util_table.merge(variables, tbl) end

return p