Difference between revisions of "Module:Data/static/medium"
(Medium data manager.) |
(Remove direct dependency on the region data.) |
||
Line 1: | Line 1: | ||
-- <pre> | -- <pre> | ||
− | |||
local thisData = mw.loadData( 'Module:Data/static/medium/data' ) | local thisData = mw.loadData( 'Module:Data/static/medium/data' ) | ||
− | local | + | local DATA = require( 'Module:Data/sandbox' ) |
local function normalize( v ) | local function normalize( v ) | ||
Line 10: | Line 9: | ||
:lower() | :lower() | ||
:gsub( "[%s%-_'!]", '' ) | :gsub( "[%s%-_'!]", '' ) | ||
− | |||
:gsub( 'yugioh', '' ) | :gsub( 'yugioh', '' ) | ||
:gsub( 'cardgame', '' ) | :gsub( 'cardgame', '' ) | ||
Line 17: | Line 15: | ||
return function( v ) | return function( v ) | ||
− | |||
− | |||
return thisData.main[ | return thisData.main[ | ||
thisData.normalize[ | thisData.normalize[ | ||
− | + | ( DATA.getRegion( v ) or {} ).index | |
− | + | or normalize( v ) | |
− | |||
] | ] | ||
] | ] | ||
end | end | ||
-- </pre> | -- </pre> |
Revision as of 13:41, 27 December 2019
-- <pre>
local thisData = mw.loadData( 'Module:Data/static/medium/data' )
local DATA = require( 'Module:Data/sandbox' )
local function normalize( v )
return type( v ) == 'string'
and mw.text.trim( v )
:lower()
:gsub( "[%s%-_'!]", '' )
:gsub( 'yugioh', '' )
:gsub( 'cardgame', '' )
or nil
end
return function( v )
return thisData.main[
thisData.normalize[
( DATA.getRegion( v ) or {} ).index
or normalize( v )
]
]
end
-- </pre>