name: Gate
card_text: Negate the effects of your opponent's Field Spells. Your opponent cannot place counters on cards on the field. Your opponent cannot target other monsters you control with card effects.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_SZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--disable effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--prevent counter
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_CANNOT_PLACE_COUNTER)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(0, 1)
  	c:RegisterEffect(e3)
  	--target
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e4:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_SET_AVAILABLE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(LOCATION_MZONE, 0)
  	e4:SetTarget(s.tglimit)
  	e4:SetValue(aux.tgoval)
  	c:RegisterEffect(e4)
  end
  function s.distg(e, c)
  	return c:IsType(TYPE_FIELD)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local tl = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	if bit.band(tl, LOCATION_FZONE) ~= 0 and re:IsActiveType(TYPE_FIELD) and 1 - tp == rp then
  		Duel.NegateEffect(ev)
  	end
  end
  function s.tglimit(e, c)
  	return c ~= e:GetHandler()
  end
  
  
source_text: Gate
  Negate the effects of your opponent's Field Spells. Your opponent cannot place counters on cards on the field. Your opponent cannot target other monsters you control with card effects.
target_text: -- Gate
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--disable
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_DISABLE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetTargetRange(0, LOCATION_SZONE)
  	e1:SetTarget(s.distg)
  	c:RegisterEffect(e1)
  	--disable effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_CHAIN_SOLVING)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetOperation(s.disop)
  	c:RegisterEffect(e2)
  	--prevent counter
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_CANNOT_PLACE_COUNTER)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(0, 1)
  	c:RegisterEffect(e3)
  	--target
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e4:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE + EFFECT_FLAG_SET_AVAILABLE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetTargetRange(LOCATION_MZONE, 0)
  	e4:SetTarget(s.tglimit)
  	e4:SetValue(aux.tgoval)
  	c:RegisterEffect(e4)
  end
  function s.distg(e, c)
  	return c:IsType(TYPE_FIELD)
  end
  function s.disop(e, tp, eg, ep, ev, re, r, rp)
  	local tl = Duel.GetChainInfo(ev, CHAININFO_TRIGGERING_LOCATION)
  	if bit.band(tl, LOCATION_FZONE) ~= 0 and re:IsActiveType(TYPE_FIELD) and 1 - tp == rp then
  		Duel.NegateEffect(ev)
  	end
  end
  function s.tglimit(e, c)
  	return c ~= e:GetHandler()
  end
  
  