name: Deskbot
card_text: All "Deskbot" monsters on the field gain 500 ATK and DEF. Once per turn: You can reveal any number of "Deskbot" cards in your hand and shuffle them into the Deck, then draw the same number of cards. You can banish 9 "Deskbot" cards with different names from your field and/or Graveyard, except "Deskbot Base"; shuffle all cards from your opponent's hand, field and Graveyard into the Deck.
external_ids: local SETCARD_ID_0 = 0xab --Deskbot
  
lua: local SETCARD_ID_0 = 0xab --Deskbot
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  	--defup
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	--draw
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCountLimit(1)
  	e4:SetRange(LOCATION_FZONE)
  	e4:SetTarget(s.target)
  	e4:SetOperation(s.operation)
  	c:RegisterEffect(e4)
  	--todeck
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_TODECK)
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetRange(LOCATION_FZONE)
  	e5:SetCost(s.cost2)
  	e5:SetTarget(s.target2)
  	e5:SetOperation(s.operation2)
  	c:RegisterEffect(e5)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToDeck() and not c:IsPublic()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Hint(HINT_SELECTMSG, p, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(p, s.filter, p, LOCATION_HAND, 0, 1, 99, nil)
  	if g:GetCount() > 0 then
  		Duel.ConfirmCards(1 - p, g)
  		local ct = Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		Duel.ShuffleDeck(p)
  		Duel.BreakEffect()
  		Duel.Draw(p, ct, REASON_EFFECT)
  		Duel.ShuffleHand(p)
  	end
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost() and not c:IsCode(id) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
  end
  function s.cost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE + LOCATION_ONFIELD, 0, nil)
  	if chk == 0 then
  		return g:GetClassCount(Card.GetCode) >= 9
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	aux.GCheckAdditional = aux.dncheck
  	local rg = g:SelectSubGroup(tp, aux.TRUE, false, 9, 9)
  	aux.GCheckAdditional = nil
  	Duel.Remove(rg, POS_FACEUP, REASON_COST)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(Card.IsAbleToDeck, tp, 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE)
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsAbleToDeck, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_HAND, nil)
  	if aux.NecroValleyNegateCheck(g) then
  		return
  	end
  	if g:GetCount() > 0 then
  		Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	end
  end
  
  
source_text: Deskbot
  All "Deskbot" monsters on the field gain 500 ATK and DEF. Once per turn: You can reveal any number of "Deskbot" cards in your hand and shuffle them into the Deck, then draw the same number of cards. You can banish 9 "Deskbot" cards with different names from your field and/or Graveyard, except "Deskbot Base"; shuffle all cards from your opponent's hand, field and Graveyard into the Deck.
target_text: -- Deskbot
  local SETCARD_ID_0 = 0xab --Deskbot
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  	--defup
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	--draw
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_TODECK + CATEGORY_DRAW)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetCountLimit(1)
  	e4:SetRange(LOCATION_FZONE)
  	e4:SetTarget(s.target)
  	e4:SetOperation(s.operation)
  	c:RegisterEffect(e4)
  	--todeck
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 1))
  	e5:SetCategory(CATEGORY_TODECK)
  	e5:SetType(EFFECT_TYPE_IGNITION)
  	e5:SetRange(LOCATION_FZONE)
  	e5:SetCost(s.cost2)
  	e5:SetTarget(s.target2)
  	e5:SetOperation(s.operation2)
  	c:RegisterEffect(e5)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToDeck() and not c:IsPublic()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp) and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local p = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER)
  	Duel.Hint(HINT_SELECTMSG, p, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(p, s.filter, p, LOCATION_HAND, 0, 1, 99, nil)
  	if g:GetCount() > 0 then
  		Duel.ConfirmCards(1 - p, g)
  		local ct = Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  		Duel.ShuffleDeck(p)
  		Duel.BreakEffect()
  		Duel.Draw(p, ct, REASON_EFFECT)
  		Duel.ShuffleHand(p)
  	end
  end
  function s.cfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemoveAsCost() and not c:IsCode(id) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
  end
  function s.cost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	local g = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_GRAVE + LOCATION_ONFIELD, 0, nil)
  	if chk == 0 then
  		return g:GetClassCount(Card.GetCode) >= 9
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	aux.GCheckAdditional = aux.dncheck
  	local rg = g:SelectSubGroup(tp, aux.TRUE, false, 9, 9)
  	aux.GCheckAdditional = nil
  	Duel.Remove(rg, POS_FACEUP, REASON_COST)
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToDeck, tp, 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(Card.IsAbleToDeck, tp, 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, LOCATION_HAND + LOCATION_ONFIELD + LOCATION_GRAVE)
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsAbleToDeck, tp, 0, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_HAND, nil)
  	if aux.NecroValleyNegateCheck(g) then
  		return
  	end
  	if g:GetCount() > 0 then
  		Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	end
  end
  
  