name: SPYRAL
card_text: 2 "SPYRAL" monsters
  This card's name becomes "SPYRAL Super Agent" while on the field or in the GY. You can declare 1 card type (Monster, Spell, or Trap); reveal the top card of your opponent's Deck, and if you do, and its type matches the declared type, take 1 "SPYRAL" monster from your Deck or GY, and either add it to your hand or Special Summon it to your zone this card points to. You can only use this effect of "SPYRAL Double Helix" once per turn.
external_ids: local CARD_ID_0 = 41091257 --SPYRAL Super Agent
  local SETCARD_ID_0 = 0xee --SPYRAL
  
lua: local CARD_ID_0 = 41091257 --SPYRAL Super Agent
  local SETCARD_ID_0 = 0xee --SPYRAL
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
  	--change name
  	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_MZONE + LOCATION_GRAVE)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.spfilter(c, e, tp, zone)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or (zone ~= 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp, zone)))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local zone = e:GetHandler():GetLinkedZone()
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, e, tp, zone)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CARDTYPE)
  	e:SetLabel(Duel.AnnounceType(tp))
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) == 0 then
  		return
  	end
  	Duel.ConfirmDecktop(1 - tp, 1)
  	local g = Duel.GetDecktopGroup(1 - tp, 1)
  	local tc = g:GetFirst()
  	local opt = e:GetLabel()
  	if (opt == 0 and tc:IsType(TYPE_MONSTER)) or (opt == 1 and tc:IsType(TYPE_SPELL)) or (opt == 2 and tc:IsType(TYPE_TRAP)) then
  		local zone = e:GetHandler():GetLinkedZone(tp)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  		local sg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, e, tp, zone)
  		local sc = sg:GetFirst()
  		if sc then
  			if zone ~= 0 and sc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp, zone) and (not sc:IsAbleToHand() or Duel.SelectOption(tp, 1190, 1152) == 1) then
  				Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP, zone)
  			else
  				Duel.SendtoHand(sc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, sc)
  			end
  		end
  	end
  end
  
  
source_text: SPYRAL
  2 "SPYRAL" monsters
  This card's name becomes "SPYRAL Super Agent" while on the field or in the GY. You can declare 1 card type (Monster, Spell, or Trap); reveal the top card of your opponent's Deck, and if you do, and its type matches the declared type, take 1 "SPYRAL" monster from your Deck or GY, and either add it to your hand or Special Summon it to your zone this card points to. You can only use this effect of "SPYRAL Double Helix" once per turn.
target_text: -- SPYRAL
  local CARD_ID_0 = 41091257 --SPYRAL Super Agent
  local SETCARD_ID_0 = 0xee --SPYRAL
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2, 2)
  	--change name
  	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_MZONE + LOCATION_GRAVE)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.spfilter(c, e, tp, zone)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and (c:IsAbleToHand() or (zone ~= 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp, zone)))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local zone = e:GetHandler():GetLinkedZone()
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, nil, e, tp, zone)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CARDTYPE)
  	e:SetLabel(Duel.AnnounceType(tp))
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK + LOCATION_GRAVE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) == 0 then
  		return
  	end
  	Duel.ConfirmDecktop(1 - tp, 1)
  	local g = Duel.GetDecktopGroup(1 - tp, 1)
  	local tc = g:GetFirst()
  	local opt = e:GetLabel()
  	if (opt == 0 and tc:IsType(TYPE_MONSTER)) or (opt == 1 and tc:IsType(TYPE_SPELL)) or (opt == 2 and tc:IsType(TYPE_TRAP)) then
  		local zone = e:GetHandler():GetLinkedZone(tp)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  		local sg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_DECK + LOCATION_GRAVE, 0, 1, 1, nil, e, tp, zone)
  		local sc = sg:GetFirst()
  		if sc then
  			if zone ~= 0 and sc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp, zone) and (not sc:IsAbleToHand() or Duel.SelectOption(tp, 1190, 1152) == 1) then
  				Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP, zone)
  			else
  				Duel.SendtoHand(sc, nil, REASON_EFFECT)
  				Duel.ConfirmCards(1 - tp, sc)
  			end
  		end
  	end
  end
  
  