name: R.B.
card_text: If you control no face-up monsters, or the only face-up monsters you control are "R.B." monsters, you can Special Summon this card (from your hand). You can only Special Summon "R.B. Ga10 Cutter" once per turn this way. When your opponent's Spell/Trap Card or effect is activated, and this card is linked to an "R.B." Link Monster (Quick Effect): You can pay 700 LP; destroy this card, and if you do, negate that effect, and if you do that, destroy that card. You can only use this effect of "R.B. Ga10 Cutter" once per turn.
external_ids: local SETCARD_ID_0 = 0x1cf --R.B.
  
lua: local SETCARD_ID_0 = 0x1cf --R.B.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DISABLE + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.discon)
  	e2:SetCost(s.discost)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and not c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and not Duel.IsExistingMatchingCard(s.cfilter, c:GetControler(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.ecfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	local lg = Duel.GetMatchingGroup(s.ecfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	local lg2 = Group.CreateGroup()
  	for lc in aux.Next(lg) do
  		lg2:Merge(lc:GetLinkedGroup())
  	end
  	return lg2 and lg2:IsContains(e:GetHandler()) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and ep ~= tp and re:IsActiveType(TYPE_SPELL + TYPE_TRAP) and Duel.IsChainDisablable(ev)
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 700)
  	end
  	Duel.PayLPCost(tp, 700)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, eg, 1, 0, 0)
  	local dg = Group.FromCards(e:GetHandler())
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		dg:Merge(eg)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, #dg, 0, 0)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToChain() and Duel.Destroy(c, REASON_EFFECT) > 0 and Duel.NegateEffect(ev) and re:GetHandler():IsRelateToChain(ev) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  
  
source_text: R.B.
  If you control no face-up monsters, or the only face-up monsters you control are "R.B." monsters, you can Special Summon this card (from your hand). You can only Special Summon "R.B. Ga10 Cutter" once per turn this way. When your opponent's Spell/Trap Card or effect is activated, and this card is linked to an "R.B." Link Monster (Quick Effect): You can pay 700 LP; destroy this card, and if you do, negate that effect, and if you do that, destroy that card. You can only use this effect of "R.B. Ga10 Cutter" once per turn.
target_text: -- R.B.
  local SETCARD_ID_0 = 0x1cf --R.B.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.spcon)
  	c:RegisterEffect(e1)
  	--negate
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DISABLE + CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_CHAINING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.discon)
  	e2:SetCost(s.discost)
  	e2:SetTarget(s.distg)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsFaceup() and not c:IsSetCard(SETCARD_ID_0)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and not Duel.IsExistingMatchingCard(s.cfilter, c:GetControler(), LOCATION_MZONE, 0, 1, nil)
  end
  function s.ecfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_LINK)
  end
  function s.discon(e, tp, eg, ep, ev, re, r, rp)
  	local lg = Duel.GetMatchingGroup(s.ecfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	local lg2 = Group.CreateGroup()
  	for lc in aux.Next(lg) do
  		lg2:Merge(lc:GetLinkedGroup())
  	end
  	return lg2 and lg2:IsContains(e:GetHandler()) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and ep ~= tp and re:IsActiveType(TYPE_SPELL + TYPE_TRAP) and Duel.IsChainDisablable(ev)
  end
  function s.discost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 700)
  	end
  	Duel.PayLPCost(tp, 700)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, eg, 1, 0, 0)
  	local dg = Group.FromCards(e:GetHandler())
  	if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
  		dg:Merge(eg)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, dg, #dg, 0, 0)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToChain() and Duel.Destroy(c, REASON_EFFECT) > 0 and Duel.NegateEffect(ev) and re:GetHandler():IsRelateToChain(ev) then
  		Duel.Destroy(eg, REASON_EFFECT)
  	end
  end
  
  