Edit the documentation or categories for this module.
local util_args = require('Module:ArgsUtil')
local util_html = require("Module:HtmlUtil")
local util_map = require('Module:MapUtil')
local util_table = require("Module:TableUtil")
local util_text = require("Module:TextUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')
local CompoundEntityAbstract = require('Module:CompoundEntityAbstract')
local p = CompoundEntityAbstract:extends()
local h = {}
p.Entity = require('Module:Role2')
function p:init(str, sep, opts)
sep = sep or ';'
self:super('init', str, sep, opts)
if self.is_nil then return end
self.ingame = self:filterIngameRoles(true)
self.staff = self:filterIngameRoles(false)
self.hasIngame = #self.ingame > 0
self.hasStaff = #self.staff > 0
self.ingameOnly = not self.hasStaff
self.staffOnly = not self.hasStaff
end
function p:filterIngameRoles(isIngame)
if self.is_nil then return end
local filteredRoles = {}
for _, role in ipairs(self) do
if isIngame == role:isIngame() then
filteredRoles[#filteredRoles+1] = role
end
end
return filteredRoles
end
function p:ingameImages(opts)
if self.is_nil then return end
if not opts then opts = {} end
local tbl = {}
for _, obj in ipairs(self.ingame) do
tbl[#tbl+1] = obj:image(opts)
end
return util_table.concat(tbl, opts.sep or '')
end
function p:ingameNames(length, opts)
if self.is_nil then return end
if not opts then opts = {} end
local tbl = {}
for _, obj in ipairs(self.ingame) do
tbl[#tbl+1] = obj:name(length, opts)
end
return util_table.concat(tbl, opts.sep)
end
function p:staffNames(length, opts)
if self.is_nil then return end
if not opts then opts = {} end
local tbl = {}
for _, obj in ipairs(self.staff) do
tbl[#tbl+1] = obj:name(length, opts)
end
return util_table.concat(tbl, opts.sep)
end
function p:serialize()
local tbl = {}
for _, obj in ipairs(self) do
tbl[#tbl+1] = obj:serialize()
end
-- same separator as we use in p:init
return util_table.concat(tbl, ';')
end
function p:sortnumber()
if self.is_nil then return end
return self.objs[1]:sortnumber()
end
return p