name: Battlin'
card_text: 2 Level 4 monsters
  If this card is Special Summoned: You can take 1 Level 4 or lower FIRE Warrior monster or 1 "Battlin' Boxing" Spell/Trap from your Deck, and either add it to your hand or send it to the GY. (Quick Effect): You can detach 1 material from a monster you control, and if you do, apply the following effect.
  ● Your opponent cannot target "Battlin' Boxer" monsters you control with card effects for the rest of this turn.
  You can only use each effect of "Battlin' Boxer King Dempsey" once per turn.
external_ids: local SETCARD_ID_0 = 0x1084 --Battlin'
  local SETCARD_ID_1 = 0x2084 --Battlin'
  
lua: local SETCARD_ID_0 = 0x1084 --Battlin'
  local SETCARD_ID_1 = 0x2084 --Battlin'
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--cannot be target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.thfilter(c)
  	return (c:IsLevelBelow(4) and c:IsRace(RACE_WARRIOR) and c:IsAttribute(ATTRIBUTE_FIRE) or c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP))
  		and (c:IsAbleToHand() or c:IsAbleToGrave())
  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
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if not tc then
  		return
  	end
  	if tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp, 1190, 1191) == 0) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	else
  		Duel.SendtoGrave(tc, REASON_EFFECT)
  	end
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckRemoveOverlayCard(tp, 1, 0, 1, REASON_EFFECT)
  	end
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.RemoveOverlayCard(tp, 1, 0, 1, 1, REASON_EFFECT) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  		e1:SetTargetRange(LOCATION_MZONE, 0)
  		e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_1))
  		e1:SetValue(s.tgval)
  		e1:SetOwnerPlayer(tp)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.tgval(e, re, rp)
  	return rp == 1 - e:GetOwnerPlayer()
  end
  
  
source_text: Battlin'
  2 Level 4 monsters
  If this card is Special Summoned: You can take 1 Level 4 or lower FIRE Warrior monster or 1 "Battlin' Boxing" Spell/Trap from your Deck, and either add it to your hand or send it to the GY. (Quick Effect): You can detach 1 material from a monster you control, and if you do, apply the following effect.
  ● Your opponent cannot target "Battlin' Boxer" monsters you control with card effects for the rest of this turn.
  You can only use each effect of "Battlin' Boxer King Dempsey" once per turn.
target_text: -- Battlin'
  local SETCARD_ID_0 = 0x1084 --Battlin'
  local SETCARD_ID_1 = 0x2084 --Battlin'
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--to hand
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_TOGRAVE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	c:RegisterEffect(e1)
  	--cannot be target
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e2:SetTarget(s.tgtg)
  	e2:SetOperation(s.tgop)
  	c:RegisterEffect(e2)
  end
  function s.thfilter(c)
  	return (c:IsLevelBelow(4) and c:IsRace(RACE_WARRIOR) and c:IsAttribute(ATTRIBUTE_FIRE) or c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_SPELL + TYPE_TRAP))
  		and (c:IsAbleToHand() or c:IsAbleToGrave())
  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
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if not tc then
  		return
  	end
  	if tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp, 1190, 1191) == 0) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  	else
  		Duel.SendtoGrave(tc, REASON_EFFECT)
  	end
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckRemoveOverlayCard(tp, 1, 0, 1, REASON_EFFECT)
  	end
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.RemoveOverlayCard(tp, 1, 0, 1, 1, REASON_EFFECT) ~= 0 then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  		e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  		e1:SetTargetRange(LOCATION_MZONE, 0)
  		e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_1))
  		e1:SetValue(s.tgval)
  		e1:SetOwnerPlayer(tp)
  		e1:SetReset(RESET_PHASE + PHASE_END)
  		Duel.RegisterEffect(e1, tp)
  	end
  end
  function s.tgval(e, re, rp)
  	return rp == 1 - e:GetOwnerPlayer()
  end
  
  