Halo Esports Wiki

We are currently performing extensive maintenance to this wiki and as a result there will likely be errors. Please be patient while we work to fix all problems.

READ MORE

Halo Esports Wiki
Advertisement

To edit the documentation or categories for this module, click here.


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 h = {}
local p = {}

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

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

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]
	end
	if objType == 'rolelist' then
		return RoleList(row[args[1]], opts)
	end
	error(('Unrecognized Cargo complex value casting type of %s'):format(objType))
end

return p
Advertisement