name: B.E.F.
card_text: When this card is activated: You can add 1 "Boss Rush" from your Deck to your hand. All "B.E.S." monsters you control gain 500 ATK and DEF, your opponent cannot target them with card effects, and they cannot be destroyed by your opponent's card effects. Once per turn: You can Special Summon 1 "B.E.S." monster from your hand. If a "B.E.S." monster(s) is Normal or Special Summoned to your field: Place 1 counter on it.
external_ids: local CARD_ID_0 = 66947414 --Boss Rush
  local SETCARD_ID_0 = 0x15 --B.E.S.
  local COUNTER_ID_0 = 0x1f --Counter(B.E.S.)
  
lua: local CARD_ID_0 = 66947414 --Boss Rush
  local SETCARD_ID_0 = 0x15 --B.E.S.
  local COUNTER_ID_0 = 0x1f --Counter(B.E.S.)
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atk/def up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	--indes
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e4:SetRange(LOCATION_FZONE)
  	e4:SetTargetRange(LOCATION_MZONE, 0)
  	e4:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e4:SetValue(aux.indoval)
  	c:RegisterEffect(e4)
  	--cannot be target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e5:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e5:SetRange(LOCATION_FZONE)
  	e5:SetTargetRange(LOCATION_MZONE, 0)
  	e5:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e5:SetValue(aux.tgoval)
  	c:RegisterEffect(e5)
  	--spsummon
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 1))
  	e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e6:SetType(EFFECT_TYPE_IGNITION)
  	e6:SetRange(LOCATION_FZONE)
  	e6:SetCountLimit(1)
  	e6:SetTarget(s.sptg)
  	e6:SetOperation(s.spop)
  	c:RegisterEffect(e6)
  	--counter
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 2))
  	e7:SetCategory(CATEGORY_COUNTER)
  	e7:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e7:SetCode(EVENT_SUMMON_SUCCESS)
  	e7:SetRange(LOCATION_FZONE)
  	e7:SetCondition(s.ctcon)
  	e7:SetTarget(s.cttg)
  	e7:SetOperation(s.ctop)
  	c:RegisterEffect(e7)
  	local e8 = e7:Clone()
  	e8:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e8)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.ctfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp)
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.ctfilter, 1, nil, tp)
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local ec = eg:FilterCount(s.ctfilter, nil, tp)
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, ec, 0, 0x1f)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local g = eg:Filter(s.ctfilter, nil, tp)
  	local tc = g:GetFirst()
  	while tc do
  		tc:AddCounter(COUNTER_ID_0, 1)
  		tc = g:GetNext()
  	end
  end
  
  
source_text: B.E.F.
  When this card is activated: You can add 1 "Boss Rush" from your Deck to your hand. All "B.E.S." monsters you control gain 500 ATK and DEF, your opponent cannot target them with card effects, and they cannot be destroyed by your opponent's card effects. Once per turn: You can Special Summon 1 "B.E.S." monster from your hand. If a "B.E.S." monster(s) is Normal or Special Summoned to your field: Place 1 counter on it.
target_text: -- B.E.F.
  local CARD_ID_0 = 66947414 --Boss Rush
  local SETCARD_ID_0 = 0x15 --B.E.S.
  local COUNTER_ID_0 = 0x1f --Counter(B.E.S.)
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atk/def up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e2:SetValue(500)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e3)
  	--indes
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e4:SetRange(LOCATION_FZONE)
  	e4:SetTargetRange(LOCATION_MZONE, 0)
  	e4:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e4:SetValue(aux.indoval)
  	c:RegisterEffect(e4)
  	--cannot be target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_FIELD)
  	e5:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e5:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e5:SetRange(LOCATION_FZONE)
  	e5:SetTargetRange(LOCATION_MZONE, 0)
  	e5:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e5:SetValue(aux.tgoval)
  	c:RegisterEffect(e5)
  	--spsummon
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 1))
  	e6:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e6:SetType(EFFECT_TYPE_IGNITION)
  	e6:SetRange(LOCATION_FZONE)
  	e6:SetCountLimit(1)
  	e6:SetTarget(s.sptg)
  	e6:SetOperation(s.spop)
  	c:RegisterEffect(e6)
  	--counter
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 2))
  	e7:SetCategory(CATEGORY_COUNTER)
  	e7:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e7:SetCode(EVENT_SUMMON_SUCCESS)
  	e7:SetRange(LOCATION_FZONE)
  	e7:SetCondition(s.ctcon)
  	e7:SetTarget(s.cttg)
  	e7:SetOperation(s.ctop)
  	c:RegisterEffect(e7)
  	local e8 = e7:Clone()
  	e8:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e8)
  end
  function s.thfilter(c)
  	return c:IsCode(CARD_ID_0) and c:IsAbleToHand()
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.thfilter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  		local sg = g:Select(tp, 1, 1, nil)
  		Duel.SendtoHand(sg, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, sg)
  	end
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.ctfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp)
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.ctfilter, 1, nil, tp)
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	local ec = eg:FilterCount(s.ctfilter, nil, tp)
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, ec, 0, 0x1f)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local g = eg:Filter(s.ctfilter, nil, tp)
  	local tc = g:GetFirst()
  	while tc do
  		tc:AddCounter(COUNTER_ID_0, 1)
  		tc = g:GetNext()
  	end
  end
  
  