Module:Champion

local util_args = require('Module:ArgsUtil') local LOOKUP = mw.loadData('Module:Championnames')

local h = {}

function h.getInfo(str, settings) if str == '' then str = nil end settings.vars = util_args.lookupVars(str, LOOKUP, true) if not settings.vars then settings.vars = { link = str, display = str } end settings.linked = not settings.vars.exception settings.link = settings.link or settings.vars.link settings.display = settings.display or settings.vars.display return end

function h.linkedDisplay(linked, link, display) if not linked then return display else return ('%s'):format(link, display) end end

local p = {} function p.main(frame) -- this should NEVER be called from Lua, only invoked from MW	local args = util_args.merge(true) if not args[1] and not args.sub then return '' end local style = args[2] or 'rightlonglinked' args.size = args.size and args.size:gsub('px','') return p[style](args[1], args) end

function p.onlyimage(str, settings) if not settings then settings = {} end h.getInfo(str, settings) return (''):format(		settings.link,		settings.size or '20'	) end

function p.onlyimagelinked(str, settings) if not settings then settings = {} end h.getInfo(str, settings) return ():format(		settings.link,		settings.size or '20',		settings.linked and settings.link or 	) end

function p.championname(str, settings) if not settings then settings = {} end h.getInfo(str, settings) return settings.link end

function p.namelinked(str, settings) if not settings then settings = {} end h.getInfo(str, settings) if not settings.linked then return settings.display else return ('%s'):format(settings.link, settings.display) end end

function p.leftlong(str, settings) if not settings then settings = {} end h.getInfo(str, settings) return ('%s '):format(		settings.vars.display,		settings.vars.link,		settings.size or '20'	) end

function p.leftlonglinked(str, settings) if not settings then settings = {} end h.getInfo(str, settings) return ('%s '):format(		h.linkedDisplay(settings.linked, settings.link, settings.display),		settings.link,		settings.size or '20',		settings.linked and settings.link or ''	) end

function p.rightlong(str, settings) if not settings then settings = {} end h.getInfo(str, settings) return (' %s'):format(		settings.link,		settings.size or '20',		settings.display	) end

function p.rightlonglinked(str, settings) if not settings then settings = {} end h.getInfo(str, settings) local link return (' %s'):format(		settings.vars.link,		settings.size or '20',		settings.linked and settings.vars.link or '',		h.linkedDisplay(settings.linked, settings.link, settings.display)	) end

return p