name: Perditious
card_text: Once per turn: You can discard 1 card; gain control of all face-up Level 3 or lower monsters your opponent controls, until the End Phase. These monsters cannot activate their effects, and cannot be Tributed or used as a Synchro Material Monster.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsLevelBelow(3) and c:IsControlerCanBeChanged()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, nil, 1, 1 - tp, LOCATION_MZONE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, 0, LOCATION_MZONE, ft, ft, nil)
  	Duel.GetControl(g, tp, PHASE_END, 1)
  	local og = Duel.GetOperatedGroup()
  	local tc = og:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TURN_SET + RESET_PHASE + PHASE_END)
  		e1:SetValue(1)
  		tc:RegisterEffect(e1, true)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_UNRELEASABLE_NONSUM)
  		tc:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CANNOT_TRIGGER)
  		tc:RegisterEffect(e3)
  		local e4 = e1:Clone()
  		e4:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
  		tc:RegisterEffect(e4)
  		tc = og:GetNext()
  	end
  end
  
  
source_text: Perditious
  Once per turn: You can discard 1 card; gain control of all face-up Level 3 or lower monsters your opponent controls, until the End Phase. These monsters cannot activate their effects, and cannot be Tributed or used as a Synchro Material Monster.
target_text: -- Perditious
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_CONTROL)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsLevelBelow(3) and c:IsControlerCanBeChanged()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, 0, LOCATION_MZONE, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, nil, 1, 1 - tp, LOCATION_MZONE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, 0, LOCATION_MZONE, ft, ft, nil)
  	Duel.GetControl(g, tp, PHASE_END, 1)
  	local og = Duel.GetOperatedGroup()
  	local tc = og:GetFirst()
  	while tc do
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UNRELEASABLE_SUM)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD - RESET_TURN_SET + RESET_PHASE + PHASE_END)
  		e1:SetValue(1)
  		tc:RegisterEffect(e1, true)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_UNRELEASABLE_NONSUM)
  		tc:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CANNOT_TRIGGER)
  		tc:RegisterEffect(e3)
  		local e4 = e1:Clone()
  		e4:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL)
  		tc:RegisterEffect(e4)
  		tc = og:GetNext()
  	end
  end
  
  