name: Witchcrafter
card_text: During the Main Phase (Quick Effect): You can Tribute this card, then discard 1 Spell; Special Summon 1 "Witchcrafter" monster from your Deck, except "Witchcrafter Schmietta". You can banish this card from your GY; send 1 "Witchcrafter" card from your Deck to the GY, except "Witchcrafter Schmietta". You can only use each effect of "Witchcrafter Schmietta" once per turn.
external_ids: local CARD_ID_0 = 83289866 --Witchcrafter Bystreet
  local SETCARD_ID_0 = 0x128 --Witchcrafter
  
lua: local CARD_ID_0 = 83289866 --Witchcrafter Bystreet
  local SETCARD_ID_0 = 0x128 --Witchcrafter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetHintTiming(0, TIMING_MAIN_END)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--to grave
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.costfilter(c, tp)
  	if c:IsLocation(LOCATION_HAND) then
  		return c:IsType(TYPE_SPELL) and c:IsDiscardable()
  	end
  	return c:IsFaceup() and c:IsAbleToGraveAsCost() and c:IsHasEffect(CARD_ID_0, tp)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable() and Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND + LOCATION_SZONE, 0, 1, nil, tp)
  	end
  	local g = Duel.GetMatchingGroup(s.costfilter, tp, LOCATION_HAND + LOCATION_SZONE, 0, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local tc = g:Select(tp, 1, 1, nil):GetFirst()
  	local te = tc:IsHasEffect(CARD_ID_0, tp)
  	if te then
  		te:UseCountLimit(tp)
  		Duel.Release(e:GetHandler(), REASON_COST)
  		Duel.SendtoGrave(tc, REASON_COST)
  	else
  		Duel.Release(e:GetHandler(), REASON_COST)
  		Duel.SendtoGrave(tc, REASON_COST + REASON_DISCARD)
  	end
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetMZoneCount(tp, e:GetHandler()) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  
  
source_text: Witchcrafter
  During the Main Phase (Quick Effect): You can Tribute this card, then discard 1 Spell; Special Summon 1 "Witchcrafter" monster from your Deck, except "Witchcrafter Schmietta". You can banish this card from your GY; send 1 "Witchcrafter" card from your Deck to the GY, except "Witchcrafter Schmietta". You can only use each effect of "Witchcrafter Schmietta" once per turn.
target_text: -- Witchcrafter
  local CARD_ID_0 = 83289866 --Witchcrafter Bystreet
  local SETCARD_ID_0 = 0x128 --Witchcrafter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetHintTiming(0, TIMING_MAIN_END)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--to grave
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(aux.bfgcost)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.costfilter(c, tp)
  	if c:IsLocation(LOCATION_HAND) then
  		return c:IsType(TYPE_SPELL) and c:IsDiscardable()
  	end
  	return c:IsFaceup() and c:IsAbleToGraveAsCost() and c:IsHasEffect(CARD_ID_0, tp)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsReleasable() and Duel.IsExistingMatchingCard(s.costfilter, tp, LOCATION_HAND + LOCATION_SZONE, 0, 1, nil, tp)
  	end
  	local g = Duel.GetMatchingGroup(s.costfilter, tp, LOCATION_HAND + LOCATION_SZONE, 0, nil, tp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local tc = g:Select(tp, 1, 1, nil):GetFirst()
  	local te = tc:IsHasEffect(CARD_ID_0, tp)
  	if te then
  		te:UseCountLimit(tp)
  		Duel.Release(e:GetHandler(), REASON_COST)
  		Duel.SendtoGrave(tc, REASON_COST)
  	else
  		Duel.Release(e:GetHandler(), REASON_COST)
  		Duel.SendtoGrave(tc, REASON_COST + REASON_DISCARD)
  	end
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetMZoneCount(tp, e:GetHandler()) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.tgfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id) and c:IsAbleToGrave()
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.tgfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, tp, LOCATION_DECK)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.tgfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoGrave(g, REASON_EFFECT)
  	end
  end
  
  