name: Galloping
card_text: Your opponent cannot activate cards or effects during the Battle Phase while "Gaia the Dragon Champion" is in your Monster Zone. You can activate 1 of the following effects.
  ● You can reveal 1 "Gaia The Fierce Knight" monster in your hand; add 1 Level 5 Dragon monster from your Deck to your hand.
  ● You can reveal 1 Level 5 Dragon monster in your hand; add 1 "Gaia The Fierce Knight" monster from your Deck to your hand.
  You can only use this effect of "Galloping Gaia" once per turn.
external_ids: local CARD_ID_0 = 66889139 --Gaia the Dragon Champion
  local SETCARD_ID_0 = 0xbd --Gaia
  
lua: local CARD_ID_0 = 66889139 --Gaia the Dragon Champion
  local SETCARD_ID_0 = 0xbd --Gaia
  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)
  	--actlimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(0, 1)
  	e1:SetRange(LOCATION_FZONE)
  	e1:SetValue(1)
  	e1:SetCondition(s.actcon)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.cost1)
  	e2:SetTarget(s.target1)
  	e2:SetOperation(s.activate1)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCost(s.cost2)
  	e3:SetTarget(s.target2)
  	e3:SetOperation(s.activate2)
  	c:RegisterEffect(e3)
  end
  function s.actfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.actcon(e)
  	local ph = Duel.GetCurrentPhase()
  	local tp = e:GetHandlerPlayer()
  	return Duel.IsExistingMatchingCard(s.actfilter, tp, LOCATION_MZONE, 0, 1, nil) and ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE
  end
  function s.costfilter1(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and not c:IsPublic()
  end
  function s.cost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter1, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter1, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  end
  function s.thfilter1(c)
  	return c:IsLevel(5) and c:IsRace(RACE_DRAGON) and c:IsAbleToHand()
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter1, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate1(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter1, 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.costfilter2(c)
  	return c:IsLevel(5) and c:IsRace(RACE_DRAGON) and not c:IsPublic()
  end
  function s.cost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter2, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter2, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  end
  function s.thfilter2(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter2, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter2, 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
  
  
source_text: Galloping
  Your opponent cannot activate cards or effects during the Battle Phase while "Gaia the Dragon Champion" is in your Monster Zone. You can activate 1 of the following effects.
  ● You can reveal 1 "Gaia The Fierce Knight" monster in your hand; add 1 Level 5 Dragon monster from your Deck to your hand.
  ● You can reveal 1 Level 5 Dragon monster in your hand; add 1 "Gaia The Fierce Knight" monster from your Deck to your hand.
  You can only use this effect of "Galloping Gaia" once per turn.
target_text: -- Galloping
  local CARD_ID_0 = 66889139 --Gaia the Dragon Champion
  local SETCARD_ID_0 = 0xbd --Gaia
  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)
  	--actlimit
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(0, 1)
  	e1:SetRange(LOCATION_FZONE)
  	e1:SetValue(1)
  	e1:SetCondition(s.actcon)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SEARCH + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.cost1)
  	e2:SetTarget(s.target1)
  	e2:SetOperation(s.activate1)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCost(s.cost2)
  	e3:SetTarget(s.target2)
  	e3:SetOperation(s.activate2)
  	c:RegisterEffect(e3)
  end
  function s.actfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.actcon(e)
  	local ph = Duel.GetCurrentPhase()
  	local tp = e:GetHandlerPlayer()
  	return Duel.IsExistingMatchingCard(s.actfilter, tp, LOCATION_MZONE, 0, 1, nil) and ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE
  end
  function s.costfilter1(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and not c:IsPublic()
  end
  function s.cost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter1, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter1, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  end
  function s.thfilter1(c)
  	return c:IsLevel(5) and c:IsRace(RACE_DRAGON) and c:IsAbleToHand()
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter1, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate1(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter1, 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.costfilter2(c)
  	return c:IsLevel(5) and c:IsRace(RACE_DRAGON) and not c:IsPublic()
  end
  function s.cost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.costfilter2, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONFIRM)
  	local g = Duel.SelectMatchingCard(tp, s.costfilter2, tp, LOCATION_HAND, 0, 1, 1, nil)
  	Duel.ConfirmCards(1 - tp, g)
  	Duel.ShuffleHand(tp)
  end
  function s.thfilter2(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter2, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.activate2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter2, 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
  
  