Module:Player

local util_args = require('Module:ArgsUtil') local util_esports = require("Module:EsportsUtil") local util_text = require('Module:TextUtil') local Country = require('Module:Country')

local h = {}

function h.flag(flag) if flag then return Country(flag):image end return nil end

function h.getNameParts(name) if not name then return nil, nil end local parts = util_text.split(name, ' ') return table.remove(parts, 1), table.concat(parts, ' ') end

function h.id(args) if args.name then return ("\"%s\""):format(h.idLink(args)) end return h.idLink(args) end

function h.idLink(args) if args.link and not util_args.castAsBool(args.link) then return args[1] end return util_esports.playerLinked(args.link or args[1]) end

local p = {} function p.main(frame) local args = util_args.merge local tbl = {} local firstname, lastname = h.getNameParts(args.name) tbl[#tbl+1] = h.flag(args.flag) tbl[#tbl+1] = firstname tbl[#tbl+1] = h.id(args) tbl[#tbl+1] = lastname return table.concat(tbl, ' ') end return p