name: 獣累々
card_text: 1:このターンに召喚・特殊召喚されていないフィールドのモンスターを全て守備表示にする。
  このターン、自身のフィールドに守備表示モンスターが存在するプレイヤーは、このターンに召喚・特殊召喚されたモンスターで攻撃宣言できない。
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_POSITION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	if not s.global_check then
  		s.global_check = true
  		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 = ge1:Clone()
  		ge2:SetCode(EVENT_SPSUMMON_SUCCESS)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD - RESET_TEMP_REMOVE + RESET_PHASE + PHASE_END, 0, 1)
  		tc = eg:GetNext()
  	end
  end
  function s.filter(c)
  	return c:IsAttackPos() and c:IsCanChangePosition() and c:GetFlagEffect(id) == 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		Duel.ChangePosition(g, POS_FACEUP_DEFENSE)
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetCondition(s.atkcon1)
  	e1:SetTarget(s.atkfilter)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(s.atkcon2)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.atkcon1(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsDefensePos, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.atkcon2(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsDefensePos, tp, 0, LOCATION_MZONE, 1, nil)
  end
  function s.atkfilter(e, c)
  	return c:GetFlagEffect(id) ~= 0
  end
  
  
source_text: 獣累々
  1:このターンに召喚・特殊召喚されていないフィールドのモンスターを全て守備表示にする。
  このターン、自身のフィールドに守備表示モンスターが存在するプレイヤーは、このターンに召喚・特殊召喚されたモンスターで攻撃宣言できない。
target_text: -- 獣累々
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_POSITION)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	if not s.global_check then
  		s.global_check = true
  		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 = ge1:Clone()
  		ge2:SetCode(EVENT_SPSUMMON_SUCCESS)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = eg:GetFirst()
  	while tc do
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD - RESET_TEMP_REMOVE + RESET_PHASE + PHASE_END, 0, 1)
  		tc = eg:GetNext()
  	end
  end
  function s.filter(c)
  	return c:IsAttackPos() and c:IsCanChangePosition() and c:GetFlagEffect(id) == 0
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		Duel.ChangePosition(g, POS_FACEUP_DEFENSE)
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
  	e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetCondition(s.atkcon1)
  	e1:SetTarget(s.atkfilter)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetTargetRange(0, LOCATION_MZONE)
  	e2:SetCondition(s.atkcon2)
  	Duel.RegisterEffect(e2, tp)
  end
  function s.atkcon1(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsDefensePos, tp, LOCATION_MZONE, 0, 1, nil)
  end
  function s.atkcon2(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(Card.IsDefensePos, tp, 0, LOCATION_MZONE, 1, nil)
  end
  function s.atkfilter(e, c)
  	return c:GetFlagEffect(id) ~= 0
  end
  
  