name: Battlin'
card_text: 2 Level 4 "Battlin' Boxer" monsters
  If a "Battlin' Boxer" monster(s) you control would be destroyed by battle or card effect, you can detach 1 material from this card instead of destroying 1 of those monsters. If a material(s) is detached from this card: This card gains 800 ATK.
external_ids: local SETCARD_ID_0 = 0x1084 --Battlin'
  
lua: local SETCARD_ID_0 = 0x1084 --Battlin'
  local s, id, o = GetID()
  function s.initial_effect(c)
  	Duel.EnableGlobalFlag(GLOBALFLAG_DETACH_EVENT)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), 4, 2)
  	c:EnableReviveLimit()
  	--destroy replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EFFECT_DESTROY_REPLACE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTarget(s.reptg)
  	e1:SetValue(s.repval)
  	c:RegisterEffect(e1)
  	--attack up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_TRIGGER_F + EFFECT_TYPE_SINGLE)
  	e2:SetCode(EVENT_DETACH_MATERIAL)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.repfilter(c, tp)
  	return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsSetCard(SETCARD_ID_0) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.repfilter, 1, nil, tp)
  	end
  	if e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_EFFECT) and Duel.SelectEffectYesNo(tp, e:GetHandler(), 96) then
  		e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_EFFECT)
  		local g = eg:Filter(s.repfilter, nil, tp)
  		if g:GetCount() == 1 then
  			e:SetLabelObject(g:GetFirst())
  		else
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESREPLACE)
  			local cg = g:Select(tp, 1, 1, nil)
  			e:SetLabelObject(cg:GetFirst())
  		end
  		return true
  	else
  		return false
  	end
  end
  function s.repval(e, c)
  	return c == e:GetLabelObject()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsRelateToEffect(e)
  	end
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e1:SetValue(800)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Battlin'
  2 Level 4 "Battlin' Boxer" monsters
  If a "Battlin' Boxer" monster(s) you control would be destroyed by battle or card effect, you can detach 1 material from this card instead of destroying 1 of those monsters. If a material(s) is detached from this card: This card gains 800 ATK.
target_text: -- Battlin'
  local SETCARD_ID_0 = 0x1084 --Battlin'
  local s, id, o = GetID()
  function s.initial_effect(c)
  	Duel.EnableGlobalFlag(GLOBALFLAG_DETACH_EVENT)
  	--xyz summon
  	aux.AddXyzProcedure(c, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), 4, 2)
  	c:EnableReviveLimit()
  	--destroy replace
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EFFECT_DESTROY_REPLACE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTarget(s.reptg)
  	e1:SetValue(s.repval)
  	c:RegisterEffect(e1)
  	--attack up
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetType(EFFECT_TYPE_TRIGGER_F + EFFECT_TYPE_SINGLE)
  	e2:SetCode(EVENT_DETACH_MATERIAL)
  	e2:SetTarget(s.atktg)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.repfilter(c, tp)
  	return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsSetCard(SETCARD_ID_0) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
  end
  function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return eg:IsExists(s.repfilter, 1, nil, tp)
  	end
  	if e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_EFFECT) and Duel.SelectEffectYesNo(tp, e:GetHandler(), 96) then
  		e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_EFFECT)
  		local g = eg:Filter(s.repfilter, nil, tp)
  		if g:GetCount() == 1 then
  			e:SetLabelObject(g:GetFirst())
  		else
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESREPLACE)
  			local cg = g:Select(tp, 1, 1, nil)
  			e:SetLabelObject(cg:GetFirst())
  		end
  		return true
  	else
  		return false
  	end
  end
  function s.repval(e, c)
  	return c == e:GetLabelObject()
  end
  function s.atktg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsRelateToEffect(e)
  	end
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		e1:SetValue(800)
  		c:RegisterEffect(e1)
  	end
  end
  
  