name: Cyber
card_text: You can activate 1 of these effects.
  ● When this card is targeted for an attack: You can banish this card; draw 1 card, then end the Battle Phase.
  ● You can target 1 face-up monster you control and this card; banish both those targets, then draw 2 cards.
  ● You can target 1 card in your GY; banish both this card and 1 card from your hand, then place that target on top of the Deck.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--be target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCost(s.cost1)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.operation1)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.operation2)
  	c:RegisterEffect(e2)
  	--salvage
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_TODECK)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTarget(s.target3)
  	e3:SetOperation(s.operation3)
  	c:RegisterEffect(e3)
  end
  function s.cost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToRemoveAsCost()
  	end
  	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_COST)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation1(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.Draw(tp, 1, REASON_EFFECT) > 0 then
  		Duel.BreakEffect()
  		Duel.SkipPhase(1 - tp, PHASE_BATTLE, RESET_PHASE + PHASE_BATTLE_STEP, 1)
  	end
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter2(chkc)
  	end
  	if chk == 0 then
  		return c:IsAbleToRemove() and Duel.IsPlayerCanDraw(tp, 2) and Duel.IsExistingTarget(s.filter2, tp, LOCATION_MZONE, 0, 1, c) and c:IsCanBeEffectTarget()
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, c)
  	g:AddCard(c)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 2, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 2)
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsControler(tp) and tc:IsFaceup() and c:IsRelateToEffect(e) and c:IsAbleToRemove() and tc:IsAbleToRemove() then
  		local sg = Group.FromCards(c, tc)
  		if Duel.Remove(sg, POS_FACEUP, REASON_EFFECT) ~= 2 then
  			return
  		end
  		Duel.BreakEffect()
  		Duel.Draw(tp, 2, REASON_EFFECT)
  	end
  end
  function s.target3(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and chkc:IsAbleToDeck()
  	end
  	if chk == 0 then
  		return e:GetHandler():IsAbleToRemove()
  			and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, LOCATION_HAND, 0, 1, nil)
  			and Duel.IsExistingTarget(Card.IsAbleToDeck, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToDeck, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 2, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  end
  function s.operation3(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local hg = Duel.SelectMatchingCard(tp, Card.IsAbleToRemove, tp, LOCATION_HAND, 0, 1, 1, nil)
  	if hg:GetCount() > 0 then
  		hg:AddCard(c)
  		if Duel.Remove(hg, POS_FACEUP, REASON_EFFECT) ~= 2 then
  			return
  		end
  		local tc = Duel.GetFirstTarget()
  		if tc:IsRelateToEffect(e) then
  			Duel.BreakEffect()
  			Duel.SendtoDeck(tc, nil, SEQ_DECKTOP, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Cyber
  You can activate 1 of these effects.
  ● When this card is targeted for an attack: You can banish this card; draw 1 card, then end the Battle Phase.
  ● You can target 1 face-up monster you control and this card; banish both those targets, then draw 2 cards.
  ● You can target 1 card in your GY; banish both this card and 1 card from your hand, then place that target on top of the Deck.
target_text: -- Cyber
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--be target
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCost(s.cost1)
  	e1:SetTarget(s.target1)
  	e1:SetOperation(s.operation1)
  	c:RegisterEffect(e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetTarget(s.target2)
  	e2:SetOperation(s.operation2)
  	c:RegisterEffect(e2)
  	--salvage
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetCategory(CATEGORY_TODECK)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetType(EFFECT_TYPE_IGNITION)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetTarget(s.target3)
  	e3:SetOperation(s.operation3)
  	c:RegisterEffect(e3)
  end
  function s.cost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToRemoveAsCost()
  	end
  	Duel.Remove(e:GetHandler(), POS_FACEUP, REASON_COST)
  end
  function s.target1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.operation1(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.Draw(tp, 1, REASON_EFFECT) > 0 then
  		Duel.BreakEffect()
  		Duel.SkipPhase(1 - tp, PHASE_BATTLE, RESET_PHASE + PHASE_BATTLE_STEP, 1)
  	end
  end
  function s.filter2(c)
  	return c:IsFaceup() and c:IsAbleToRemove()
  end
  function s.target2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter2(chkc)
  	end
  	if chk == 0 then
  		return c:IsAbleToRemove() and Duel.IsPlayerCanDraw(tp, 2) and Duel.IsExistingTarget(s.filter2, tp, LOCATION_MZONE, 0, 1, c) and c:IsCanBeEffectTarget()
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, c)
  	g:AddCard(c)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 2, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 2)
  end
  function s.operation2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and tc:IsControler(tp) and tc:IsFaceup() and c:IsRelateToEffect(e) and c:IsAbleToRemove() and tc:IsAbleToRemove() then
  		local sg = Group.FromCards(c, tc)
  		if Duel.Remove(sg, POS_FACEUP, REASON_EFFECT) ~= 2 then
  			return
  		end
  		Duel.BreakEffect()
  		Duel.Draw(tp, 2, REASON_EFFECT)
  	end
  end
  function s.target3(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and chkc:IsAbleToDeck()
  	end
  	if chk == 0 then
  		return e:GetHandler():IsAbleToRemove()
  			and Duel.IsExistingMatchingCard(Card.IsAbleToRemove, tp, LOCATION_HAND, 0, 1, nil)
  			and Duel.IsExistingTarget(Card.IsAbleToDeck, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToDeck, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 2, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  end
  function s.operation3(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local hg = Duel.SelectMatchingCard(tp, Card.IsAbleToRemove, tp, LOCATION_HAND, 0, 1, 1, nil)
  	if hg:GetCount() > 0 then
  		hg:AddCard(c)
  		if Duel.Remove(hg, POS_FACEUP, REASON_EFFECT) ~= 2 then
  			return
  		end
  		local tc = Duel.GetFirstTarget()
  		if tc:IsRelateToEffect(e) then
  			Duel.BreakEffect()
  			Duel.SendtoDeck(tc, nil, SEQ_DECKTOP, REASON_EFFECT)
  		end
  	end
  end
  
  