name: Life
card_text: During your Standby Phase, gain Life Points equal to half of the total Life Points you paid during your last turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--recover
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_RECOVER)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.reccon)
  	e2:SetTarget(s.rectg)
  	e2:SetOperation(s.recop)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = 0
  		s[1] = 0
  		s[2] = 0
  		s[3] = 0
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_PAY_LPCOST)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_TURN_END)
  		ge2:SetOperation(s.clear)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	if ep == Duel.GetTurnPlayer() then
  		local val = math.ceil(ev / 2)
  		s[ep] = s[ep] + val
  	end
  end
  function s.clear(e, tp, eg, ep, ev, re, r, rp)
  	s[ep + 2] = s[ep]
  	s[ep] = 0
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer()
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local val = s[tp + 2]
  	if chk == 0 then
  		return val > 0
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(val)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, val)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  end
  
  
source_text: Life
  During your Standby Phase, gain Life Points equal to half of the total Life Points you paid during your last turn.
target_text: -- Life
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--recover
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_RECOVER)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_PHASE + PHASE_STANDBY)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.reccon)
  	e2:SetTarget(s.rectg)
  	e2:SetOperation(s.recop)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = 0
  		s[1] = 0
  		s[2] = 0
  		s[3] = 0
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_PAY_LPCOST)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_TURN_END)
  		ge2:SetOperation(s.clear)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	if ep == Duel.GetTurnPlayer() then
  		local val = math.ceil(ev / 2)
  		s[ep] = s[ep] + val
  	end
  end
  function s.clear(e, tp, eg, ep, ev, re, r, rp)
  	s[ep + 2] = s[ep]
  	s[ep] = 0
  end
  function s.reccon(e, tp, eg, ep, ev, re, r, rp)
  	return tp == Duel.GetTurnPlayer()
  end
  function s.rectg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local val = s[tp + 2]
  	if chk == 0 then
  		return val > 0
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(val)
  	Duel.SetOperationInfo(0, CATEGORY_RECOVER, nil, 0, tp, val)
  end
  function s.recop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Recover(p, d, REASON_EFFECT)
  end
  
  