name: Number
card_text: 2 Level 7 monsters
  Once per turn: You can detach 2 Xyz Materials from this card; Special Summon as many "Battle Eagle Tokens" (Machine-Type/WIND/Level 6/ATK 2000/DEF 0) as possible, destroy them during the End Phase of this turn, also your opponent takes no further battle damage this turn.
external_ids: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 10389143 --Battle Eagle Token
  
lua: local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 10389143 --Battle Eagle Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 7, 2)
  	c:EnableReviveLimit()
  	--token
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  aux.xyz_number[id] = 42
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 2, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 2, 2, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 0, 6, RACE_MACHINE, ATTRIBUTE_WIND)
  	end
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, ft, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, ft, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local e0 = Effect.CreateEffect(e:GetHandler())
  	e0:SetType(EFFECT_TYPE_FIELD)
  	e0:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e0:SetTargetRange(0, 1)
  	e0:SetValue(1)
  	e0:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e0, tp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 0, 6, RACE_MACHINE, ATTRIBUTE_WIND) then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	local fid = e:GetHandler():GetFieldID()
  	local g = Group.CreateGroup()
  	for i = 1, ft do
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  		token:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1, fid)
  		g:AddCard(token)
  	end
  	Duel.SpecialSummonComplete()
  	g:KeepAlive()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetLabel(fid)
  	e1:SetLabelObject(g)
  	e1:SetCondition(s.descon)
  	e1:SetOperation(s.desop)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.desfilter(c, fid)
  	return c:GetFlagEffectLabel(id) == fid
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	if not g:IsExists(s.desfilter, 1, nil, e:GetLabel()) then
  		g:DeleteGroup()
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	local tg = g:Filter(s.desfilter, nil, e:GetLabel())
  	g:DeleteGroup()
  	Duel.Destroy(tg, REASON_EFFECT)
  end
  
  
source_text: Number
  2 Level 7 monsters
  Once per turn: You can detach 2 Xyz Materials from this card; Special Summon as many "Battle Eagle Tokens" (Machine-Type/WIND/Level 6/ATK 2000/DEF 0) as possible, destroy them during the End Phase of this turn, also your opponent takes no further battle damage this turn.
target_text: -- Number
  local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
  local CARD_ID_1 = 10389143 --Battle Eagle Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 7, 2)
  	c:EnableReviveLimit()
  	--token
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  aux.xyz_number[id] = 42
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 2, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 2, 2, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 0, 6, RACE_MACHINE, ATTRIBUTE_WIND)
  	end
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, ft, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, ft, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local e0 = Effect.CreateEffect(e:GetHandler())
  	e0:SetType(EFFECT_TYPE_FIELD)
  	e0:SetCode(EFFECT_AVOID_BATTLE_DAMAGE)
  	e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e0:SetTargetRange(0, 1)
  	e0:SetValue(1)
  	e0:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e0, tp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if ft <= 0 or not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 2000, 0, 6, RACE_MACHINE, ATTRIBUTE_WIND) then
  		return
  	end
  	if Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) then
  		ft = 1
  	end
  	local fid = e:GetHandler():GetFieldID()
  	local g = Group.CreateGroup()
  	for i = 1, ft do
  		local token = Duel.CreateToken(tp, id + 1)
  		Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP)
  		token:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1, fid)
  		g:AddCard(token)
  	end
  	Duel.SpecialSummonComplete()
  	g:KeepAlive()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	e1:SetCountLimit(1)
  	e1:SetLabel(fid)
  	e1:SetLabelObject(g)
  	e1:SetCondition(s.descon)
  	e1:SetOperation(s.desop)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.desfilter(c, fid)
  	return c:GetFlagEffectLabel(id) == fid
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	if not g:IsExists(s.desfilter, 1, nil, e:GetLabel()) then
  		g:DeleteGroup()
  		e:Reset()
  		return false
  	else
  		return true
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = e:GetLabelObject()
  	local tg = g:Filter(s.desfilter, nil, e:GetLabel())
  	g:DeleteGroup()
  	Duel.Destroy(tg, REASON_EFFECT)
  end
  
  