name: Degrade
card_text: Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) by banishing 2 Cyberse monsters from your GY. You can target 1 monster your opponent controls with higher ATK than this card (Quick Effect); banish it until the End Phase. You can only use this effect of "Degrade Buster" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	e1:SetTarget(s.sprtg)
  	e1:SetOperation(s.sprop)
  	c:RegisterEffect(e1)
  	--remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  end
  function s.sprfilter(c)
  	return c:IsRace(RACE_CYBERSE) and c:IsAbleToRemoveAsCost()
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_GRAVE, 0, 2, nil)
  end
  function s.sprtg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.sprfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:CancelableSelect(tp, 2, 2, nil)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.sprop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Remove(g, POS_FACEUP, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.rmfilter(c, atk)
  	return c:IsFaceup() and c:GetAttack() > atk and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local atk = e:GetHandler():GetAttack()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.rmfilter(chkc, atk)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.rmfilter, tp, 0, LOCATION_MZONE, 1, nil, atk)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.rmfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, atk)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Remove(tc, 0, REASON_EFFECT + REASON_TEMPORARY) ~= 0 then
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		e1:SetLabelObject(tc)
  		e1:SetCountLimit(1)
  		e1:SetCondition(s.retcon)
  		e1:SetOperation(s.retop)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabelObject():GetFlagEffect(id) ~= 0
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ReturnToField(e:GetLabelObject())
  end
  
  
source_text: Degrade
  Cannot be Normal Summoned/Set. Must first be Special Summoned (from your hand) by banishing 2 Cyberse monsters from your GY. You can target 1 monster your opponent controls with higher ATK than this card (Quick Effect); banish it until the End Phase. You can only use this effect of "Degrade Buster" once per turn.
target_text: -- Degrade
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	e1:SetTarget(s.sprtg)
  	e1:SetOperation(s.sprop)
  	c:RegisterEffect(e1)
  	--remove
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_REMOVE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.rmtg)
  	e2:SetOperation(s.rmop)
  	c:RegisterEffect(e2)
  end
  function s.sprfilter(c)
  	return c:IsRace(RACE_CYBERSE) and c:IsAbleToRemoveAsCost()
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_GRAVE, 0, 2, nil)
  end
  function s.sprtg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local g = Duel.GetMatchingGroup(s.sprfilter, tp, LOCATION_GRAVE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local sg = g:CancelableSelect(tp, 2, 2, nil)
  	if sg then
  		sg:KeepAlive()
  		e:SetLabelObject(sg)
  		return true
  	else
  		return false
  	end
  end
  function s.sprop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.Remove(g, POS_FACEUP, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.rmfilter(c, atk)
  	return c:IsFaceup() and c:GetAttack() > atk and c:IsAbleToRemove()
  end
  function s.rmtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local atk = e:GetHandler():GetAttack()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.rmfilter(chkc, atk)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.rmfilter, tp, 0, LOCATION_MZONE, 1, nil, atk)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectTarget(tp, s.rmfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, atk)
  	Duel.SetOperationInfo(0, CATEGORY_REMOVE, g, 1, 0, 0)
  end
  function s.rmop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.Remove(tc, 0, REASON_EFFECT + REASON_TEMPORARY) ~= 0 then
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END, 0, 1)
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_PHASE + PHASE_END)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		e1:SetLabelObject(tc)
  		e1:SetCountLimit(1)
  		e1:SetCondition(s.retcon)
  		e1:SetOperation(s.retop)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.retcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetLabelObject():GetFlagEffect(id) ~= 0
  end
  function s.retop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ReturnToField(e:GetLabelObject())
  end
  
  