name: Tricky
card_text: Send 1 face-up "The Tricky" you control to the Graveyard; Special Summon "Tricky Tokens" (Spellcaster-Type/WIND/Level 5/ATK 2000/DEF 1200) in Defense Position, equal to the number of monsters your opponent controls. "Tricky Tokens" cannot declare an attack.
external_ids: local CARD_ID_0 = 75622825 --Tricky Token
  local CARD_ID_1 = 14778250 --The Tricky
  local CARD_ID_2 = 59822133 --Blue-Eyes Spirit Dragon
  
lua: local CARD_ID_0 = 75622825 --Tricky Token
  local CARD_ID_1 = 14778250 --The Tricky
  local CARD_ID_2 = 59822133 --Blue-Eyes Spirit Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetFieldGroupCount(1 - tp, LOCATION_MZONE, 0)
  	if chk == 0 then
  		return ct > 0
  			and (ct == 1 or not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_2))
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > ct - 2
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 1200, 5, RACE_SPELLCASTER, ATTRIBUTE_WIND, POS_FACEUP_DEFENSE)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, ct, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, ct, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_2) then
  		ft = 1
  	end
  	local ct = Duel.GetFieldGroupCount(1 - tp, LOCATION_MZONE, 0)
  	if ft < ct then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 1200, 5, RACE_SPELLCASTER, ATTRIBUTE_WIND, POS_FACEUP_DEFENSE) then
  		return
  	end
  	for i = 1, ct do
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		token:RegisterEffect(e1, true)
  	end
  	Duel.SpecialSummonComplete()
  end
  
  
source_text: Tricky
  Send 1 face-up "The Tricky" you control to the Graveyard; Special Summon "Tricky Tokens" (Spellcaster-Type/WIND/Level 5/ATK 2000/DEF 1200) in Defense Position, equal to the number of monsters your opponent controls. "Tricky Tokens" cannot declare an attack.
target_text: -- Tricky
  local CARD_ID_0 = 75622825 --Tricky Token
  local CARD_ID_1 = 14778250 --The Tricky
  local CARD_ID_2 = 59822133 --Blue-Eyes Spirit Dragon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	local ct = Duel.GetFieldGroupCount(1 - tp, LOCATION_MZONE, 0)
  	if chk == 0 then
  		return ct > 0
  			and (ct == 1 or not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_2))
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > ct - 2
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 1200, 5, RACE_SPELLCASTER, ATTRIBUTE_WIND, POS_FACEUP_DEFENSE)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, ct, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, ct, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_2) then
  		ft = 1
  	end
  	local ct = Duel.GetFieldGroupCount(1 - tp, LOCATION_MZONE, 0)
  	if ft < ct then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 1200, 5, RACE_SPELLCASTER, ATTRIBUTE_WIND, POS_FACEUP_DEFENSE) then
  		return
  	end
  	for i = 1, ct do
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		token:RegisterEffect(e1, true)
  	end
  	Duel.SpecialSummonComplete()
  end
  
  