name: Numbers
card_text: If your opponent controls a monster(s) Special Summoned from the Extra Deck and you do not: Choose 4 "Number" Xyz Monsters from your Extra Deck with different Ranks, plus a 5th "Number" Xyz Monster whose "Number" value in its name equals the combined "Number" values of the 4 other monsters, Special Summon that 5th "Number" monster (this is treated as an Xyz Summon), and attach the 4 chosen monsters to it as material, but you cannot Special Summon monsters, except "Number" Xyz Monsters, while you control that face-up monster.
external_ids: local SETCARD_ID_0 = 0x48 --Number
  
lua: local SETCARD_ID_0 = 0x48 --Number
  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:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.cfilter, tp, 0, LOCATION_MZONE, 1, nil)
  end
  function s.nofilter(c)
  	return c:IsType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0) and aux.GetXyzNumber(c)
  end
  function s.spfilter(c, e, tp)
  	return s.nofilter(c) and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.gselect(g, spg)
  	return spg:IsExists(s.spnofilter, 1, g, g:GetSum(aux.GetXyzNumber))
  end
  function s.spnofilter(c, sum)
  	return aux.GetXyzNumber(c) == sum
  end
  function s.gcheck(max)
  	return function(g)
  		return g:GetClassCount(Card.GetRank) == #g and g:GetSum(aux.GetXyzNumber) <= max
  	end
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		if not aux.MustMaterialCheck(nil, tp, EFFECT_MUST_BE_XMATERIAL) then
  			return false
  		end
  		local mg = Duel.GetMatchingGroup(s.nofilter, tp, LOCATION_EXTRA, 0, nil)
  		local spg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
  		if #mg < 5 or #spg == 0 then
  			return false
  		end
  		local _, max = spg:GetMaxGroup(aux.GetXyzNumber)
  		aux.GCheckAdditional = s.gcheck(max)
  		local res = mg:CheckSubGroup(s.gselect, 4, 4, spg)
  		aux.GCheckAdditional = nil
  		return res
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if not aux.MustMaterialCheck(nil, tp, EFFECT_MUST_BE_XMATERIAL) then
  		return
  	end
  	local mg = Duel.GetMatchingGroup(s.nofilter, tp, LOCATION_EXTRA, 0, nil)
  	local spg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
  	if #mg < 5 or #spg == 0 then
  		return
  	end
  	local _, max = spg:GetMaxGroup(aux.GetXyzNumber)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	aux.GCheckAdditional = s.gcheck(max)
  	local sg = mg:SelectSubGroup(tp, s.gselect, false, 4, 4, spg)
  	aux.GCheckAdditional = nil
  	if sg then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local xyz = spg:FilterSelect(tp, s.spnofilter, 1, 1, sg, sg:GetSum(aux.GetXyzNumber)):GetFirst()
  		xyz:SetMaterial(nil)
  		Duel.SpecialSummon(xyz, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  		xyz:CompleteProcedure()
  		Duel.Overlay(xyz, sg)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetAbsoluteRange(tp, 1, 0)
  		e1:SetCondition(s.splimitcon)
  		e1:SetTarget(s.splimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		xyz:RegisterEffect(e1, true)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(63060238)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetAbsoluteRange(tp, 1, 0)
  		e2:SetCondition(s.splimitcon)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		xyz:RegisterEffect(e2, true)
  	end
  end
  function s.splimitcon(e)
  	return e:GetHandler():IsControler(e:GetOwnerPlayer())
  end
  function s.splimit(e, c)
  	return not s.nofilter(c)
  end
  
  
source_text: Numbers
  If your opponent controls a monster(s) Special Summoned from the Extra Deck and you do not: Choose 4 "Number" Xyz Monsters from your Extra Deck with different Ranks, plus a 5th "Number" Xyz Monster whose "Number" value in its name equals the combined "Number" values of the 4 other monsters, Special Summon that 5th "Number" monster (this is treated as an Xyz Summon), and attach the 4 chosen monsters to it as material, but you cannot Special Summon monsters, except "Number" Xyz Monsters, while you control that face-up monster.
target_text: -- Numbers
  local SETCARD_ID_0 = 0x48 --Number
  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:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c)
  	return c:IsSummonLocation(LOCATION_EXTRA)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingMatchingCard(s.cfilter, tp, 0, LOCATION_MZONE, 1, nil)
  end
  function s.nofilter(c)
  	return c:IsType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0) and aux.GetXyzNumber(c)
  end
  function s.spfilter(c, e, tp)
  	return s.nofilter(c) and c:IsCanBeSpecialSummoned(e, SUMMON_TYPE_XYZ, tp, false, false) and Duel.GetLocationCountFromEx(tp, tp, nil, c) > 0
  end
  function s.gselect(g, spg)
  	return spg:IsExists(s.spnofilter, 1, g, g:GetSum(aux.GetXyzNumber))
  end
  function s.spnofilter(c, sum)
  	return aux.GetXyzNumber(c) == sum
  end
  function s.gcheck(max)
  	return function(g)
  		return g:GetClassCount(Card.GetRank) == #g and g:GetSum(aux.GetXyzNumber) <= max
  	end
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		if not aux.MustMaterialCheck(nil, tp, EFFECT_MUST_BE_XMATERIAL) then
  			return false
  		end
  		local mg = Duel.GetMatchingGroup(s.nofilter, tp, LOCATION_EXTRA, 0, nil)
  		local spg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
  		if #mg < 5 or #spg == 0 then
  			return false
  		end
  		local _, max = spg:GetMaxGroup(aux.GetXyzNumber)
  		aux.GCheckAdditional = s.gcheck(max)
  		local res = mg:CheckSubGroup(s.gselect, 4, 4, spg)
  		aux.GCheckAdditional = nil
  		return res
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if not aux.MustMaterialCheck(nil, tp, EFFECT_MUST_BE_XMATERIAL) then
  		return
  	end
  	local mg = Duel.GetMatchingGroup(s.nofilter, tp, LOCATION_EXTRA, 0, nil)
  	local spg = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_EXTRA, 0, nil, e, tp)
  	if #mg < 5 or #spg == 0 then
  		return
  	end
  	local _, max = spg:GetMaxGroup(aux.GetXyzNumber)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_XMATERIAL)
  	aux.GCheckAdditional = s.gcheck(max)
  	local sg = mg:SelectSubGroup(tp, s.gselect, false, 4, 4, spg)
  	aux.GCheckAdditional = nil
  	if sg then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local xyz = spg:FilterSelect(tp, s.spnofilter, 1, 1, sg, sg:GetSum(aux.GetXyzNumber)):GetFirst()
  		xyz:SetMaterial(nil)
  		Duel.SpecialSummon(xyz, SUMMON_TYPE_XYZ, tp, tp, false, false, POS_FACEUP)
  		xyz:CompleteProcedure()
  		Duel.Overlay(xyz, sg)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetAbsoluteRange(tp, 1, 0)
  		e1:SetCondition(s.splimitcon)
  		e1:SetTarget(s.splimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		xyz:RegisterEffect(e1, true)
  		local e2 = Effect.CreateEffect(e:GetHandler())
  		e2:SetType(EFFECT_TYPE_FIELD)
  		e2:SetCode(63060238)
  		e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e2:SetRange(LOCATION_MZONE)
  		e2:SetAbsoluteRange(tp, 1, 0)
  		e2:SetCondition(s.splimitcon)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		xyz:RegisterEffect(e2, true)
  	end
  end
  function s.splimitcon(e)
  	return e:GetHandler():IsControler(e:GetOwnerPlayer())
  end
  function s.splimit(e, c)
  	return not s.nofilter(c)
  end
  
  