name: サモン・ゲート
card_text: 1:このカードが魔法&罠ゾーンに存在する限り、お互いはそれぞれ1ターンに合計3体までしかエクストラデッキからモンスターを特殊召喚できない。
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)
  	--summon count limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 1)
  	e2:SetTarget(s.sumlimit)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(id)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 1)
  	c:RegisterEffect(e3)
  	if s.global_check == nil then
  		s.global_check = true
  		s[0] = 3
  		s[1] = 3
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  		ge1:SetCode(EVENT_PHASE_START + PHASE_DRAW)
  		ge1:SetOperation(s.resetop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  		ge2:SetCode(EVENT_SPSUMMON_SUCCESS)
  		ge2:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.sumlimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsLocation(LOCATION_EXTRA) and s[sump] <= 0
  end
  function s.resetop(e, tp, eg, ep, ev, re, r, rp)
  	s[0] = 3
  	s[1] = 3
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		if tc:IsPreviousLocation(LOCATION_EXTRA) then
  			local p = tc:GetSummonPlayer()
  			s[p] = s[p] - 1
  		end
  		tc = eg:GetNext()
  	end
  end
  
  
source_text: サモン・ゲート
  1:このカードが魔法&罠ゾーンに存在する限り、お互いはそれぞれ1ターンに合計3体までしかエクストラデッキからモンスターを特殊召喚できない。
target_text: -- サモン・ゲート
  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)
  	--summon count limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(1, 1)
  	e2:SetTarget(s.sumlimit)
  	c:RegisterEffect(e2)
  	--
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(id)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 1)
  	c:RegisterEffect(e3)
  	if s.global_check == nil then
  		s.global_check = true
  		s[0] = 3
  		s[1] = 3
  		local ge1 = Effect.CreateEffect(c)
  		ge1:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  		ge1:SetCode(EVENT_PHASE_START + PHASE_DRAW)
  		ge1:SetOperation(s.resetop)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.CreateEffect(c)
  		ge2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  		ge2:SetCode(EVENT_SPSUMMON_SUCCESS)
  		ge2:SetOperation(s.checkop)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.sumlimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return c:IsLocation(LOCATION_EXTRA) and s[sump] <= 0
  end
  function s.resetop(e, tp, eg, ep, ev, re, r, rp)
  	s[0] = 3
  	s[1] = 3
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		if tc:IsPreviousLocation(LOCATION_EXTRA) then
  			local p = tc:GetSummonPlayer()
  			s[p] = s[p] - 1
  		end
  		tc = eg:GetNext()
  	end
  end
  
  