name: Max
card_text: If this card attacks an opponent's monster, this card gains 400 ATK during the Damage Step only. If this card destroys an opponent's monster by battle, until your next Standby Phase: this card becomes Level 2 and its original ATK and DEF are halved.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetCondition(s.condtion)
  	e1:SetValue(400)
  	c:RegisterEffect(e1)
  	--addown
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.atkcon)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.condtion(e)
  	local ph = Duel.GetCurrentPhase()
  	return (ph == PHASE_DAMAGE or ph == PHASE_DAMAGE_CAL) and Duel.GetAttacker() == e:GetHandler() and Duel.GetAttackTarget() ~= nil
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsRelateToBattle() and e:GetHandler():IsFaceup()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToBattle() and c:IsFaceup() then
  		local batk = c:GetBaseAttack()
  		local bdef = c:GetBaseDefense()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_BASE_ATTACK_FINAL)
  		e1:SetValue(math.ceil(batk / 2))
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_SET_BASE_DEFENSE_FINAL)
  		e2:SetValue(math.ceil(bdef / 2))
  		c:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CHANGE_LEVEL)
  		e3:SetValue(2)
  		c:RegisterEffect(e3)
  	end
  end
  
  
source_text: Max
  If this card attacks an opponent's monster, this card gains 400 ATK during the Damage Step only. If this card destroys an opponent's monster by battle, until your next Standby Phase: this card becomes Level 2 and its original ATK and DEF are halved.
target_text: -- Max
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetCondition(s.condtion)
  	e1:SetValue(400)
  	c:RegisterEffect(e1)
  	--addown
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCategory(CATEGORY_ATKCHANGE)
  	e2:SetCode(EVENT_BATTLE_DESTROYING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.atkcon)
  	e2:SetOperation(s.atkop)
  	c:RegisterEffect(e2)
  end
  function s.condtion(e)
  	local ph = Duel.GetCurrentPhase()
  	return (ph == PHASE_DAMAGE or ph == PHASE_DAMAGE_CAL) and Duel.GetAttacker() == e:GetHandler() and Duel.GetAttackTarget() ~= nil
  end
  function s.atkcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsRelateToBattle() and e:GetHandler():IsFaceup()
  end
  function s.atkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToBattle() and c:IsFaceup() then
  		local batk = c:GetBaseAttack()
  		local bdef = c:GetBaseDefense()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_SET_BASE_ATTACK_FINAL)
  		e1:SetValue(math.ceil(batk / 2))
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_STANDBY + RESET_SELF_TURN)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_SET_BASE_DEFENSE_FINAL)
  		e2:SetValue(math.ceil(bdef / 2))
  		c:RegisterEffect(e2)
  		local e3 = e1:Clone()
  		e3:SetCode(EFFECT_CHANGE_LEVEL)
  		e3:SetValue(2)
  		c:RegisterEffect(e3)
  	end
  end
  
  