name: Magicians'
card_text: You can send up to 2 Spells/Traps from your hand and/or field to the GY; draw that many cards. If this card is in your hand: You can send 1 Level 6 or higher Spellcaster monster from your Deck to the GY, then activate 1 of these effects;
  ● Special Summon this card.
  ● Send this card to the GY, then, you can Special Summon 1 "Dark Magician" or 1 "Dark Magician Girl" from your GY.
  You can only use each effect of "Magicians' Souls" once per turn.
external_ids: local CARD_ID_0 = 46986414 --Dark Magician
  local CARD_ID_2 = 38033121 --Dark Magician Girl
  
lua: local CARD_ID_0 = 46986414 --Dark Magician
  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)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	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)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.drcost)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsLevelAbove(6) and c:IsRace(RACE_SPELLCASTER) and c:IsAbleToGraveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local b1 = c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	local b2 = c:IsAbleToGrave()
  	if chk == 0 then
  		return b1 or b2
  	end
  	local s = 0
  	if b1 and not b2 then
  		s = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	elseif not b1 and b2 then
  		s = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	elseif b1 and b2 then
  		s = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	end
  	e:SetLabel(s)
  	if s == 0 then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOGRAVE + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, c, 1, 0, 0)
  	end
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_0, CARD_ID_2) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if e:GetLabel() == 0 and c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  	if
  		e:GetLabel() == 1
  		and c:IsRelateToEffect(e)
  		and Duel.SendtoGrave(c, REASON_EFFECT) > 0
  		and c:IsLocation(LOCATION_GRAVE)
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.drfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToGraveAsCost()
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.drfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil)
  	end
  	local ct = 1
  	if Duel.IsPlayerCanDraw(tp, 2) then
  		ct = 2
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.drfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, ct, nil)
  	e:SetLabel(Duel.SendtoGrave(g, REASON_COST))
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	local ct = e:GetLabel()
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(ct)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, ct)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  
  
source_text: Magicians'
  You can send up to 2 Spells/Traps from your hand and/or field to the GY; draw that many cards. If this card is in your hand: You can send 1 Level 6 or higher Spellcaster monster from your Deck to the GY, then activate 1 of these effects;
  ● Special Summon this card.
  ● Send this card to the GY, then, you can Special Summon 1 "Dark Magician" or 1 "Dark Magician Girl" from your GY.
  You can only use each effect of "Magicians' Souls" once per turn.
target_text: -- Magicians'
  local CARD_ID_0 = 46986414 --Dark Magician
  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)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	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)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.drcost)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsLevelAbove(6) and c:IsRace(RACE_SPELLCASTER) and c:IsAbleToGraveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local b1 = c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  	local b2 = c:IsAbleToGrave()
  	if chk == 0 then
  		return b1 or b2
  	end
  	local s = 0
  	if b1 and not b2 then
  		s = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	elseif not b1 and b2 then
  		s = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	elseif b1 and b2 then
  		s = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	end
  	e:SetLabel(s)
  	if s == 0 then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOGRAVE + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_SPSUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, c, 1, 0, 0)
  	end
  end
  function s.spfilter(c, e, tp)
  	return c:IsCode(CARD_ID_0, CARD_ID_2) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if e:GetLabel() == 0 and c:IsRelateToEffect(e) then
  		Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  	end
  	if
  		e:GetLabel() == 1
  		and c:IsRelateToEffect(e)
  		and Duel.SendtoGrave(c, REASON_EFFECT) > 0
  		and c:IsLocation(LOCATION_GRAVE)
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.drfilter(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP) and c:IsAbleToGraveAsCost()
  end
  function s.drcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.drfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, nil)
  	end
  	local ct = 1
  	if Duel.IsPlayerCanDraw(tp, 2) then
  		ct = 2
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.drfilter, tp, LOCATION_HAND + LOCATION_ONFIELD, 0, 1, ct, nil)
  	e:SetLabel(Duel.SendtoGrave(g, REASON_COST))
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	local ct = e:GetLabel()
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(ct)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, ct)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  
  