name: Timaeus
card_text: You can send 1 Spellcaster monster, or 1 Spell/Trap that mentions "Dark Magician", from your hand or face-up field to the GY; Special Summon this card from your hand. During your Main Phase: You can Fusion Summon 1 Fusion Monster from your Extra Deck, using monsters from your hand or field as material, including a Spellcaster monster. You can only use each effect of "Timaeus the United Dragon" once per turn.
external_ids: local CARD_ID_0 = 46986414 --Dark Magician
  
lua: local CARD_ID_0 = 46986414 --Dark Magician
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--fusion summon
  	local e2 = FusionSpell.CreateSummonEffect(c, {
  		additional_fcheck = s.fcheck,
  	})
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + o)
  	c:RegisterEffect(e2)
  end
  
  function s.cfilter(c, tp)
  	return (c:IsLocation(LOCATION_HAND) or c:IsFaceup())
  		and Duel.GetMZoneCount(tp, c) > 0
  		and c:IsAbleToGraveAsCost()
  		and (c:IsRace(RACE_SPELLCASTER) and c:IsType(TYPE_MONSTER) or aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP))
  end
  
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, nil, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  function s.fcheck(tp, mg, fc, mg_all)
  	--- Must include a Spellcaster monster
  	if not mg_all:IsExists(function(c)
  		return c:IsRace(RACE_SPELLCASTER)
  	end, 1, nil) then
  		return false
  	end
  	return true
  end
  
  
source_text: Timaeus
  You can send 1 Spellcaster monster, or 1 Spell/Trap that mentions "Dark Magician", from your hand or face-up field to the GY; Special Summon this card from your hand. During your Main Phase: You can Fusion Summon 1 Fusion Monster from your Extra Deck, using monsters from your hand or field as material, including a Spellcaster monster. You can only use each effect of "Timaeus the United Dragon" once per turn.
target_text: -- Timaeus
  local CARD_ID_0 = 46986414 --Dark Magician
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--fusion summon
  	local e2 = FusionSpell.CreateSummonEffect(c, {
  		additional_fcheck = s.fcheck,
  	})
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + o)
  	c:RegisterEffect(e2)
  end
  
  function s.cfilter(c, tp)
  	return (c:IsLocation(LOCATION_HAND) or c:IsFaceup())
  		and Duel.GetMZoneCount(tp, c) > 0
  		and c:IsAbleToGraveAsCost()
  		and (c:IsRace(RACE_SPELLCASTER) and c:IsType(TYPE_MONSTER) or aux.IsCodeListed(c, CARD_ID_0) and c:IsType(TYPE_SPELL + TYPE_TRAP))
  end
  
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, 1, nil, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  
  function s.fcheck(tp, mg, fc, mg_all)
  	--- Must include a Spellcaster monster
  	if not mg_all:IsExists(function(c)
  		return c:IsRace(RACE_SPELLCASTER)
  	end, 1, nil) then
  		return false
  	end
  	return true
  end
  
  