Leaguepedia | League of Legends Esports Wiki
Register
Advertisement

Edit the documentation or categories for this module.


local Role = require('Module:Role')
local CompoundRole = require('Module:CompoundRole')
local Champion = require('Module:ChampionClass')
local CompoundChampion = require('Module:CompoundChampion')
local h = {}
local p = {}

function p.castField(v, v_type)
	if v_type == 'role' then
		return Role(v)
	elseif v_type == 'compoundrole' then
		return CompoundRole(v)
	elseif v_type == 'champion' then
		return ChampionClass(v)
	elseif v_type == 'compoundchampion' then
		return CompoundChampion(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 == 'CompoundRole' then
		return CompoundRole(row[args[1]], opts)
	end
	error('Unrecognized Cargo complex value casting type')
end

return p
Advertisement