[checked revision] | [checked revision] |
([ST] look up in table instead of writing out as if/elseif because this list is gonna get way longer) |
([ST] + Team, TeamList) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
⚫ | |||
local Champion = require('Module:Champion') |
local Champion = require('Module:Champion') |
||
local ChampionList = require('Module:ChampionList') |
local ChampionList = require('Module:ChampionList') |
||
− | local |
+ | 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 Team = require('Module:TeamClass') |
||
+ | local TeamList = require('Module:TeamList') |
||
local h = {} |
local h = {} |
||
local p = {} |
local p = {} |
||
p.objectTypes = { |
p.objectTypes = { |
||
⚫ | |||
⚫ | |||
champion = Champion, |
champion = Champion, |
||
championlist = ChampionList, |
championlist = ChampionList, |
||
+ | country = Country, |
||
+ | countrylist = CountryList, |
||
+ | league = League, |
||
+ | leaguelist = LeagueList, |
||
region = Region, |
region = Region, |
||
⚫ | |||
⚫ | |||
+ | team = Team, |
||
+ | teamlist = TeamList, |
||
} |
} |
||
function p.castField(v, v_type) |
function p.castField(v, v_type) |
||
− | if objectTypes[v_type] then |
+ | if p.objectTypes[v_type] then |
− | return objectTypes[v_type](v) |
+ | return p.objectTypes[v_type](v) |
end |
end |
||
error('Unrecognized Cargo value casting type') |
error('Unrecognized Cargo value casting type') |
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