name: 森羅の恵み
card_text: 手札を1枚選んで持ち主のデッキの一番上または一番下に戻し、自分の手札・墓地から「森羅」と名のついたモンスター1体を選んで特殊召喚する。
  この効果で特殊召喚したモンスターはこのターン、このカード以外のカードの効果を受けず、エンドフェイズ時に持ち主のデッキの一番上または一番下に戻す。
external_ids: local SETCARD_ID_0 = 0x90 --森羅
  
lua: local SETCARD_ID_0 = 0x90 --森羅
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsAbleToDeck() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, c, e, tp)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		local opt = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  		Duel.SendtoDeck(g, nil, opt, REASON_EFFECT)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, tc, e, tp)
  		local sc = sg:GetFirst()
  		if sc then
  			Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetRange(LOCATION_MZONE)
  			e1:SetCountLimit(1)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetOperation(s.tdop)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			sc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  			e2:SetRange(LOCATION_MZONE)
  			e2:SetCode(EFFECT_IMMUNE_EFFECT)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			e2:SetValue(s.efilter)
  			sc:RegisterEffect(e2)
  		end
  	end
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsExtraDeckMonster() or Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1)) == 0 then
  		Duel.SendtoDeck(c, nil, SEQ_DECKTOP, REASON_EFFECT)
  	else
  		Duel.SendtoDeck(c, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  	end
  end
  function s.efilter(e, te)
  	return te:GetOwner() ~= e:GetOwner()
  end
  
  
source_text: 森羅の恵み
  手札を1枚選んで持ち主のデッキの一番上または一番下に戻し、自分の手札・墓地から「森羅」と名のついたモンスター1体を選んで特殊召喚する。
  この効果で特殊召喚したモンスターはこのターン、このカード以外のカードの効果を受けず、エンドフェイズ時に持ち主のデッキの一番上または一番下に戻す。
target_text: -- 森羅の恵み
  local SETCARD_ID_0 = 0x90 --森羅
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, e, tp)
  	return c:IsAbleToDeck() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, c, e, tp)
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, nil, 1, tp, LOCATION_HAND)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND + LOCATION_GRAVE)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	local tc = g:GetFirst()
  	if tc then
  		local opt = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  		Duel.SendtoDeck(g, nil, opt, REASON_EFFECT)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local sg = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.spfilter), tp, LOCATION_HAND + LOCATION_GRAVE, 0, 1, 1, tc, e, tp)
  		local sc = sg:GetFirst()
  		if sc then
  			Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP)
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  			e1:SetRange(LOCATION_MZONE)
  			e1:SetCountLimit(1)
  			e1:SetCode(EVENT_PHASE + PHASE_END)
  			e1:SetOperation(s.tdop)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			sc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(e:GetHandler())
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  			e2:SetRange(LOCATION_MZONE)
  			e2:SetCode(EFFECT_IMMUNE_EFFECT)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			e2:SetValue(s.efilter)
  			sc:RegisterEffect(e2)
  		end
  	end
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsExtraDeckMonster() or Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1)) == 0 then
  		Duel.SendtoDeck(c, nil, SEQ_DECKTOP, REASON_EFFECT)
  	else
  		Duel.SendtoDeck(c, nil, SEQ_DECKBOTTOM, REASON_EFFECT)
  	end
  end
  function s.efilter(e, te)
  	return te:GetOwner() ~= e:GetOwner()
  end
  
  