Module:Rush Duel card

From Yugipedia
Jump to: navigation, search
local Card = require('Module:Card')

require('Module:Card/traits/has sets')
require('Module:Card/traits/accepts image input')

-- Take a copy of the original object  before this module makes changes to it.
local Parent = mw.clone(Card)

-- ------------------------------------
-- Overwrite `Module:Card` data
-- ------------------------------------
Card.config.defaultImage     = 'Back-RushDuel-JP.png'
Card.config.icons.levels     = '[[File:Rush Duel Level {$level}.png|28px|alt=|class=noviewer]]'
Card.config.icons.cardType   = '[[File:{$cardType}-DBR-JP.png|28px|alt=|class=noviewer]]'
Card.config.icons.attributes = '[[File:{$attribute}-DBR-JP.png|28px|alt=|class=noviewer]]'
Card.config.langs            = { 'en', 'ja', 'ko' }
Card.config.rows             = {
	'legend',
	'cardType',
	'property',
	'attribute',
	'type',
	'level',
	'maximumAtk',
	'atkDef',
	'effectType',
	'lore',
}
Card.config.allowedCardTypes = { 'Monster', 'Spell', 'Trap', 'Skill' }
Card.config.allowedAttributes = {
	'LIGHT', 'DARK', 'FIRE', 'WATER', 'EARTH', 'WIND', '???'
}
Card.config.allowedTypes = {
	'Dragon', 'Spellcaster', 'Zombie', 'Warrior', 'Beast-Warrior', 'Beast',
	'Winged Beast', 'Fiend', 'Fairy', 'Insect', 'Dinosaur', 'Reptile', 'Fish',
	'Sea Serpent', 'Machine', 'Thunder', 'Aqua', 'Pyro', 'Rock', 'Plant',
	'Psychic', 'Wyrm',
	'Cyberse', 'Cyborg', 'High Dragon', 'Magical Knight', 'Celestial Warrior',
	'Omega Psychic', 'Galaxy',
	'Fusion', 'Maximum', 'Normal', 'Effect',
	'?', '???'
}

Card.setsConfig.breakdown = {
	{
		abbr      = 'RD',
		shortName = 'Rush Duel',
		name      = 'Yu-Gi-Oh! Rush Duel',
		languages = { 'ja', 'ko' }
	}
}

table.insert(Card.categories, 'Yu-Gi-Oh! Rush Duel cards')



-- ------------------------------------
-- Add Rush Duel-specfic properties
-- ------------------------------------
Card.isLegend = nil
Card.maximumAtk = nil
Card.mainEffectType = nil


-- ------------------------------------
-- Override Model:Card methods
-- ------------------------------------
function Card:setData(args)
	-- Call the original function
	Parent.setData(self, args)

	-- Add Rush Duel specific stuff
	self.isLegend = args.legend and args.legend == 'true'
	self.maximumAtk = args.maximum_atk
	self:setMainEffectType()

	if (not self.main) then
		table.insert(self.categories, 'Yu-Gi-Oh! Rush Duel-only cards')
	end
end

-- The file name for the Skill Card icon doesn't match the Spell/Trap files.
-- Override this function to add special handling for Skill Cards
function Card:renderCardTypeIcon()
	-- If the card type is Skill Card, use its own icon
	if (#self.cardTypes and self.cardTypes[1].name == 'Skill') then
		return '[[File:Skill-DULI-EN-VG.png|28px|alt=|class=noviewer]]'
	end

	-- Otherwise, call the original function
	return Parent.renderCardTypeIcon(self)
end


-- ------------------------------------
-- Custom methods
-- ------------------------------------
-- Set the main effect type (the one acknowledged in the lore)
function Card:setMainEffectType()
	-- Exit early if there are no effect types
	if (#self.effectTypes == 0) then return end

	-- Get the last effect type. (Skip any condition effect types.)
	local lastEffectType = self.effectTypes[#self.effectTypes]

	-- `pageName` rather than `name`
	-- e.g. 'Continuous Effect', rather than 'Effect'
	self.mainEffectType = lastEffectType.pageName
end

-- Add row specifically for "Legend" badge
function Card:addLegendRow()
	if (self.isLegend ~= true) then return end

	self:addRow(' ', '[[File:Legend Icon.png|100px|link=Legend Card|alt=Legend|class=noviewer]]')
end

-- Add row specifically for the MAXIMUM ATTACK
function Card:addMaximumAtkRow()
	self:addRow('[[MAXIMUM ATK]]', self.maximumAtk)
end

return Card