name: Spiral
card_text: While "Gaia the Dragon Champion" is in your Monster Zone, your opponent's monsters can only target "Gaia the Dragon Champion" for attacks. When an attack is declared involving your "Gaia the Dragon Champion": You can target 1 card on the field; destroy it. You can only use this effect of "Spiral Discharge" once 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 e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--atklimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetCondition(s.tgcon)
  	e1:SetValue(s.tgtg)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(s.tgcon)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.tgcon(e)
  	return Duel.IsExistingMatchingCard(s.tgfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.tgtg(e, c)
  	return c:IsFacedown() or not c:IsCode(CARD_ID_0)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local ac = Duel.GetAttacker()
  	local tc = Duel.GetAttackTarget()
  	if not ac:IsControler(tp) then
  		ac, tc = tc, ac
  	end
  	return ac and ac:IsControler(tp) and ac:IsFaceup() and ac:IsCode(CARD_ID_0)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField()
  	end
  	local xg = nil
  	if not e:GetHandler():IsStatus(STATUS_EFFECT_ENABLED) then
  		xg = e:GetHandler()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, xg)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, xg)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  
source_text: Spiral
  While "Gaia the Dragon Champion" is in your Monster Zone, your opponent's monsters can only target "Gaia the Dragon Champion" for attacks. When an attack is declared involving your "Gaia the Dragon Champion": You can target 1 card on the field; destroy it. You can only use this effect of "Spiral Discharge" once 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 e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_ACTIVATE)
  	e0:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e0)
  	--atklimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_SELECT_BATTLE_TARGET)
  	e1:SetRange(LOCATION_SZONE)
  	e1:SetTargetRange(0, LOCATION_MZONE)
  	e1:SetCondition(s.tgcon)
  	e1:SetValue(s.tgtg)
  	c:RegisterEffect(e1)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(s.tgcon)
  	c:RegisterEffect(e2)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_ATTACK_ANNOUNCE)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.tgfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.tgcon(e)
  	return Duel.IsExistingMatchingCard(s.tgfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.tgtg(e, c)
  	return c:IsFacedown() or not c:IsCode(CARD_ID_0)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local ac = Duel.GetAttacker()
  	local tc = Duel.GetAttackTarget()
  	if not ac:IsControler(tp) then
  		ac, tc = tc, ac
  	end
  	return ac and ac:IsControler(tp) and ac:IsFaceup() and ac:IsCode(CARD_ID_0)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField()
  	end
  	local xg = nil
  	if not e:GetHandler():IsStatus(STATUS_EFFECT_ENABLED) then
  		xg = e:GetHandler()
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, xg)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, 1, xg)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  