name: Final
card_text: Pay 2000 Life Points. After 20 turns have passed after you activate this card (counting the turn you activate this card as the 1st turn), you win the Duel.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 2000)
  	end
  	Duel.PayLPCost(tp, 2000)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 20)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetOperation(s.checkop)
  	e1:SetCountLimit(1)
  	e1:SetReset(RESET_PHASE + PHASE_END, 20)
  	Duel.RegisterEffect(e1, tp)
  	c:RegisterFlagEffect(1082946, RESET_PHASE + PHASE_END, 0, 20)
  	s[c] = e1
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.GetFlagEffect(tp, id)
  	c:SetHint(CHINT_TURN, ct)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 21 - ct)
  	if ct == 20 then
  		Duel.Win(tp, 0x11)
  		c:ResetFlagEffect(1082946)
  	end
  end
  
  
source_text: Final
  Pay 2000 Life Points. After 20 turns have passed after you activate this card (counting the turn you activate this card as the 1st turn), you win the Duel.
target_text: -- Final
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_REMOVE)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLPCost(tp, 2000)
  	end
  	Duel.PayLPCost(tp, 2000)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetFlagEffect(tp, id) ~= 0 then
  		return
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 20)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_PHASE + PHASE_END)
  	e1:SetOperation(s.checkop)
  	e1:SetCountLimit(1)
  	e1:SetReset(RESET_PHASE + PHASE_END, 20)
  	Duel.RegisterEffect(e1, tp)
  	c:RegisterFlagEffect(1082946, RESET_PHASE + PHASE_END, 0, 20)
  	s[c] = e1
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local ct = Duel.GetFlagEffect(tp, id)
  	c:SetHint(CHINT_TURN, ct)
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 21 - ct)
  	if ct == 20 then
  		Duel.Win(tp, 0x11)
  		c:ResetFlagEffect(1082946)
  	end
  end
  
  