name: Infestation
card_text: Target 1 "lswarm" monster you control and 2 cards your opponent controls; banish the first target, and if you do, return the second targets to the hand.
external_ids: local SETCARD_ID_0 = 0xa --lswarm
  
lua: local SETCARD_ID_0 = 0xa --lswarm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--remove & tohand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.rmfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.rmfilter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingTarget(Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g1 = Duel.SelectTarget(tp, s.rmfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g1, 1, 0, 0)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g2 = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 2, 2, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g2, g2:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ex, g1 = Duel.GetOperationInfo(0, CATEGORY_REMOVE)
  	local ex, g2 = Duel.GetOperationInfo(0, CATEGORY_TOHAND)
  	if g1:GetFirst():IsRelateToEffect(e) and g1:GetFirst():IsFaceup() and Duel.Remove(g1, POS_FACEUP, REASON_EFFECT) ~= 0 then
  		local hg = g2:Filter(Card.IsRelateToEffect, nil, e)
  		Duel.SendtoHand(hg, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Infestation
  Target 1 "lswarm" monster you control and 2 cards your opponent controls; banish the first target, and if you do, return the second targets to the hand.
target_text: -- Infestation
  local SETCARD_ID_0 = 0xa --lswarm
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--remove & tohand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE + CATEGORY_TOHAND)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.rmfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsAbleToRemove()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.rmfilter, tp, LOCATION_MZONE, 0, 1, nil) and Duel.IsExistingTarget(Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g1 = Duel.SelectTarget(tp, s.rmfilter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g1, 1, 0, 0)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_RTOHAND)
  	local g2 = Duel.SelectTarget(tp, Card.IsAbleToHand, tp, 0, LOCATION_ONFIELD, 2, 2, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, g2, g2:GetCount(), 0, 0)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ex, g1 = Duel.GetOperationInfo(0, CATEGORY_REMOVE)
  	local ex, g2 = Duel.GetOperationInfo(0, CATEGORY_TOHAND)
  	if g1:GetFirst():IsRelateToEffect(e) and g1:GetFirst():IsFaceup() and Duel.Remove(g1, POS_FACEUP, REASON_EFFECT) ~= 0 then
  		local hg = g2:Filter(Card.IsRelateToEffect, nil, e)
  		Duel.SendtoHand(hg, nil, REASON_EFFECT)
  	end
  end
  
  