name: Summon
card_text: During Main Phase 1, if the turn player successfully conducts their third Summon of a monster(s) this turn: It becomes the End Phase.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCode(EVENT_CUSTOM + id)
  	e2:SetCondition(s.condition)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = 0
  		s[1] = 0
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_SUMMON_SUCCESS)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  		ge2:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge2, 0)
  		local ge3 = Effect.CreateEffect(c)
  		ge3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge3:SetCode(EVENT_SPSUMMON_SUCCESS)
  		ge3:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge3, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local turnp = Duel.GetTurnPlayer()
  	if Duel.GetTurnCount() ~= s[2] then
  		s[0] = 0
  		s[1] = 0
  		s[2] = Duel.GetTurnCount()
  	end
  	local tc = eg:GetFirst()
  	local p1 = false
  	while tc do
  		if tc:IsSummonPlayer(turnp) then
  			p1 = true
  			break
  		end
  		tc = eg:GetNext()
  	end
  	if p1 then
  		s[turnp] = s[turnp] + 1
  		if s[turnp] == 3 then
  			Duel.RaiseEvent(e:GetHandler(), EVENT_CUSTOM + id, e, 0, 0, 0, 0)
  		end
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local turnp = Duel.GetTurnPlayer()
  	Duel.SkipPhase(turnp, PHASE_MAIN1, RESET_PHASE + PHASE_END, 1)
  	Duel.SkipPhase(turnp, PHASE_BATTLE, RESET_PHASE + PHASE_END, 1, 1)
  	Duel.SkipPhase(turnp, PHASE_MAIN2, RESET_PHASE + PHASE_END, 1)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BP)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, turnp)
  end
  
  
source_text: Summon
  During Main Phase 1, if the turn player successfully conducts their third Summon of a monster(s) this turn: It becomes the End Phase.
target_text: -- Summon
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetRange(LOCATION_FZONE)
  	e2:SetCode(EVENT_CUSTOM + id)
  	e2:SetCondition(s.condition)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = 0
  		s[1] = 0
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_SUMMON_SUCCESS)
  		ge1:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  		ge2:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge2, 0)
  		local ge3 = Effect.CreateEffect(c)
  		ge3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge3:SetCode(EVENT_SPSUMMON_SUCCESS)
  		ge3:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge3, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local turnp = Duel.GetTurnPlayer()
  	if Duel.GetTurnCount() ~= s[2] then
  		s[0] = 0
  		s[1] = 0
  		s[2] = Duel.GetTurnCount()
  	end
  	local tc = eg:GetFirst()
  	local p1 = false
  	while tc do
  		if tc:IsSummonPlayer(turnp) then
  			p1 = true
  			break
  		end
  		tc = eg:GetNext()
  	end
  	if p1 then
  		s[turnp] = s[turnp] + 1
  		if s[turnp] == 3 then
  			Duel.RaiseEvent(e:GetHandler(), EVENT_CUSTOM + id, e, 0, 0, 0, 0)
  		end
  	end
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local turnp = Duel.GetTurnPlayer()
  	Duel.SkipPhase(turnp, PHASE_MAIN1, RESET_PHASE + PHASE_END, 1)
  	Duel.SkipPhase(turnp, PHASE_BATTLE, RESET_PHASE + PHASE_END, 1, 1)
  	Duel.SkipPhase(turnp, PHASE_MAIN2, RESET_PHASE + PHASE_END, 1)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_BP)
  	e1:SetTargetRange(1, 0)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, turnp)
  end
  
  