name: The
card_text: Target 1 "Dark Magician" or "Dark Magician Girl" you control or in your GY; Fusion Summon 1 Fusion Monster from your Extra Deck that mentions it as material, by shuffling that monster into the Deck, but banish it during the End Phase of the next turn. (This is treated as a Special Summon with "The Eye of Timaeus ".) You can only activate 1 "The Gaze of Timaeus" per turn.
external_ids: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_1 = 1784686 --The Eye of Timaeus
  local CARD_ID_2 = 38033121 --Dark Magician Girl
  
lua: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_1 = 1784686 --The Eye of Timaeus
  local CARD_ID_2 = 38033121 --Dark Magician Girl
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0, CARD_ID_2, CARD_ID_1)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON + CATEGORY_FUSION_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsFaceupEx()
  		and c:IsCode(CARD_ID_0, CARD_ID_2)
  		and c:IsAbleToDeck()
  		and not c:IsImmuneToEffect(e)
  		and c:IsCanBeFusionMaterial()
  		and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_FMATERIAL)
  		and Duel.IsExistingMatchingCard(s.fusfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c:GetCode(), c)
  end
  function s.fusfilter(c, e, tp, code, mc)
  	return c:IsType(TYPE_FUSION) and aux.IsMaterialListCode(c, code) and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0 and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE + LOCATION_GRAVE) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not aux.MustMaterialCheck(tc, tp, EFFECT_MUST_BE_FMATERIAL) or not tc:IsCode(CARD_ID_0, CARD_ID_2) then
  		return
  	end
  	local code = tc:GetCode()
  	if tc and tc:IsRelateToChain() and aux.NecroValleyFilter()(tc) and not tc:IsImmuneToEffect(e) and (tc:IsAbleToDeck() or tc:IsAbleToExtra()) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = Duel.SelectMatchingCard(tp, s.fusfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, code, tc)
  		local sc = sg:GetFirst()
  		if sc then
  			sc:SetMaterial(Group.FromCards(tc))
  			Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  			Duel.BreakEffect()
  			Duel.SpecialSummon(sc, SUMMON_TYPE_FUSION, tp, tp, false, false, POS_FACEUP)
  			local fid = sc:GetFieldID()
  			sc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			sc:CompleteProcedure()
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetCountLimit(1)
  			e1:SetLabelObject(sc)
  			e1:SetLabel(Duel.GetTurnCount() + 1)
  			e1:SetCondition(s.rmcon(fid))
  			e1:SetOperation(s.rmop)
  			e1:SetReset(RESET_PHASE + PHASE_END, 2)
  			Duel.RegisterEffect(e1, tp)
  		end
  	end
  end
  function s.rmcon(fid)
  	return function(e, tp, eg, ep, ev, re, r, rp)
  		local tc = e:GetLabelObject()
  		if tc:GetFlagEffect(id) ~= 0 and tc:GetFlagEffectLabel(id) == fid then
  			return Duel.GetTurnCount() == e:GetLabel()
  		else
  			e:Reset()
  			return false
  		end
  	end
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	local tc = e:GetLabelObject()
  	if tc and tc:IsOnField() then
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  
source_text: The
  Target 1 "Dark Magician" or "Dark Magician Girl" you control or in your GY; Fusion Summon 1 Fusion Monster from your Extra Deck that mentions it as material, by shuffling that monster into the Deck, but banish it during the End Phase of the next turn. (This is treated as a Special Summon with "The Eye of Timaeus ".) You can only activate 1 "The Gaze of Timaeus" per turn.
target_text: -- The
  local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_1 = 1784686 --The Eye of Timaeus
  local CARD_ID_2 = 38033121 --Dark Magician Girl
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0, CARD_ID_2, CARD_ID_1)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON + CATEGORY_FUSION_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsFaceupEx()
  		and c:IsCode(CARD_ID_0, CARD_ID_2)
  		and c:IsAbleToDeck()
  		and not c:IsImmuneToEffect(e)
  		and c:IsCanBeFusionMaterial()
  		and aux.MustMaterialCheck(c, tp, EFFECT_MUST_BE_FMATERIAL)
  		and Duel.IsExistingMatchingCard(s.fusfilter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, c:GetCode(), c)
  end
  function s.fusfilter(c, e, tp, code, mc)
  	return c:IsType(TYPE_FUSION) and aux.IsMaterialListCode(c, code) and Duel.GetLocationCountFromEx(tp, tp, mc, c) > 0 and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_FUSION, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE + LOCATION_GRAVE) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE + LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not aux.MustMaterialCheck(tc, tp, EFFECT_MUST_BE_FMATERIAL) or not tc:IsCode(CARD_ID_0, CARD_ID_2) then
  		return
  	end
  	local code = tc:GetCode()
  	if tc and tc:IsRelateToChain() and aux.NecroValleyFilter()(tc) and not tc:IsImmuneToEffect(e) and (tc:IsAbleToDeck() or tc:IsAbleToExtra()) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = Duel.SelectMatchingCard(tp, s.fusfilter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, code, tc)
  		local sc = sg:GetFirst()
  		if sc then
  			sc:SetMaterial(Group.FromCards(tc))
  			Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  			Duel.BreakEffect()
  			Duel.SpecialSummon(sc, SUMMON_TYPE_FUSION, tp, tp, false, false, POS_FACEUP)
  			local fid = sc:GetFieldID()
  			sc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1, fid)
  			sc:CompleteProcedure()
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetCountLimit(1)
  			e1:SetLabelObject(sc)
  			e1:SetLabel(Duel.GetTurnCount() + 1)
  			e1:SetCondition(s.rmcon(fid))
  			e1:SetOperation(s.rmop)
  			e1:SetReset(RESET_PHASE + PHASE_END, 2)
  			Duel.RegisterEffect(e1, tp)
  		end
  	end
  end
  function s.rmcon(fid)
  	return function(e, tp, eg, ep, ev, re, r, rp)
  		local tc = e:GetLabelObject()
  		if tc:GetFlagEffect(id) ~= 0 and tc:GetFlagEffectLabel(id) == fid then
  			return Duel.GetTurnCount() == e:GetLabel()
  		else
  			e:Reset()
  			return false
  		end
  	end
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_CARD, 0, id)
  	local tc = e:GetLabelObject()
  	if tc and tc:IsOnField() then
  		Duel.Remove(tc, POS_FACEUP, REASON_EFFECT)
  	end
  end
  
  