name: Machine
card_text: This card can be used to Ritual Summon any "Cyber Angel" Ritual Monster. You must also Tribute monsters from your hand or field and/or shuffle Fairy or Warrior-Type monsters from your Graveyard into the Deck, whose total Levels exactly equal the Level of the Ritual Monster you Ritual Summon.
external_ids: local SETCARD_ID_0 = 0x2093 --Cyber
  
lua: local SETCARD_ID_0 = 0x2093 --Cyber
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.mfilter(c)
  	return c:GetLevel() > 0 and c:IsRace(RACE_WARRIOR + RACE_FAIRY) and c:IsAbleToDeck()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local mg1 = Duel.GetRitualMaterial(tp)
  		local mg2 = Duel.GetMatchingGroup(s.mfilter, tp, LOCATION_GRAVE, 0, nil)
  		return Duel.IsExistingMatchingCard(aux.RitualUltimateFilter, tp, LOCATION_HAND, 0, 1, nil, s.filter, e, tp, mg1, mg2, Card.GetLevel, "Equal")
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 0, tp, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	::cancel::
  	local mg1 = Duel.GetRitualMaterial(tp)
  	local mg2 = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.mfilter), tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.RitualUltimateFilter, tp, LOCATION_HAND, 0, 1, 1, nil, s.filter, e, tp, mg1, mg2, Card.GetLevel, "Equal")
  	local tc = g:GetFirst()
  	if tc then
  		local mg = mg1:Filter(Card.IsCanBeRitualMaterial, tc, tc)
  		mg:Merge(mg2)
  		if tc.mat_filter then
  			mg = mg:Filter(tc.mat_filter, tc, tp)
  		else
  			mg:RemoveCard(tc)
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  		aux.GCheckAdditional = aux.RitualCheckAdditional(tc, tc:GetLevel(), "Equal")
  		local mat = mg:SelectSubGroup(tp, aux.RitualCheck, true, 1, tc:GetLevel(), tp, tc, tc:GetLevel(), "Equal")
  		aux.GCheckAdditional = nil
  		if not mat then
  			goto cancel
  		end
  		tc:SetMaterial(mat)
  		local mat2 = mat:Filter(Card.IsLocation, nil, LOCATION_GRAVE):Filter(Card.IsRace, nil, RACE_WARRIOR + RACE_FAIRY)
  		if #mat2 > 0 then
  			Duel.HintSelection(mat2)
  		end
  		mat:Sub(mat2)
  		Duel.ReleaseRitualMaterial(mat)
  		Duel.SendtoDeck(mat2, nil, SEQ_DECKSHUFFLE, REASON_EFFECT + REASON_MATERIAL + REASON_RITUAL)
  		Duel.BreakEffect()
  		Duel.SpecialSummon(tc, SUMMON_TYPE_RITUAL, tp, tp, false, true, POS_FACEUP)
  		tc:CompleteProcedure()
  	end
  end
  
  
source_text: Machine
  This card can be used to Ritual Summon any "Cyber Angel" Ritual Monster. You must also Tribute monsters from your hand or field and/or shuffle Fairy or Warrior-Type monsters from your Graveyard into the Deck, whose total Levels exactly equal the Level of the Ritual Monster you Ritual Summon.
target_text: -- Machine
  local SETCARD_ID_0 = 0x2093 --Cyber
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.mfilter(c)
  	return c:GetLevel() > 0 and c:IsRace(RACE_WARRIOR + RACE_FAIRY) and c:IsAbleToDeck()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local mg1 = Duel.GetRitualMaterial(tp)
  		local mg2 = Duel.GetMatchingGroup(s.mfilter, tp, LOCATION_GRAVE, 0, nil)
  		return Duel.IsExistingMatchingCard(aux.RitualUltimateFilter, tp, LOCATION_HAND, 0, 1, nil, s.filter, e, tp, mg1, mg2, Card.GetLevel, "Equal")
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 0, tp, LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	::cancel::
  	local mg1 = Duel.GetRitualMaterial(tp)
  	local mg2 = Duel.GetMatchingGroup(aux.NecroValleyFilter(s.mfilter), tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, aux.RitualUltimateFilter, tp, LOCATION_HAND, 0, 1, 1, nil, s.filter, e, tp, mg1, mg2, Card.GetLevel, "Equal")
  	local tc = g:GetFirst()
  	if tc then
  		local mg = mg1:Filter(Card.IsCanBeRitualMaterial, tc, tc)
  		mg:Merge(mg2)
  		if tc.mat_filter then
  			mg = mg:Filter(tc.mat_filter, tc, tp)
  		else
  			mg:RemoveCard(tc)
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RELEASE)
  		aux.GCheckAdditional = aux.RitualCheckAdditional(tc, tc:GetLevel(), "Equal")
  		local mat = mg:SelectSubGroup(tp, aux.RitualCheck, true, 1, tc:GetLevel(), tp, tc, tc:GetLevel(), "Equal")
  		aux.GCheckAdditional = nil
  		if not mat then
  			goto cancel
  		end
  		tc:SetMaterial(mat)
  		local mat2 = mat:Filter(Card.IsLocation, nil, LOCATION_GRAVE):Filter(Card.IsRace, nil, RACE_WARRIOR + RACE_FAIRY)
  		if #mat2 > 0 then
  			Duel.HintSelection(mat2)
  		end
  		mat:Sub(mat2)
  		Duel.ReleaseRitualMaterial(mat)
  		Duel.SendtoDeck(mat2, nil, SEQ_DECKSHUFFLE, REASON_EFFECT + REASON_MATERIAL + REASON_RITUAL)
  		Duel.BreakEffect()
  		Duel.SpecialSummon(tc, SUMMON_TYPE_RITUAL, tp, tp, false, true, POS_FACEUP)
  		tc:CompleteProcedure()
  	end
  end
  
  