name: Number
card_text: 3 Level 8 monsters
  Once per turn, if you have no cards in your Spell & Trap Card Zone: You can detach 1 Xyz Material from this card, and if you do, place 1 Destiny Counter on this card. You cannot conduct your Battle Phase the turn you activate this effect. When 3 Destiny Counters are on this card, you win the Duel.
external_ids: local COUNTER_ID_0 = 0x2b --Destiny
  
lua: local COUNTER_ID_0 = 0x2b --Destiny
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x2b)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 8, 3)
  	c:EnableReviveLimit()
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--win
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_ADJUST)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetOperation(s.winop)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 88
  function s.filter(c)
  	return c:GetSequence() < 5
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_SZONE, 0, 1, nil)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCurrentPhase() == PHASE_MAIN1
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BP)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_EFFECT) and e:GetHandler():IsCanAddCounter(COUNTER_ID_0, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 1, 0, 0x2b)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and c:RemoveOverlayCard(tp, 1, 1, REASON_EFFECT) then
  		c:AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.winop(e, tp, eg, ep, ev, re, r, rp)
  	local WIN_REASON_DESTINY_LEO = 0x17
  	local c = e:GetHandler()
  	if c:GetCounter(COUNTER_ID_0) == 3 then
  		Duel.Win(tp, WIN_REASON_DESTINY_LEO)
  	end
  end
  
  
source_text: Number
  3 Level 8 monsters
  Once per turn, if you have no cards in your Spell & Trap Card Zone: You can detach 1 Xyz Material from this card, and if you do, place 1 Destiny Counter on this card. You cannot conduct your Battle Phase the turn you activate this effect. When 3 Destiny Counters are on this card, you win the Duel.
target_text: -- Number
  local COUNTER_ID_0 = 0x2b --Destiny
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x2b)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 8, 3)
  	c:EnableReviveLimit()
  	--counter
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_COUNTER)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  	--win
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_ADJUST)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetOperation(s.winop)
  	c:RegisterEffect(e2)
  end
  aux.xyz_number[id] = 88
  function s.filter(c)
  	return c:GetSequence() < 5
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return not Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_SZONE, 0, 1, nil)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetCurrentPhase() == PHASE_MAIN1
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BP)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_EFFECT) and e:GetHandler():IsCanAddCounter(COUNTER_ID_0, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_COUNTER, nil, 1, 0, 0x2b)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() and c:RemoveOverlayCard(tp, 1, 1, REASON_EFFECT) then
  		c:AddCounter(COUNTER_ID_0, 1)
  	end
  end
  function s.winop(e, tp, eg, ep, ev, re, r, rp)
  	local WIN_REASON_DESTINY_LEO = 0x17
  	local c = e:GetHandler()
  	if c:GetCounter(COUNTER_ID_0) == 3 then
  		Duel.Win(tp, WIN_REASON_DESTINY_LEO)
  	end
  end
  
  