name: Galaxy-Eyes
card_text: 2 Level 10 monsters
  Once per turn, you can also Xyz Summon "Galaxy-Eyes Cipher X Dragon" by using a "Cipher Dragon" monster you control as material. (Transfer its materials to this card.) You can detach 2 materials from this card; your opponent cannot target LIGHT monsters you control with card effects, until the end of your opponent's turn. Once per turn, during your Standby Phase: You can return 1 Rank 9 or lower Dragon Xyz Monster from your GY to the Extra Deck, then you can Special Summon that monster from your Extra Deck, by using this card you control as material. (This is treated as an Xyz Summon. Transfer this card's materials to the Summoned monster.)
external_ids: local SETCARD_ID_0 = 0x10e5 --Cipher
  
lua: local SETCARD_ID_0 = 0x10e5 --Cipher
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 10, 2, s.ovfilter, aux.Stringid(id, 0), 2, s.xyzop)
  	c:EnableReviveLimit()
  	--CANNOT be tg
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_TOEXTRA + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.con)
  	e2:SetTarget(s.tg)
  	e2:SetOperation(s.op)
  	c:RegisterEffect(e2)
  end
  function s.ovfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.xyzop(e, tp, chk)
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, EFFECT_FLAG_OATH, 1)
  end
  function s.filter1(c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 2, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 2, 2, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_MZONE, 0, nil)
  	local tc = g:GetFirst()
  	while tc do
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  		e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 2)
  		e3:SetValue(aux.tgoval)
  		tc:RegisterEffect(e3)
  		tc = g:GetNext()
  	end
  end
  function s.con(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.filter(c)
  	return c:IsType(TYPE_XYZ) and c:IsRankBelow(9) and c:IsRace(RACE_DRAGON) and c:IsAbleToExtra()
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOEXTRA, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	if #g == 0 then
  		return
  	end
  	Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local c = e:GetHandler()
  	local sc = g:GetFirst()
  	if
  		sc:IsLocation(LOCATION_EXTRA)
  		and c:IsRelateToEffect(e)
  		and c:IsFaceup()
  		and c:IsControler(tp)
  		and c:IsCanBeXyzMaterial(sc)
  		and sc:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, c, sc) > 0
  		and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 4))
  	then
  		Duel.BreakEffect()
  		local mg = c:GetOverlayGroup()
  		if mg:GetCount() ~= 0 then
  			Duel.Overlay(sc, mg)
  		end
  		sc:SetMaterial(Group.FromCards(c))
  		Duel.Overlay(sc, Group.FromCards(c))
  		Duel.SpecialSummon(sc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  		sc:CompleteProcedure()
  	end
  end
  
  
source_text: Galaxy-Eyes
  2 Level 10 monsters
  Once per turn, you can also Xyz Summon "Galaxy-Eyes Cipher X Dragon" by using a "Cipher Dragon" monster you control as material. (Transfer its materials to this card.) You can detach 2 materials from this card; your opponent cannot target LIGHT monsters you control with card effects, until the end of your opponent's turn. Once per turn, during your Standby Phase: You can return 1 Rank 9 or lower Dragon Xyz Monster from your GY to the Extra Deck, then you can Special Summon that monster from your Extra Deck, by using this card you control as material. (This is treated as an Xyz Summon. Transfer this card's materials to the Summoned monster.)
target_text: -- Galaxy-Eyes
  local SETCARD_ID_0 = 0x10e5 --Cipher
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 10, 2, s.ovfilter, aux.Stringid(id, 0), 2, s.xyzop)
  	c:EnableReviveLimit()
  	--CANNOT be tg
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_TOEXTRA + CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.con)
  	e2:SetTarget(s.tg)
  	e2:SetOperation(s.op)
  	c:RegisterEffect(e2)
  end
  function s.ovfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.xyzop(e, tp, chk)
  	if chk == 0 then
  		return Duel.GetFlagEffect(tp, id) == 0
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, EFFECT_FLAG_OATH, 1)
  end
  function s.filter1(c)
  	return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_LIGHT)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 2, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 2, 2, REASON_COST)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local g = Duel.GetMatchingGroup(s.filter1, tp, LOCATION_MZONE, 0, nil)
  	local tc = g:GetFirst()
  	while tc do
  		local e3 = Effect.CreateEffect(c)
  		e3:SetType(EFFECT_TYPE_SINGLE)
  		e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  		e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e3:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 2)
  		e3:SetValue(aux.tgoval)
  		tc:RegisterEffect(e3)
  		tc = g:GetNext()
  	end
  end
  function s.con(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() == tp
  end
  function s.filter(c)
  	return c:IsType(TYPE_XYZ) and c:IsRankBelow(9) and c:IsRace(RACE_DRAGON) and c:IsAbleToExtra()
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOEXTRA, nil, 1, tp, LOCATION_GRAVE)
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	if #g == 0 then
  		return
  	end
  	Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local c = e:GetHandler()
  	local sc = g:GetFirst()
  	if
  		sc:IsLocation(LOCATION_EXTRA)
  		and c:IsRelateToEffect(e)
  		and c:IsFaceup()
  		and c:IsControler(tp)
  		and c:IsCanBeXyzMaterial(sc)
  		and sc:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false)
  		and Duel.GetLocationCountFromEx(tp, tp, c, sc) > 0
  		and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_XMATERIAL)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 4))
  	then
  		Duel.BreakEffect()
  		local mg = c:GetOverlayGroup()
  		if mg:GetCount() ~= 0 then
  			Duel.Overlay(sc, mg)
  		end
  		sc:SetMaterial(Group.FromCards(c))
  		Duel.Overlay(sc, Group.FromCards(c))
  		Duel.SpecialSummon(sc, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  		sc:CompleteProcedure()
  	end
  end
  
  