name: Arc
card_text: 3 Level 5 monsters
  This Xyz Summoned card cannot be destroyed by card effects. You can detach 1 material from this card; this card gains ATK equal to the total original ATK of all other monsters on the field, then, if this card has a DARK Xyz Monster as material, negate the effects of all other face-up monsters on the field. After this effect resolves, you cannot declare attacks with other monsters for the rest of this turn. You can only use this effect of "Arc Rebellion Xyz Dragon" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e1:SetCondition(s.indcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.indcon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler()):GetSum(Card.GetBaseAttack) > 0
  	end
  end
  function s.mgfilter(c)
  	return c:IsType(TYPE_XYZ) and c:IsAttribute(ATTRIBUTE_DARK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local atk = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, c):GetSum(Card.GetBaseAttack)
  		if atk > 0 then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  			e1:SetValue(atk)
  			c:RegisterEffect(e1)
  			local mg = c:GetOverlayGroup()
  			if mg:IsExists(s.mgfilter, 1, nil) then
  				local g = Duel.GetMatchingGroup(aux.NegateMonsterFilter, tp, LOCATION_MZONE, LOCATION_MZONE, c)
  				for tc in aux.Next(g) do
  					local e2 = Effect.CreateEffect(c)
  					e2:SetType(EFFECT_TYPE_SINGLE)
  					e2:SetCode(EFFECT_DISABLE)
  					e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  					tc:RegisterEffect(e2)
  					local e3 = Effect.CreateEffect(c)
  					e3:SetType(EFFECT_TYPE_SINGLE)
  					e3:SetCode(EFFECT_DISABLE_EFFECT)
  					e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  					tc:RegisterEffect(e3)
  				end
  			end
  		end
  	end
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_FIELD)
  	e0:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e0:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e0:SetTargetRange(LOCATION_MZONE, 0)
  	e0:SetTarget(s.ftarget)
  	e0:SetLabel(c:GetFieldID())
  	e0:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e0, tp)
  end
  function s.ftarget(e, c)
  	return e:GetLabel() ~= c:GetFieldID()
  end
  
  
source_text: Arc
  3 Level 5 monsters
  This Xyz Summoned card cannot be destroyed by card effects. You can detach 1 material from this card; this card gains ATK equal to the total original ATK of all other monsters on the field, then, if this card has a DARK Xyz Monster as material, negate the effects of all other face-up monsters on the field. After this effect resolves, you cannot declare attacks with other monsters for the rest of this turn. You can only use this effect of "Arc Rebellion Xyz Dragon" once per turn.
target_text: -- Arc
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 5, 3)
  	c:EnableReviveLimit()
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e1:SetCondition(s.indcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.indcon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_XYZ)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, e:GetHandler()):GetSum(Card.GetBaseAttack) > 0
  	end
  end
  function s.mgfilter(c)
  	return c:IsType(TYPE_XYZ) and c:IsAttribute(ATTRIBUTE_DARK)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsFaceup() and c:IsRelateToEffect(e) then
  		local atk = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, c):GetSum(Card.GetBaseAttack)
  		if atk > 0 then
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_UPDATE_ATTACK)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  			e1:SetValue(atk)
  			c:RegisterEffect(e1)
  			local mg = c:GetOverlayGroup()
  			if mg:IsExists(s.mgfilter, 1, nil) then
  				local g = Duel.GetMatchingGroup(aux.NegateMonsterFilter, tp, LOCATION_MZONE, LOCATION_MZONE, c)
  				for tc in aux.Next(g) do
  					local e2 = Effect.CreateEffect(c)
  					e2:SetType(EFFECT_TYPE_SINGLE)
  					e2:SetCode(EFFECT_DISABLE)
  					e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  					tc:RegisterEffect(e2)
  					local e3 = Effect.CreateEffect(c)
  					e3:SetType(EFFECT_TYPE_SINGLE)
  					e3:SetCode(EFFECT_DISABLE_EFFECT)
  					e3:SetReset(RESET_EVENT + RESETS_STANDARD)
  					tc:RegisterEffect(e3)
  				end
  			end
  		end
  	end
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_FIELD)
  	e0:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e0:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e0:SetTargetRange(LOCATION_MZONE, 0)
  	e0:SetTarget(s.ftarget)
  	e0:SetLabel(c:GetFieldID())
  	e0:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e0, tp)
  end
  function s.ftarget(e, c)
  	return e:GetLabel() ~= c:GetFieldID()
  end
  
  