name: The
card_text: When this card is activated: Add 1 "The Winged Dragon of Ra" or 1 card that mentions it from your Deck to your hand, except "The True Sun God". Monsters, except "The Winged Dragon of Ra", cannot attack the turn they are Special Summoned. Once per turn, during your Main Phase: You can send this card from the field, or 1 "The Winged Dragon of Ra - Immortal Phoenix" from your Deck, to the GY, then send 1 "The Winged Dragon of Ra" from your Monster Zone to the GY. You can only activate 1 "The True Sun God" per turn.
external_ids: local CARD_ID_0 = 10000010 --The Winged Dragon of Ra
  local CARD_ID_1 = 10000090 --The Winged Dragon of Ra - Immortal Phoenix
  
lua: local CARD_ID_0 = 10000010 --The Winged Dragon of Ra
  local CARD_ID_1 = 10000090 --The Winged Dragon of Ra - Immortal Phoenix
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atklimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.attg)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.tgtg)
  	e3:SetOperation(s.tgop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return aux.IsCodeOrListed(c, CARD_ID_0) and not c:IsCode(id) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.attg(e, c)
  	return c:IsStatus(STATUS_SPSUMMON_TURN) and not c:IsCode(CARD_ID_0)
  end
  function s.tgfilter1(c)
  	return c:IsAbleToGrave() and c:IsCode(CARD_ID_1)
  end
  function s.tgfilter2(c)
  	return c:IsAbleToGrave() and c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (e:GetHandler():IsAbleToGrave() or Duel.IsExistingMatchingCard(s.tgfilter1, tp, LOCATION_DECK, 0, 1, nil)) and Duel.IsExistingMatchingCard(s.tgfilter2, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 2, tp, LOCATION_MZONE + LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.tgfilter1, tp, LOCATION_DECK, 0, nil)
  	if c:IsRelateToChain() and c:IsAbleToGrave() then
  		g:AddCard(c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg1 = g:Select(tp, 1, 1, nil)
  	if Duel.SendtoGrave(sg1, REASON_EFFECT) > 0 and sg1:GetFirst():IsLocation(LOCATION_GRAVE) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local sg2 = Duel.SelectMatchingCard(tp, s.tgfilter2, tp, LOCATION_MZONE, 0, 1, 1, nil)
  		if #sg2 > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoGrave(sg2, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: The
  When this card is activated: Add 1 "The Winged Dragon of Ra" or 1 card that mentions it from your Deck to your hand, except "The True Sun God". Monsters, except "The Winged Dragon of Ra", cannot attack the turn they are Special Summoned. Once per turn, during your Main Phase: You can send this card from the field, or 1 "The Winged Dragon of Ra - Immortal Phoenix" from your Deck, to the GY, then send 1 "The Winged Dragon of Ra" from your Monster Zone to the GY. You can only activate 1 "The True Sun God" per turn.
target_text: -- The
  local CARD_ID_0 = 10000010 --The Winged Dragon of Ra
  local CARD_ID_1 = 10000090 --The Winged Dragon of Ra - Immortal Phoenix
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atklimit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(s.attg)
  	c:RegisterEffect(e2)
  	--to grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_TOGRAVE)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.tgtg)
  	e3:SetOperation(s.tgop)
  	c:RegisterEffect(e3)
  end
  function s.filter(c)
  	return aux.IsCodeOrListed(c, CARD_ID_0) and not c:IsCode(id) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.attg(e, c)
  	return c:IsStatus(STATUS_SPSUMMON_TURN) and not c:IsCode(CARD_ID_0)
  end
  function s.tgfilter1(c)
  	return c:IsAbleToGrave() and c:IsCode(CARD_ID_1)
  end
  function s.tgfilter2(c)
  	return c:IsAbleToGrave() and c:IsCode(CARD_ID_0) and c:IsFaceup()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return (e:GetHandler():IsAbleToGrave() or Duel.IsExistingMatchingCard(s.tgfilter1, tp, LOCATION_DECK, 0, 1, nil)) and Duel.IsExistingMatchingCard(s.tgfilter2, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 2, tp, LOCATION_MZONE + LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.tgfilter1, tp, LOCATION_DECK, 0, nil)
  	if c:IsRelateToChain() and c:IsAbleToGrave() then
  		g:AddCard(c)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local sg1 = g:Select(tp, 1, 1, nil)
  	if Duel.SendtoGrave(sg1, REASON_EFFECT) > 0 and sg1:GetFirst():IsLocation(LOCATION_GRAVE) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  		local sg2 = Duel.SelectMatchingCard(tp, s.tgfilter2, tp, LOCATION_MZONE, 0, 1, 1, nil)
  		if #sg2 > 0 then
  			Duel.BreakEffect()
  			Duel.SendtoGrave(sg2, REASON_EFFECT)
  		end
  	end
  end
  
  