name: Battlin'
card_text: If this card is Normal or Special Summoned: You can add 1 "Battlin' Boxer" monster or 1 "Counter" Counter Trap from your Deck to your hand, except "Battlin' Boxer Uppercutter". If this card is sent to the GY by card effect: You can activate 1 of these effects;
  ● Special Summon 1 "Battlin' Boxer" monster from your GY, except "Battlin' Boxer Uppercutter".
  ● Set 1 "Counter" Counter Trap from your GY to your field.
  You can only use 1 "Battlin' Boxer Uppercutter" effect per turn, and only once that turn.
external_ids: local SETCARD_ID_0 = 0x1084 --Battlin'
  local SETCARD_ID_1 = 0x199 --Counter
  
lua: local SETCARD_ID_0 = 0x1084 --Battlin'
  local SETCARD_ID_1 = 0x199 --Counter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--leave grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.lgcon)
  	e3:SetTarget(s.lgtg)
  	e3:SetOperation(s.lgop)
  	c:RegisterEffect(e3)
  end
  function s.thfilter(c)
  	return (c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) or c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_COUNTER)) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.lgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_EFFECT)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.setfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_COUNTER) and c:IsSSetable()
  end
  function s.lgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local b1 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	local b2 = Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 2)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE)
  	else
  		e:SetCategory(CATEGORY_LEAVE_GRAVE)
  		Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, nil, 1, tp, LOCATION_GRAVE)
  	end
  end
  function s.lgop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetLabel() == 0 then
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  			return
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.setfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g)
  		end
  	end
  end
  
  
source_text: Battlin'
  If this card is Normal or Special Summoned: You can add 1 "Battlin' Boxer" monster or 1 "Counter" Counter Trap from your Deck to your hand, except "Battlin' Boxer Uppercutter". If this card is sent to the GY by card effect: You can activate 1 of these effects;
  ● Special Summon 1 "Battlin' Boxer" monster from your GY, except "Battlin' Boxer Uppercutter".
  ● Set 1 "Counter" Counter Trap from your GY to your field.
  You can only use 1 "Battlin' Boxer Uppercutter" effect per turn, and only once that turn.
target_text: -- Battlin'
  local SETCARD_ID_0 = 0x1084 --Battlin'
  local SETCARD_ID_1 = 0x199 --Counter
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	--leave grave
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_TO_GRAVE)
  	e3:SetCountLimit(1, id)
  	e3:SetCondition(s.lgcon)
  	e3:SetTarget(s.lgtg)
  	e3:SetOperation(s.lgop)
  	c:RegisterEffect(e3)
  end
  function s.thfilter(c)
  	return (c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) or c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_COUNTER)) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  function s.lgcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_EFFECT)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.setfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_COUNTER) and c:IsSSetable()
  end
  function s.lgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local b1 = Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	local b2 = Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	if chk == 0 then
  		return b1 or b2
  	end
  	local op = 0
  	if b1 and b2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1), aux.Stringid(id, 2))
  	elseif b1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1))
  	else
  		op = Duel.SelectOption(tp, aux.Stringid(id, 2)) + 1
  	end
  	e:SetLabel(op)
  	if op == 0 then
  		e:SetCategory(CATEGORY_SPECIAL_SUMMON)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_GRAVE)
  	else
  		e:SetCategory(CATEGORY_LEAVE_GRAVE)
  		Duel.SetOperationInfo(0, CATEGORY_LEAVE_GRAVE, nil, 1, tp, LOCATION_GRAVE)
  	end
  end
  function s.lgop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetLabel() == 0 then
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  			return
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  		if g:GetCount() > 0 then
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	else
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SET)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.setfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil)
  		if g:GetCount() > 0 then
  			Duel.SSet(tp, g)
  		end
  	end
  end
  
  