name: Borrelend
card_text: 3+ Effect Monsters
  Cannot be destroyed by battle or card effects, also neither player can target this card with monster effects. Can attack all monsters your opponent controls, once each. (Quick Effect): You can target 1 Effect Monster on the field and 1 "Rokket" monster in your GY; negate the effects of that monster on the field, and if you do, Special Summon that other monster from your GY. Your opponent cannot activate cards or effects in response to this effect's activation. You can only use this effect of "Borrelend Dragon" once per turn.
external_ids: local SETCARD_ID_0 = 0x102 --Rokket
  
lua: local SETCARD_ID_0 = 0x102 --Rokket
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkType, TYPE_EFFECT), 3)
  	c:EnableReviveLimit()
  	--indestructable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e2)
  	--cannot be target
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetValue(s.efilter)
  	c:RegisterEffect(e3)
  	--attack all
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_ATTACK_ALL)
  	e4:SetValue(1)
  	c:RegisterEffect(e4)
  	--disable
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCategory(CATEGORY_DISABLE + CATEGORY_SPECIAL_SUMMON)
  	e5:SetType(EFFECT_TYPE_QUICK_O)
  	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e5:SetCode(EVENT_FREE_CHAIN)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCountLimit(1, id)
  	e5:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e5:SetTarget(s.distg)
  	e5:SetOperation(s.disop)
  	c:RegisterEffect(e5)
  end
  function s.efilter(e, re, rp)
  	return re:IsActiveType(TYPE_MONSTER)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingTarget(aux.NegateEffectMonsterFilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  			and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISABLE)
  	local g1 = Duel.SelectTarget(tp, aux.NegateEffectMonsterFilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	e:SetLabelObject(g1:GetFirst())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g2 = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g2, 1, 0, 0)
  	Duel.SetChainLimit(s.chlimit)
  end
  function s.chlimit(e, ep, tp)
  	return tp == ep
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local hc = e:GetLabelObject()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tc = g:GetFirst()
  	if tc == hc then
  		tc = g:GetNext()
  	end
  	if hc:IsRelateToEffect(e) and hc:IsCanBeDisabledByEffect(e) then
  		Duel.NegateRelatedChain(hc, RESET_TURN_SET)
  		local c = e:GetHandler()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		hc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		hc:RegisterEffect(e2)
  		if tc:IsRelateToEffect(e) then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: Borrelend
  3+ Effect Monsters
  Cannot be destroyed by battle or card effects, also neither player can target this card with monster effects. Can attack all monsters your opponent controls, once each. (Quick Effect): You can target 1 Effect Monster on the field and 1 "Rokket" monster in your GY; negate the effects of that monster on the field, and if you do, Special Summon that other monster from your GY. Your opponent cannot activate cards or effects in response to this effect's activation. You can only use this effect of "Borrelend Dragon" once per turn.
target_text: -- Borrelend
  local SETCARD_ID_0 = 0x102 --Rokket
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkType, TYPE_EFFECT), 3)
  	c:EnableReviveLimit()
  	--indestructable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	c:RegisterEffect(e2)
  	--cannot be target
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetValue(s.efilter)
  	c:RegisterEffect(e3)
  	--attack all
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetCode(EFFECT_ATTACK_ALL)
  	e4:SetValue(1)
  	c:RegisterEffect(e4)
  	--disable
  	local e5 = Effect.CreateEffect(c)
  	e5:SetDescription(aux.Stringid(id, 0))
  	e5:SetCategory(CATEGORY_DISABLE + CATEGORY_SPECIAL_SUMMON)
  	e5:SetType(EFFECT_TYPE_QUICK_O)
  	e5:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e5:SetCode(EVENT_FREE_CHAIN)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCountLimit(1, id)
  	e5:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e5:SetTarget(s.distg)
  	e5:SetOperation(s.disop)
  	c:RegisterEffect(e5)
  end
  function s.efilter(e, re, rp)
  	return re:IsActiveType(TYPE_MONSTER)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.distg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return false
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsExistingTarget(aux.NegateEffectMonsterFilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  			and Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISABLE)
  	local g1 = Duel.SelectTarget(tp, aux.NegateEffectMonsterFilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	e:SetLabelObject(g1:GetFirst())
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g2 = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_DISABLE, g1, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g2, 1, 0, 0)
  	Duel.SetChainLimit(s.chlimit)
  end
  function s.chlimit(e, ep, tp)
  	return tp == ep
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local hc = e:GetLabelObject()
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local tc = g:GetFirst()
  	if tc == hc then
  		tc = g:GetNext()
  	end
  	if hc:IsRelateToEffect(e) and hc:IsCanBeDisabledByEffect(e) then
  		Duel.NegateRelatedChain(hc, RESET_TURN_SET)
  		local c = e:GetHandler()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		hc:RegisterEffect(e1)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_DISABLE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		hc:RegisterEffect(e2)
  		if tc:IsRelateToEffect(e) then
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  