Number
2+ "Number" Xyz Monsters, with the same Rank, that have material
Once per turn: You can Special Summon Rank 9 or lower "Number" monsters with 3000 or less ATK that have different Ranks from each other from your Extra Deck, up to the number of materials with different names attached to this card, but their effects are negated, then detach 1 material from this card. For the rest of this turn, unless this effect was negated, you cannot Special Summon, and any battle damage your opponent takes becomes halved. While you control another "Number" Xyz Monster, this card cannot be destroyed by battle or card effects.
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 29724053 --Summon Gate
local SETCARD_ID_0 = 0x48 --Number

local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 29724053 --Summon Gate
local SETCARD_ID_0 = 0x48 --Number
local s, id, o = GetID()
function s.initial_effect(c)
	--xyz summon
	c:EnableReviveLimit()
	aux.AddXyzProcedureLevelFree(c, s.mfilter, s.xyzcheck, 2, 99)
	--spsummon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCountLimit(1)
	e2:SetTarget(s.target)
	e2:SetOperation(s.operation)
	c:RegisterEffect(e2)
	--indestructable
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_SINGLE)
	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
	e3:SetCondition(s.indcon)
	e3:SetValue(1)
	c:RegisterEffect(e3)
	local e4 = e3:Clone()
	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	c:RegisterEffect(e4)
end
aux.xyz_number[id] = 93
function s.mfilter(c, xyzc)
	return c:IsXyzType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0) and c:GetOverlayCount() > 0
end
function s.xyzcheck(g)
	return g:GetClassCount(Card.GetRank) == 1
end
function s.filter(c, e, tp)
	return c:IsRankBelow(9) and c:IsAttackBelow(3000) and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():GetOverlayCount() > 0 and Duel.GetLocationCountFromEx(tp, tp, nil, TYPE_XYZ) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
end
function s.gfilter(c, rank)
	return c:IsRank(rank)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local ft = Duel.GetLocationCountFromEx(tp, tp, nil, TYPE_XYZ)
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		ft = 1
	end
	local ect = c29724053 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_1) and c29724053[tp]
	if ect ~= nil then
		ft = math.min(ft, ect)
	end
	local c = e:GetHandler()
	local g1 = Duel.GetMatchingGroup(s.filter, tp, LOCATION_EXTRA, 0, nil, e, tp)
	local ct = c:GetOverlayGroup():GetClassCount(Card.GetCode)
	if ct > ft then
		ct = ft
	end
	if g1:GetCount() > 0 and ct > 0 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
		aux.GCheckAdditional = aux.drkcheck
		local g2 = g1:SelectSubGroup(tp, aux.TRUE, false, 1, ct)
		aux.GCheckAdditional = nil
		for tc in aux.Next(g2) do
			Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
			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)
		end
		Duel.SpecialSummonComplete()
		Duel.BreakEffect()
		c:RemoveOverlayCard(tp, 1, 1, REASON_EFFECT)
	end
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e3:SetTargetRange(0, 1)
	e3:SetValue(HALF_DAMAGE)
	e3:SetReset(RESET_PHASE + PHASE_END)
	Duel.RegisterEffect(e3, tp)
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_FIELD)
	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e4:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e4:SetReset(RESET_PHASE + PHASE_END)
	e4:SetTargetRange(1, 0)
	Duel.RegisterEffect(e4, tp)
end
function s.indfilter(c)
	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0)
end
function s.indcon(e)
	return Duel.IsExistingMatchingCard(s.indfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, e:GetHandler())
end


Number
2+ "Number" Xyz Monsters, with the same Rank, that have material
Once per turn: You can Special Summon Rank 9 or lower "Number" monsters with 3000 or less ATK that have different Ranks from each other from your Extra Deck, up to the number of materials with different names attached to this card, but their effects are negated, then detach 1 material from this card. For the rest of this turn, unless this effect was negated, you cannot Special Summon, and any battle damage your opponent takes becomes halved. While you control another "Number" Xyz Monster, this card cannot be destroyed by battle or card effects.
-- Number
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local CARD_ID_1 = 29724053 --Summon Gate
local SETCARD_ID_0 = 0x48 --Number
local s, id, o = GetID()
function s.initial_effect(c)
	--xyz summon
	c:EnableReviveLimit()
	aux.AddXyzProcedureLevelFree(c, s.mfilter, s.xyzcheck, 2, 99)
	--spsummon
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e2:SetType(EFFECT_TYPE_IGNITION)
	e2:SetRange(LOCATION_MZONE)
	e2:SetCountLimit(1)
	e2:SetTarget(s.target)
	e2:SetOperation(s.operation)
	c:RegisterEffect(e2)
	--indestructable
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_SINGLE)
	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
	e3:SetCondition(s.indcon)
	e3:SetValue(1)
	c:RegisterEffect(e3)
	local e4 = e3:Clone()
	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
	c:RegisterEffect(e4)
end
aux.xyz_number[id] = 93
function s.mfilter(c, xyzc)
	return c:IsXyzType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0) and c:GetOverlayCount() > 0
end
function s.xyzcheck(g)
	return g:GetClassCount(Card.GetRank) == 1
end
function s.filter(c, e, tp)
	return c:IsRankBelow(9) and c:IsAttackBelow(3000) and c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return e:GetHandler():GetOverlayCount() > 0 and Duel.GetLocationCountFromEx(tp, tp, nil, TYPE_XYZ) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_EXTRA, 0, 1, nil, e, tp)
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_EXTRA)
end
function s.gfilter(c, rank)
	return c:IsRank(rank)
end
function s.operation(e, tp, eg, ep, ev, re, r, rp)
	local ft = Duel.GetLocationCountFromEx(tp, tp, nil, TYPE_XYZ)
	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
		ft = 1
	end
	local ect = c29724053 and Duel.IsPlayerAffectedByEffect(tp, CARD_ID_1) and c29724053[tp]
	if ect ~= nil then
		ft = math.min(ft, ect)
	end
	local c = e:GetHandler()
	local g1 = Duel.GetMatchingGroup(s.filter, tp, LOCATION_EXTRA, 0, nil, e, tp)
	local ct = c:GetOverlayGroup():GetClassCount(Card.GetCode)
	if ct > ft then
		ct = ft
	end
	if g1:GetCount() > 0 and ct > 0 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
		aux.GCheckAdditional = aux.drkcheck
		local g2 = g1:SelectSubGroup(tp, aux.TRUE, false, 1, ct)
		aux.GCheckAdditional = nil
		for tc in aux.Next(g2) do
			Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
			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)
		end
		Duel.SpecialSummonComplete()
		Duel.BreakEffect()
		c:RemoveOverlayCard(tp, 1, 1, REASON_EFFECT)
	end
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_CHANGE_BATTLE_DAMAGE)
	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e3:SetTargetRange(0, 1)
	e3:SetValue(HALF_DAMAGE)
	e3:SetReset(RESET_PHASE + PHASE_END)
	Duel.RegisterEffect(e3, tp)
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_FIELD)
	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e4:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e4:SetReset(RESET_PHASE + PHASE_END)
	e4:SetTargetRange(1, 0)
	Duel.RegisterEffect(e4, tp)
end
function s.indfilter(c)
	return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(SETCARD_ID_0)
end
function s.indcon(e)
	return Duel.IsExistingMatchingCard(s.indfilter, e:GetHandlerPlayer(), LOCATION_MZONE, 0, 1, e:GetHandler())
end

