name: Spiral
card_text: Target 1 Level 7 or lower Dragon monster in your GY; Special Summon it. If you Special Summoned a "Gaia the Dragon Champion" by this effect, your opponent cannot target it with card effects, and it cannot be destroyed by their card effects. You can only activate 1 "Spiral Reborn" per turn.
external_ids: local CARD_ID_0 = 66889139 --Gaia the Dragon Champion
  
lua: local CARD_ID_0 = 66889139 --Gaia the Dragon Champion
  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_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsLevelBelow(7) and c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) ~= 0 and tc:IsCode(CARD_ID_0) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.tgval)
  		e1:SetOwnerPlayer(tp)
  		tc:RegisterEffect(e1, true)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetDescription(aux.Stringid(id, 0))
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  		e2:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetValue(s.tgval)
  		e2:SetOwnerPlayer(tp)
  		tc:RegisterEffect(e2, true)
  	end
  end
  function s.tgval(e, re, rp)
  	return rp == 1 - e:GetOwnerPlayer()
  end
  
  
source_text: Spiral
  Target 1 Level 7 or lower Dragon monster in your GY; Special Summon it. If you Special Summoned a "Gaia the Dragon Champion" by this effect, your opponent cannot target it with card effects, and it cannot be destroyed by their card effects. You can only activate 1 "Spiral Reborn" per turn.
target_text: -- Spiral
  local CARD_ID_0 = 66889139 --Gaia the Dragon Champion
  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_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsLevelBelow(7) and c:IsRace(RACE_DRAGON) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP) ~= 0 and tc:IsCode(CARD_ID_0) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.tgval)
  		e1:SetOwnerPlayer(tp)
  		tc:RegisterEffect(e1, true)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetDescription(aux.Stringid(id, 0))
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  		e2:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e2:SetValue(s.tgval)
  		e2:SetOwnerPlayer(tp)
  		tc:RegisterEffect(e2, true)
  	end
  end
  function s.tgval(e, re, rp)
  	return rp == 1 - e:GetOwnerPlayer()
  end
  
  