Difference between pages "Card Tips:Prisman" and "Module:Card/traits/implicit Normal and Effect"

From Yugipedia
(Difference between pages)
Jump to: navigation, search
 
(make `isNormalMonster(card)` and `isEffectMonster(card)` local functions. (Need to define them before the function that invokes them for them to work this way.))
 
Line 1: Line 1:
{{Navigation}}
+
-- Trait for games that don't explicitely put "Normal"
 +
-- and don't necessarily put "Effect" next to a card's Type.
  
* This card can be searched by "[[Princess Cologne (card)|Princess Cologne]]", "[[Serpentine Princess]]","[[Emissary of the Afterlife]]", "[[Enchanting Fitting Room]]", "[[Rescue Rabbit]]", "[[Vampire Dragon]]", "[[Sphere of Chaos]]", "[[Dragunity Corsesca]]", "[[Chaos Zone]]", "[[Photon Veil]]" and "[[Shining Angel]]".
+
-- For testing purposes, make sure this is defined.
 +
if not Card then
 +
Card = require('Module:Card')
 +
end
  
* This card can be summoned from the [[Graveyard]] by "[[Limit Reverse]]".
+
-- Take a copy of the original `Card` object before this makes changes to it.
 +
local Parent = mw.clone(Card)
  
* You can send these to the "[[Graveyard]]" with "[[Rock Bombardment]]" then remove them from play to Summon "[[Megarock Dragon]]".
 
  
*This card is versatile in a way that it's a [[Rock]] type with [[Light]] attribute. If this card is in the graveyard it can help special summon [[Gaia Plate the Earth Giant]] or [[Chaos Sorcerer]].
 
  
==Traditional Format==
+
-- ------------------------------------
* This card can be searched by "[[Sangan]]", "[[Last Will]]" and "[[Witch of the Black Forest]]".
+
-- Custom methods
 +
--    Methods that are only to be used within this module
 +
-- ------------------------------------
 +
-- Check if the card is a Normal Monster
 +
-- @param card Card
 +
-- @return bool
 +
local function isNormalMonster(card)
 +
-- Not a monster, can't be a Normal Monster
 +
if (not card.isMonster) then return false end
 +
 
 +
-- If the Types contain an Effect, Summon or ability Type, it is not a Normal Monster
 +
for _, type in pairs(card.types) do
 +
if (TableTools.inArray({ 'Effect', 'Summon', 'Ability' }, type.category)) then
 +
return false
 +
end
 +
end
 +
 
 +
-- If the card has an Effect type, it is not a Normal Monster
 +
if (#card.effectTypes > 0) then return false end
 +
 
 +
-- If the card is a God card, it is not a Normal Monster
 +
if (#card.attributes and card.attributes[1].link == 'DIVINE') then
 +
return false
 +
end
 +
 
 +
return true
 +
end
 +
 
 +
-- Check if the card is an Effect Monster
 +
-- @param card Card
 +
-- @return bool
 +
local function isEffectMonster(card)
 +
-- Not a monster, can't be an Effect Monster
 +
if (not card.isMonster) then return false end
 +
 
 +
-- If the Types contain an Effect or ability Type, it is an Effect Monster
 +
for _, type in pairs(card.types) do
 +
if (TableTools.inArray({ 'Effect', 'Ability' }, type.category)) then
 +
return true
 +
end
 +
end
 +
 
 +
-- If the card has an Effect type, it is an Effect Monster
 +
if (#card.effectTypes > 0) then return true end
 +
 
 +
return false
 +
end
 +
 
 +
 
 +
 
 +
-- ------------------------------------
 +
-- Override methods
 +
--    These methods exist in the original `Card` module
 +
--    And are having their behavior modified here.
 +
-- ------------------------------------
 +
-- Override the `setData` method to change its Normal/Effect-checking logic
 +
function Card:setData(args)
 +
-- Call the original `setData` function
 +
Parent.setData(self, args)
 +
 
 +
-- Set the "Normal" and "Effect" checks based on the logic in this module
 +
self.isNormalMonster = isNormalMonster(self)
 +
self.isEffectMonster = isEffectMonster(self)
 +
end
 +
 
 +
return Card

Latest revision as of 22:14, 28 December 2023

-- Trait for games that don't explicitely put "Normal"
-- and don't necessarily put "Effect" next to a card's Type.

-- For testing purposes, make sure this is defined.
if not Card then
	Card = require('Module:Card')
end

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



-- ------------------------------------
-- Custom methods
--    Methods that are only to be used within this module
-- ------------------------------------
-- Check if the card is a Normal Monster
-- @param card Card
-- @return bool
local function isNormalMonster(card)
	-- Not a monster, can't be a Normal Monster
	if (not card.isMonster) then return false end

	-- If the Types contain an Effect, Summon or ability Type, it is not a Normal Monster
	for _, type in pairs(card.types) do
		if (TableTools.inArray({ 'Effect', 'Summon', 'Ability' }, type.category)) then
			return false
		end
	end

	-- If the card has an Effect type, it is not a Normal Monster
	if (#card.effectTypes > 0) then return false end

	-- If the card is a God card, it is not a Normal Monster
	if (#card.attributes and card.attributes[1].link == 'DIVINE') then
		return false
	end

	return true
end

-- Check if the card is an Effect Monster
-- @param card Card
-- @return bool
local function isEffectMonster(card)
	-- Not a monster, can't be an Effect Monster
	if (not card.isMonster) then return false end

	-- If the Types contain an Effect or ability Type, it is an Effect Monster
	for _, type in pairs(card.types) do
		if (TableTools.inArray({ 'Effect', 'Ability' }, type.category)) then
			return true
		end
	end

	-- If the card has an Effect type, it is an Effect Monster
	if (#card.effectTypes > 0) then return true end

	return false
end



-- ------------------------------------
-- Override methods
--    These methods exist in the original `Card` module
--    And are having their behavior modified here.
-- ------------------------------------
-- Override the `setData` method to change its Normal/Effect-checking logic
function Card:setData(args)
	-- Call the original `setData` function
	Parent.setData(self, args)

	-- Set the "Normal" and "Effect" checks based on the logic in this module
	self.isNormalMonster = isNormalMonster(self)
	self.isEffectMonster = isEffectMonster(self)
end

return Card