name: Battlin'
card_text: The first time this card would be destroyed by battle each turn, it is not destroyed. Once per turn: You can target 1 of your "Battlin' Boxer" monsters that is banished or in your GY, that has a Level; all "Battlin' Boxer" monsters you currently control become that monster's current Level.
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)
  	--battle indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e1:SetCountLimit(1)
  	e1:SetValue(s.valcon)
  	c:RegisterEffect(e1)
  	--level
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.lvtg)
  	e2:SetOperation(s.lvop)
  	c:RegisterEffect(e2)
  end
  function s.valcon(e, re, r, rp)
  	return bit.band(r, REASON_BATTLE) ~= 0
  end
  function s.filter(c)
  	return c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_0) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
  end
  function s.lvfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetLevel() > 0
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil) and Duel.IsExistingMatchingCard(s.lvfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) then
  		return
  	end
  	local lv = tc:GetLevel()
  	local g = Duel.GetMatchingGroup(s.lvfilter, tp, LOCATION_MZONE, 0, nil)
  	local lc = g:GetFirst()
  	while lc do
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(lv)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		lc:RegisterEffect(e1)
  		lc = g:GetNext()
  	end
  end
  
  
source_text: Battlin'
  The first time this card would be destroyed by battle each turn, it is not destroyed. Once per turn: You can target 1 of your "Battlin' Boxer" monsters that is banished or in your GY, that has a Level; all "Battlin' Boxer" monsters you currently control become that monster's current Level.
target_text: -- Battlin'
  local SETCARD_ID_0 = 0x1084 --Battlin'
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--battle indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT)
  	e1:SetCountLimit(1)
  	e1:SetValue(s.valcon)
  	c:RegisterEffect(e1)
  	--level
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetCountLimit(1)
  	e2:SetTarget(s.lvtg)
  	e2:SetOperation(s.lvop)
  	c:RegisterEffect(e2)
  end
  function s.valcon(e, re, r, rp)
  	return bit.band(r, REASON_BATTLE) ~= 0
  end
  function s.filter(c)
  	return c:GetLevel() > 0 and c:IsSetCard(SETCARD_ID_0) and (c:IsLocation(LOCATION_GRAVE) or c:IsFaceup())
  end
  function s.lvfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:GetLevel() > 0
  end
  function s.lvtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE + LOCATION_REMOVED) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, nil) and Duel.IsExistingMatchingCard(s.lvfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE + LOCATION_REMOVED, 0, 1, 1, nil)
  end
  function s.lvop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsRelateToEffect(e) then
  		return
  	end
  	local lv = tc:GetLevel()
  	local g = Duel.GetMatchingGroup(s.lvfilter, tp, LOCATION_MZONE, 0, nil)
  	local lc = g:GetFirst()
  	while lc do
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_CHANGE_LEVEL)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(lv)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		lc:RegisterEffect(e1)
  		lc = g:GetNext()
  	end
  end
  
  