name: Summon
card_text: 2+ monsters with the same Type, except Tokens
  If this card is Link Summoned: You can Special Summon 1 monster from your hand in Defense Position to your opponent's zone this card points to (but negate its effects), then you can Special Summon 1 monster from your Deck in Defense Position with the same Type as that monster (but negate its effects). If you Summon from your Deck this way, you cannot Special Summon for the rest of this turn, except monsters with that same original Type. You can only use this effect of "Summon Sorceress" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.NOT(aux.FilterBoolFunction(Card.IsLinkType, TYPE_TOKEN)), 2, 99, s.lcheck)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.lcheck(g)
  	return aux.SameValueCheck(g, Card.GetLinkRace)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.spfilter1(c, e, tp, zone)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp, zone)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local zone = e:GetHandler():GetLinkedZone(1 - tp)
  	if chk == 0 then
  		return Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) > 0 and Duel.IsExistingMatchingCard(s.spfilter1, tp, LOCATION_HAND, 0, 1, nil, e, tp, zone)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spfilter2(c, e, tp, rac)
  	return c:IsRace(rac) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local zone = c:GetLinkedZone(1 - tp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local tc = Duel.SelectMatchingCard(tp, s.spfilter1, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, zone):GetFirst()
  	if tc and Duel.SpecialSummonStep(tc, 0, tp, 1 - tp, false, false, POS_FACEUP_DEFENSE, zone) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  		Duel.SpecialSummonComplete()
  		local g = Duel.GetMatchingGroup(s.spfilter2, tp, LOCATION_DECK, 0, nil, e, tp, tc:GetRace())
  		if #g > 0 and Duel.GetMZoneCount(tp) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sc = g:Select(tp, 1, 1, nil):GetFirst()
  			if Duel.SpecialSummonStep(sc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) then
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_DISABLE)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  				sc:RegisterEffect(e1)
  				local e2 = Effect.CreateEffect(c)
  				e2:SetType(EFFECT_TYPE_SINGLE)
  				e2:SetCode(EFFECT_DISABLE_EFFECT)
  				e2:SetValue(RESET_TURN_SET)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  				sc:RegisterEffect(e2)
  				local e3 = Effect.CreateEffect(c)
  				e3:SetType(EFFECT_TYPE_FIELD)
  				e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  				e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  				e3:SetTargetRange(1, 0)
  				e3:SetTarget(s.splimit)
  				e3:SetLabel(sc:GetOriginalRace())
  				e3:SetReset(RESET_PHASE + PHASE_END)
  				Duel.RegisterEffect(e3, tp)
  				Duel.SpecialSummonComplete()
  			end
  		end
  	end
  end
  function s.splimit(e, c)
  	return c:GetOriginalRace() & e:GetLabel() == 0
  end
  
  
source_text: Summon
  2+ monsters with the same Type, except Tokens
  If this card is Link Summoned: You can Special Summon 1 monster from your hand in Defense Position to your opponent's zone this card points to (but negate its effects), then you can Special Summon 1 monster from your Deck in Defense Position with the same Type as that monster (but negate its effects). If you Summon from your Deck this way, you cannot Special Summon for the rest of this turn, except monsters with that same original Type. You can only use this effect of "Summon Sorceress" once per turn.
target_text: -- Summon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.NOT(aux.FilterBoolFunction(Card.IsLinkType, TYPE_TOKEN)), 2, 99, s.lcheck)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.lcheck(g)
  	return aux.SameValueCheck(g, Card.GetLinkRace)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.spfilter1(c, e, tp, zone)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, 1 - tp, zone)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local zone = e:GetHandler():GetLinkedZone(1 - tp)
  	if chk == 0 then
  		return Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) > 0 and Duel.IsExistingMatchingCard(s.spfilter1, tp, LOCATION_HAND, 0, 1, nil, e, tp, zone)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spfilter2(c, e, tp, rac)
  	return c:IsRace(rac) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local zone = c:GetLinkedZone(1 - tp)
  	if Duel.GetLocationCount(1 - tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local tc = Duel.SelectMatchingCard(tp, s.spfilter1, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, zone):GetFirst()
  	if tc and Duel.SpecialSummonStep(tc, 0, tp, 1 - tp, false, false, POS_FACEUP_DEFENSE, zone) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetValue(RESET_TURN_SET)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		tc:RegisterEffect(e2)
  		Duel.SpecialSummonComplete()
  		local g = Duel.GetMatchingGroup(s.spfilter2, tp, LOCATION_DECK, 0, nil, e, tp, tc:GetRace())
  		if #g > 0 and Duel.GetMZoneCount(tp) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  			local sc = g:Select(tp, 1, 1, nil):GetFirst()
  			if Duel.SpecialSummonStep(sc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE) then
  				local e1 = Effect.CreateEffect(c)
  				e1:SetType(EFFECT_TYPE_SINGLE)
  				e1:SetCode(EFFECT_DISABLE)
  				e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  				sc:RegisterEffect(e1)
  				local e2 = Effect.CreateEffect(c)
  				e2:SetType(EFFECT_TYPE_SINGLE)
  				e2:SetCode(EFFECT_DISABLE_EFFECT)
  				e2:SetValue(RESET_TURN_SET)
  				e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  				sc:RegisterEffect(e2)
  				local e3 = Effect.CreateEffect(c)
  				e3:SetType(EFFECT_TYPE_FIELD)
  				e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  				e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  				e3:SetTargetRange(1, 0)
  				e3:SetTarget(s.splimit)
  				e3:SetLabel(sc:GetOriginalRace())
  				e3:SetReset(RESET_PHASE + PHASE_END)
  				Duel.RegisterEffect(e3, tp)
  				Duel.SpecialSummonComplete()
  			end
  		end
  	end
  end
  function s.splimit(e, c)
  	return c:GetOriginalRace() & e:GetLabel() == 0
  end
  
  