name: Arms
card_text: 1 DARK Tuner + 1+ non-Tuner monsters
  When your opponent activates a monster effect (Quick Effect): You can banish 1 monster from your GY with the same Attribute; negate the activation, and if you do, destroy that monster. (You can only banish each Attribute once per turn to activate this effect of "Arms of Genex Return Zero".) Once per turn: You can target up to 6 of your "Genex" monsters with different Attributes that are banished and/or in your GY; shuffle them into the Deck, then you can destroy up to that many cards in the Spell & Trap Zones.
external_ids: local SETCARD_ID_0 = 0x2 --Genex
  
lua: local SETCARD_ID_0 = 0x2 --Genex
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsAttribute, ATTRIBUTE_DARK), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--negate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.ngcon)
  	e1:SetCost(s.ngcost)
  	e1:SetTarget(s.ngtg)
  	e1:SetOperation(s.ngop)
  	c:RegisterEffect(e1)
  	--back deck and destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_TODECK + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.tdtg)
  	e2:SetOperation(s.tdop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, att)
  	return c:IsAbleToRemoveAsCost() and c:IsAttribute(att)
  end
  function s.ngcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and re:IsActiveType(TYPE_MONSTER) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev)
  end
  function s.ngcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local att = re:GetHandler():GetAttribute()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil, att)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, att)
  	e:SetLabel(g:GetFirst():GetAttribute())
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_REMOVE)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.rmlimit)
  	e1:SetLabel(e:GetLabel())
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.ngtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.ngop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  function s.rmlimit(e, c, tp, r, re)
  	return c:IsAttribute(e:GetLabel()) and re and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsCode(id) and r == REASON_COST
  end
  function s.tdfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToDeck() and c:IsFaceup()
  end
  function s.desfilter(c)
  	return c:GetSequence() < 5
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.tdfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.tdfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local sg = g:SelectSubGroup(tp, aux.dabcheck, false, 1, 6)
  	Duel.SetTargetCard(sg)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, sg, sg:GetCount(), 0, 0)
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetTargetsRelateToChain()
  	if #tg == 0 then
  		return
  	end
  	Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local g = Duel.GetOperatedGroup()
  	local ct = g:GetCount()
  	local dg = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_SZONE, LOCATION_SZONE, nil)
  	if ct > 0 and dg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local sg2 = dg:Select(tp, 1, ct, nil)
  		Duel.HintSelection(sg2)
  		Duel.Destroy(sg2, REASON_EFFECT)
  	end
  end
  
  
source_text: Arms
  1 DARK Tuner + 1+ non-Tuner monsters
  When your opponent activates a monster effect (Quick Effect): You can banish 1 monster from your GY with the same Attribute; negate the activation, and if you do, destroy that monster. (You can only banish each Attribute once per turn to activate this effect of "Arms of Genex Return Zero".) Once per turn: You can target up to 6 of your "Genex" monsters with different Attributes that are banished and/or in your GY; shuffle them into the Deck, then you can destroy up to that many cards in the Spell & Trap Zones.
target_text: -- Arms
  local SETCARD_ID_0 = 0x2 --Genex
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, aux.FilterBoolFunction(Card.IsAttribute, ATTRIBUTE_DARK), aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--negate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_NEGATE + CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DAMAGE_CAL)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetCondition(s.ngcon)
  	e1:SetCost(s.ngcost)
  	e1:SetTarget(s.ngtg)
  	e1:SetOperation(s.ngop)
  	c:RegisterEffect(e1)
  	--back deck and destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_TODECK + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.tdtg)
  	e2:SetOperation(s.tdop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c, att)
  	return c:IsAbleToRemoveAsCost() and c:IsAttribute(att)
  end
  function s.ngcon(e, tp, eg, ep, ev, re, r, rp)
  	return rp == 1 - tp and re:IsActiveType(TYPE_MONSTER) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev)
  end
  function s.ngcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local att = re:GetHandler():GetAttribute()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil, att)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, att)
  	e:SetLabel(g:GetFirst():GetAttribute())
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetCode(EFFECT_CANNOT_REMOVE)
  	e1:SetTargetRange(1, 0)
  	e1:SetTarget(s.rmlimit)
  	e1:SetLabel(e:GetLabel())
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.ngtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_NEGATE, eg, 1, 0, 0)
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, eg, 1, 0, 0)
  	end
  end
  function s.ngop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  function s.rmlimit(e, c, tp, r, re)
  	return c:IsAttribute(e:GetLabel()) and re and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsCode(id) and r == REASON_COST
  end
  function s.tdfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToDeck() and c:IsFaceup()
  end
  function s.desfilter(c)
  	return c:GetSequence() < 5
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.tdfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.tdfilter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local sg = g:SelectSubGroup(tp, aux.dabcheck, false, 1, 6)
  	Duel.SetTargetCard(sg)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, sg, sg:GetCount(), 0, 0)
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetTargetsRelateToChain()
  	if #tg == 0 then
  		return
  	end
  	Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local g = Duel.GetOperatedGroup()
  	local ct = g:GetCount()
  	local dg = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_SZONE, LOCATION_SZONE, nil)
  	if ct > 0 and dg:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  		local sg2 = dg:Select(tp, 1, ct, nil)
  		Duel.HintSelection(sg2)
  		Duel.Destroy(sg2, REASON_EFFECT)
  	end
  end
  
  