Editing Module:Card gallery/File/CG
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page is not enabled for semantic in-text annotations due to namespace restrictions. Details about how to enable the namespace can be found on the configuration help page.
Latest revision | Your text | ||
Line 14: | Line 14: | ||
local DATA = require( 'Module:Data' ); | local DATA = require( 'Module:Data' ); | ||
local UTIL = require( 'Module:Util' ); | local UTIL = require( 'Module:Util' ); | ||
− | |||
− | |||
− | |||
------------- | ------------- | ||
-- Constants: | -- Constants: | ||
------------- | ------------- | ||
− | local | + | local CARD_BACK_TCG = 'Back-EN.png'; |
− | + | local CARD_BACK_JP = 'Back-JP.png'; | |
− | + | local CARD_BACK_AE = 'Back-AE.png'; | |
− | local CARD_BACK_JP | + | local CARD_BACK_KR = 'Back-KR.png'; |
− | local CARD_BACK_AE | + | local OFFICIAL_PROXY = DATA.getRelease( 'OP' ); |
− | local CARD_BACK_KR | ||
− | |||
− | local OFFICIAL_PROXY | ||
--------------- | --------------- | ||
Line 48: | Line 42: | ||
-- @description Boolean indicating if the file doesn't have an edition. | -- @description Boolean indicating if the file doesn't have an edition. | ||
local function hasNoEdition( t ) | local function hasNoEdition( t ) | ||
− | local rg = | + | local rg = t.parent:getRegion().index; |
− | + | return rg == 'JP' or rg == 'JA' or rg == 'TC'; | |
− | return rg == 'JP' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 82: | Line 68: | ||
end | end | ||
− | if cardNumber and cardNumber:match( '^ | + | if cardNumber and cardNumber:match( '^%w-%-%w-$' ) then |
-- Input like «TLM-EN012». | -- Input like «TLM-EN012». | ||
t.number = cardNumber:upper(); | t.number = cardNumber:upper(); | ||
− | t.setAbbr = t.number:match( '^( | + | t.setAbbr = t.number:match( '^(%w-)%-%w-$' ); |
else | else | ||
-- Input like «S1». | -- Input like «S1». | ||
Line 103: | Line 89: | ||
t.set = set; | t.set = set; | ||
− | t.setEn = | + | t.setEn = UTIL.getName( set ) or set; --TODO: either UTIL.trim or... check later |
− | t.setLn = | + | t.setLn = UTIL.getName( set, t.parent:getLanguage().index ); |
end | end | ||
Line 126: | Line 112: | ||
table.insert( releases, releaseAsKey ); | table.insert( releases, releaseAsKey ); | ||
end | end | ||
− | table.sort( releases ); | + | table.sort( releases ); |
t.releases = {}; | t.releases = {}; | ||
Line 143: | Line 129: | ||
-- @description Sets the `rarity` attribute. | -- @description Sets the `rarity` attribute. | ||
local function initRarity( t ) | local function initRarity( t ) | ||
− | t. | + | local rarity = not t.flags.isOP and _standard[ 3 ]; |
− | if | + | if not t.flags.isOP and rarity == '' then |
return t:error( 'rarity' ); | return t:error( 'rarity' ); | ||
end | end | ||
+ | |||
+ | t.rarity = DATA.getRarity( rarity ); -- TODO: error in case there's no rarity found. | ||
end | end | ||
Line 157: | Line 145: | ||
t.edition = DATA.getEdition( edition ); | t.edition = DATA.getEdition( edition ); | ||
− | if | + | if not hasNoEdition( t ) and not t.edition then |
return t:error( 'edition' ); | return t:error( 'edition' ); | ||
end | end | ||
Line 173: | Line 161: | ||
-- @name initOptions | -- @name initOptions | ||
− | -- @description Sets any possible options ( | + | -- @description Sets any possible options (`extension` and `description`). |
local function initOptions( t ) | local function initOptions( t ) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
-- Extension: | -- Extension: | ||
local extension = _options[ 'extension' ]; | local extension = _options[ 'extension' ]; | ||
Line 193: | Line 169: | ||
-- Description: | -- Description: | ||
t.description = _options[ 'description' ]; | t.description = _options[ 'description' ]; | ||
− | |||
− | |||
− | |||
end | end | ||
Line 201: | Line 174: | ||
-- @description Initializes the attributes of the File instance. | -- @description Initializes the attributes of the File instance. | ||
local function init( t ) | local function init( t ) | ||
− | |||
initNumber( t ); | initNumber( t ); | ||
initSet( t ); | initSet( t ); | ||
Line 208: | Line 180: | ||
initEdition( t ); | initEdition( t ); | ||
initAlt( t ); | initAlt( t ); | ||
+ | initOptions( t ); | ||
return t; | return t; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 280: | Line 231: | ||
self.flags.hasErrors = true; | self.flags.hasErrors = true; | ||
self.parent:error( | self.parent:error( | ||
− | ('No %s | + | ('No %s given for file input number %d!'):format( parameter, self.id ) |
) | ) | ||
Line 294: | Line 245: | ||
-- Build file: | -- Build file: | ||
− | local file = ( self.file | + | local file = UTIL.newStringBuffer() |
+ | :add( UTIL.getImgName() ) | ||
+ | :add( self.setAbbr ) | ||
+ | :add( self.parent:getRegion().index ) | ||
+ | :add( self.rarity and self.rarity.abbr ) | ||
+ | :add( self.edition and self.edition.abbr ) | ||
+ | ; | ||
+ | |||
+ | for _, release in ipairs( self.releases ) do | ||
+ | file:add( release.abbr ); | ||
+ | end | ||
+ | |||
+ | file | ||
+ | :add( self.flags.isOP and OFFICIAL_PROXY.abbr ) | ||
+ | :add( self.alt ) | ||
+ | :flush( '-' ) | ||
+ | :add( self.extension ) | ||
+ | :flush( '.' ) | ||
+ | ; | ||
-- Build caption: | -- Build caption: | ||
− | local caption = | + | local caption = UTIL.newStringBuffer() |
:add( self.number and UTIL.link( self.number ) ) | :add( self.number and UTIL.link( self.number ) ) | ||
:add( | :add( | ||
Line 324: | Line 293: | ||
:flush( '<br />' ) | :flush( '<br />' ) | ||
; | ; | ||
− | + | ||
− | return ('%s | %s'):format( file, caption:toString() ); | + | return ('%s | %s'):format( file:toString(), caption:toString() ); |
end | end | ||