[checked revision] | [checked revision] |
m (→top: CompoundRole -> RoleList) |
([ST] + Team, TeamList) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
+ | 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 Role = require('Module:Role') |
||
local RoleList = require('Module:RoleList') |
local RoleList = require('Module:RoleList') |
||
− | local |
+ | local Team = require('Module:TeamClass') |
− | local |
+ | local TeamList = require('Module:TeamList') |
⚫ | |||
local h = {} |
local h = {} |
||
local p = {} |
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) |
function p.castField(v, v_type) |
||
− | if v_type |
+ | if p.objectTypes[v_type] then |
− | return |
+ | return p.objectTypes[v_type](v) |
− | elseif v_type == 'RoleList' then |
||
− | return RoleList(v) |
||
− | elseif v_type == 'champion' then |
||
− | return Champion(v) |
||
− | elseif v_type == 'compoundchampion' then |
||
− | return CompoundChampion(v) |
||
− | elseif v_type == 'region' then |
||
− | return Region(v) |
||
end |
end |
||
error('Unrecognized Cargo value casting type') |
error('Unrecognized Cargo value casting type') |
||
Line 29: | Line 41: | ||
opts[k] = row[v] |
opts[k] = row[v] |
||
end |
end |
||
− | if objType == ' |
+ | if objType == 'rolelist' then |
return RoleList(row[args[1]], opts) |
return RoleList(row[args[1]], opts) |
||
end |
end |
||
− | error('Unrecognized Cargo complex value casting type') |
+ | error(('Unrecognized Cargo complex value casting type of %s'):format(objType)) |
end |
end |
||
Latest revision as of 08:24, 31 August 2020
Edit the documentation or categories for this module.
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)
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