We're currently performing an overhaul of our entire tournament results system so results will be missing from team and player pages for a while, and there may be some errors on tournament pages. Please bear with us as we complete this update.


From Call of Duty Esports Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:CargoUtil/Wiki/doc

local Champion = require('Module:Champion')
local ChampionList = require('Module:ChampionList')
local Country = require('Module:Country')
local CountryList = require('Module:CountryList')
local League = require('Module:League')
local LeagueList = require('Module:LeagueList')
local Region = require('Module:Region')
local Role = require('Module:Role')
local RoleList = require('Module:RoleList')
local Team = require('Module:TeamClass')
local TeamList = require('Module:TeamList')
local h = {}
local p = {}

p.objectTypes = {
	champion = Champion,
	championlist = ChampionList,
	country = Country,
	countrylist = CountryList,
	league = League,
	leaguelist = LeagueList,
	region = Region,
	role = Role,
	rolelist = RoleList,
	team = Team,
	teamlist = TeamList,

function p.castField(v, v_type)
	if p.objectTypes[v_type] then
		return p.objectTypes[v_type](v)
	error('Unrecognized Cargo value casting type')

function p.castComplexTypes(row, info)
	local objType = info.type
	local args = info.args
	local opts = {}
	for k, v in pairs(args) do
		opts[k] = row[v]
	if objType == 'rolelist' then
		return RoleList(row[args[1]], opts)
	error(('Unrecognized Cargo complex value casting type of %s'):format(objType))

return p