name: Kaiser
card_text: If there is 1 or more monster(s) on the field of the controller of this card, his/her opponent cannot place a monster on the field if his/her number of monsters would exceed the number of monsters that are on the field of this card's controller. The cards that are already on the field before this card's activation are unaffected by this effect.
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)
  	--mzone limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EFFECT_MAX_MZONE)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(0, 1)
  	e2:SetValue(s.value)
  	c:RegisterEffect(e2)
  	--advance summon limit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EFFECT_UNRELEASABLE_SUM)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetValue(s.sumlimit)
  	c:RegisterEffect(e3)
  	--kaiser colosseum
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetCode(EFFECT_KAISER_COLOSSEUM)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetTargetRange(0, 1)
  	c:RegisterEffect(e4)
  end
  function s.value(e, fp, rp, r)
  	if rp == e:GetHandlerPlayer() or r ~= LOCATION_REASON_TOFIELD then
  		return 7
  	end
  	local limit = Duel.GetFieldGroupCount(e:GetHandlerPlayer(), LOCATION_MZONE, 0)
  	return limit > 0 and limit or 7
  end
  function s.sumlimit(e, c)
  	local tp = e:GetHandlerPlayer()
  	if c:IsControler(1 - tp) then
  		local mint, maxt = c:GetTributeRequirement()
  		local x = Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0)
  		local y = Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE)
  		local ex = Duel.GetMatchingGroupCount(Card.IsHasEffect, tp, LOCATION_MZONE, 0, nil, EFFECT_EXTRA_RELEASE)
  		local exs = Duel.GetMatchingGroupCount(Card.IsHasEffect, tp, LOCATION_MZONE, 0, nil, EFFECT_EXTRA_RELEASE_SUM)
  		if ex == 0 and exs > 0 then
  			ex = 1
  		end
  		return y - maxt + ex + 1 > x - ex
  	else
  		return false
  	end
  end
  
  
source_text: Kaiser
  If there is 1 or more monster(s) on the field of the controller of this card, his/her opponent cannot place a monster on the field if his/her number of monsters would exceed the number of monsters that are on the field of this card's controller. The cards that are already on the field before this card's activation are unaffected by this effect.
target_text: -- Kaiser
  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)
  	--mzone limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EFFECT_MAX_MZONE)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTargetRange(0, 1)
  	e2:SetValue(s.value)
  	c:RegisterEffect(e2)
  	--advance summon limit
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCode(EFFECT_UNRELEASABLE_SUM)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE + EFFECT_FLAG_IGNORE_IMMUNE)
  	e3:SetValue(s.sumlimit)
  	c:RegisterEffect(e3)
  	--kaiser colosseum
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetCode(EFFECT_KAISER_COLOSSEUM)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetTargetRange(0, 1)
  	c:RegisterEffect(e4)
  end
  function s.value(e, fp, rp, r)
  	if rp == e:GetHandlerPlayer() or r ~= LOCATION_REASON_TOFIELD then
  		return 7
  	end
  	local limit = Duel.GetFieldGroupCount(e:GetHandlerPlayer(), LOCATION_MZONE, 0)
  	return limit > 0 and limit or 7
  end
  function s.sumlimit(e, c)
  	local tp = e:GetHandlerPlayer()
  	if c:IsControler(1 - tp) then
  		local mint, maxt = c:GetTributeRequirement()
  		local x = Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0)
  		local y = Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE)
  		local ex = Duel.GetMatchingGroupCount(Card.IsHasEffect, tp, LOCATION_MZONE, 0, nil, EFFECT_EXTRA_RELEASE)
  		local exs = Duel.GetMatchingGroupCount(Card.IsHasEffect, tp, LOCATION_MZONE, 0, nil, EFFECT_EXTRA_RELEASE_SUM)
  		if ex == 0 and exs > 0 then
  			ex = 1
  		end
  		return y - maxt + ex + 1 > x - ex
  	else
  		return false
  	end
  end
  
  