name: Forbidden
card_text: If you control exactly 2 monster card types (among Fusion, Synchro, and/or Xyz): Apply the following effect based on those types.
  ● Fusion and Synchro: Special Summon 1 "Outer Entity" Xyz Monster from your Extra Deck, and if you do, attach this card to it as material.
  ● Synchro and Xyz: Special Summon 1 "Elder Entity" Fusion Monster from your Extra Deck.
  ● Xyz and Fusion: Special Summon 1 "Old Entity" Synchro Monster from your Extra Deck.
  You can only activate 1 "Forbidden Trapezohedron" per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, tpe)
  	return c:IsFaceup() and c:IsType(tpe)
  end
  function s.filter(c, e, tp, cat)
  	return c:IsSetCard(cat) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local flag = 0
  		if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_FUSION) then
  			flag = flag + 1
  		end
  		if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_SYNCHRO) then
  			flag = flag + 2
  		end
  		if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_XYZ) then
  			flag = flag + 4
  		end
  		if flag == 3 then
  			return e:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, 0xb6) and e:GetHandler():IsCanOverlay()
  		elseif flag == 6 then
  			return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, 0xb7)
  		elseif flag == 5 then
  			return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, 0xb8)
  		else
  			return false
  		end
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local flag = 0
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_FUSION) then
  		flag = flag + 1
  	end
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_SYNCHRO) then
  		flag = flag + 2
  	end
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_XYZ) then
  		flag = flag + 4
  	end
  	if flag == 3 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, 0xb6)
  		local sc = g:GetFirst()
  		if sc then
  			Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP)
  			local c = e:GetHandler()
  			if c:IsRelateToEffect(e) and c:IsCanOverlay() then
  				c:CancelToGrave()
  				Duel.Overlay(sc, Group.FromCards(c))
  			end
  		end
  	elseif flag == 6 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, 0xb7)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	elseif flag == 5 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, 0xb8)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Forbidden
  If you control exactly 2 monster card types (among Fusion, Synchro, and/or Xyz): Apply the following effect based on those types.
  ● Fusion and Synchro: Special Summon 1 "Outer Entity" Xyz Monster from your Extra Deck, and if you do, attach this card to it as material.
  ● Synchro and Xyz: Special Summon 1 "Elder Entity" Fusion Monster from your Extra Deck.
  ● Xyz and Fusion: Special Summon 1 "Old Entity" Synchro Monster from your Extra Deck.
  You can only activate 1 "Forbidden Trapezohedron" per turn.
target_text: -- Forbidden
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, tpe)
  	return c:IsFaceup() and c:IsType(tpe)
  end
  function s.filter(c, e, tp, cat)
  	return c:IsSetCard(cat) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local flag = 0
  		if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_FUSION) then
  			flag = flag + 1
  		end
  		if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_SYNCHRO) then
  			flag = flag + 2
  		end
  		if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_XYZ) then
  			flag = flag + 4
  		end
  		if flag == 3 then
  			return e:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, 0xb6) and e:GetHandler():IsCanOverlay()
  		elseif flag == 6 then
  			return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, 0xb7)
  		elseif flag == 5 then
  			return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp, 0xb8)
  		else
  			return false
  		end
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local flag = 0
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_FUSION) then
  		flag = flag + 1
  	end
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_SYNCHRO) then
  		flag = flag + 2
  	end
  	if Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil, TYPE_XYZ) then
  		flag = flag + 4
  	end
  	if flag == 3 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, 0xb6)
  		local sc = g:GetFirst()
  		if sc then
  			Duel.SpecialSummon(sc, 0, tp, tp, false, false, POS_FACEUP)
  			local c = e:GetHandler()
  			if c:IsRelateToEffect(e) and c:IsCanOverlay() then
  				c:CancelToGrave()
  				Duel.Overlay(sc, Group.FromCards(c))
  			end
  		end
  	elseif flag == 6 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, 0xb7)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	elseif flag == 5 then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_EXTRA, 0, 1, 1, nil, e, tp, 0xb8)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  