name: Ancient
card_text: Reveal 1 Level 5 or higher "Ancient Gear" monster from your hand, then banish a number of "Ancient Gear" monsters from your Graveyard, whose combined Levels are double the revealed monster's, and if you do, if you Normal Summon the revealed monster this turn, you must Normal Smmon it without Tributing.
external_ids: local SETCARD_ID_0 = 0x7 --Ancient
  
lua: local SETCARD_ID_0 = 0x7 --Ancient
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, g)
  	return c:IsLevelAbove(5) and c:IsSetCard(SETCARD_ID_0) and g:CheckWithSumEqual(Card.GetLevel, c:GetLevel() * 2, 1, 99)
  end
  function s.rfilter(c)
  	return c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_GRAVE, 0, nil)
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, rg)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil, rg)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.ConfirmCards(1 - tp, tc)
  		Duel.ShuffleHand(tp)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg = rg:SelectWithSumEqual(tp, Card.GetLevel, tc:GetLevel() * 2, 1, 99)
  		Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SUMMON_PROC)
  		e1:SetCondition(s.ntcon)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  
  
source_text: Ancient
  Reveal 1 Level 5 or higher "Ancient Gear" monster from your hand, then banish a number of "Ancient Gear" monsters from your Graveyard, whose combined Levels are double the revealed monster's, and if you do, if you Normal Summon the revealed monster this turn, you must Normal Smmon it without Tributing.
target_text: -- Ancient
  local SETCARD_ID_0 = 0x7 --Ancient
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, g)
  	return c:IsLevelAbove(5) and c:IsSetCard(SETCARD_ID_0) and g:CheckWithSumEqual(Card.GetLevel, c:GetLevel() * 2, 1, 99)
  end
  function s.rfilter(c)
  	return c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_GRAVE, 0, nil)
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, rg)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local rg = Duel.GetMatchingGroup(s.rfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 1))
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil, rg)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.ConfirmCards(1 - tp, tc)
  		Duel.ShuffleHand(tp)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  		local sg = rg:SelectWithSumEqual(tp, Card.GetLevel, tc:GetLevel() * 2, 1, 99)
  		Duel.Remove(sg, POS_FACEUP, REASON_EFFECT)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetDescription(aux.Stringid(id, 0))
  		e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SUMMON_PROC)
  		e1:SetCondition(s.ntcon)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  
  