Tsumuha-Kutsunagi
Cannot be Special Summoned. You can Tribute Summon this card by Tributing 1 Normal Summoned/Set monster. If this card is Normal Summoned or flipped face-up: Activate this effect; your opponent can send any number of cards from their field to the GY, then each player draws the same number of cards as were sent to the GY by this effect. During the End Phase of the turn this effect was activated, shuffle all cards into the Deck from the field, the GYs, and that are banished. Once per turn, during the End Phase, if this card on the field was Normal Summoned or flipped face-up this turn: Return this card to the hand.
local s, id, o = GetID()
function s.initial_effect(c)
	--cannot special summon
	local e0 = Effect.CreateEffect(c)
	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e0:SetType(EFFECT_TYPE_SINGLE)
	e0:SetCode(EFFECT_SPSUMMON_CONDITION)
	e0:SetValue(aux.FALSE)
	c:RegisterEffect(e0)
	--spirit return
	aux.EnableSpiritReturn(c, EVENT_SUMMON_SUCCESS, EVENT_FLIP)
	--summon with 1 tribute
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_SUMMON_PROC)
	e1:SetCondition(s.otcon)
	e1:SetOperation(s.otop)
	e1:SetValue(SUMMON_TYPE_ADVANCE)
	c:RegisterEffect(e1)
	local e2 = e1:Clone()
	e2:SetCode(EFFECT_SET_PROC)
	c:RegisterEffect(e2)
	--return to deck
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_DRAW + CATEGORY_TODECK + CATEGORY_GRAVE_ACTION)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
	e2:SetCode(EVENT_SUMMON_SUCCESS)
	e2:SetTarget(s.tg)
	e2:SetOperation(s.op)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EVENT_FLIP)
	c:RegisterEffect(e3)
end
function s.otfilter(c)
	return c:IsSummonType(SUMMON_TYPE_NORMAL) or c:IsSummonType(SUMMON_TYPE_ADVANCE) or c:IsSummonType(SUMMON_TYPE_DUAL)
end
function s.otcon(e, c, minc)
	if c == nil then
		return true
	end
	local mg = Duel.GetMatchingGroup(s.otfilter, 0, LOCATION_MZONE, LOCATION_MZONE, nil)
	return c:IsLevelAbove(7) and minc <= 1 and Duel.CheckTribute(c, 1, 1, mg)
end
function s.otop(e, tp, eg, ep, ev, re, r, rp, c)
	local mg = Duel.GetMatchingGroup(s.otfilter, 0, LOCATION_MZONE, LOCATION_MZONE, nil)
	local sg = Duel.SelectTribute(tp, c, 1, 1, mg)
	c:SetMaterial(sg)
	Duel.Release(sg, REASON_SUMMON + REASON_MATERIAL)
end
function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
end
function s.op(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local g = Duel.GetMatchingGroup(Card.IsAbleToGrave, 1 - tp, LOCATION_ONFIELD, 0, nil)
	if #g > 0 and Duel.IsPlayerCanDraw(tp) and Duel.IsPlayerCanDraw(1 - tp) and Duel.SelectYesNo(1 - tp, aux.Stringid(id, 2)) then
		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_TOGRAVE)
		local tg = g:Select(1 - tp, 1, #g, nil)
		if #tg > 0 and Duel.SendtoGrave(tg, REASON_EFFECT) and tg:IsExists(Card.IsLocation, 1, nil, LOCATION_GRAVE) then
			Duel.Draw(tp, #tg, REASON_EFFECT)
			Duel.Draw(1 - tp, #tg, REASON_EFFECT)
		end
	end
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e1:SetCode(EVENT_PHASE + PHASE_END)
	e1:SetCountLimit(1)
	e1:SetOperation(s.todop)
	e1:SetReset(RESET_PHASE + PHASE_END)
	Duel.RegisterEffect(e1, tp)
end
function s.todop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(Card.IsAbleToDeck), tp, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED, nil)
	if #g == 0 then
		return
	end
	Duel.Hint(HINT_CARD, 0, id)
	Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
end


Tsumuha-Kutsunagi
Cannot be Special Summoned. You can Tribute Summon this card by Tributing 1 Normal Summoned/Set monster. If this card is Normal Summoned or flipped face-up: Activate this effect; your opponent can send any number of cards from their field to the GY, then each player draws the same number of cards as were sent to the GY by this effect. During the End Phase of the turn this effect was activated, shuffle all cards into the Deck from the field, the GYs, and that are banished. Once per turn, during the End Phase, if this card on the field was Normal Summoned or flipped face-up this turn: Return this card to the hand.
-- Tsumuha-Kutsunagi
local s, id, o = GetID()
function s.initial_effect(c)
	--cannot special summon
	local e0 = Effect.CreateEffect(c)
	e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e0:SetType(EFFECT_TYPE_SINGLE)
	e0:SetCode(EFFECT_SPSUMMON_CONDITION)
	e0:SetValue(aux.FALSE)
	c:RegisterEffect(e0)
	--spirit return
	aux.EnableSpiritReturn(c, EVENT_SUMMON_SUCCESS, EVENT_FLIP)
	--summon with 1 tribute
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_SUMMON_PROC)
	e1:SetCondition(s.otcon)
	e1:SetOperation(s.otop)
	e1:SetValue(SUMMON_TYPE_ADVANCE)
	c:RegisterEffect(e1)
	local e2 = e1:Clone()
	e2:SetCode(EFFECT_SET_PROC)
	c:RegisterEffect(e2)
	--return to deck
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 1))
	e2:SetCategory(CATEGORY_DRAW + CATEGORY_TODECK + CATEGORY_GRAVE_ACTION)
	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
	e2:SetCode(EVENT_SUMMON_SUCCESS)
	e2:SetTarget(s.tg)
	e2:SetOperation(s.op)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EVENT_FLIP)
	c:RegisterEffect(e3)
end
function s.otfilter(c)
	return c:IsSummonType(SUMMON_TYPE_NORMAL) or c:IsSummonType(SUMMON_TYPE_ADVANCE) or c:IsSummonType(SUMMON_TYPE_DUAL)
end
function s.otcon(e, c, minc)
	if c == nil then
		return true
	end
	local mg = Duel.GetMatchingGroup(s.otfilter, 0, LOCATION_MZONE, LOCATION_MZONE, nil)
	return c:IsLevelAbove(7) and minc <= 1 and Duel.CheckTribute(c, 1, 1, mg)
end
function s.otop(e, tp, eg, ep, ev, re, r, rp, c)
	local mg = Duel.GetMatchingGroup(s.otfilter, 0, LOCATION_MZONE, LOCATION_MZONE, nil)
	local sg = Duel.SelectTribute(tp, c, 1, 1, mg)
	c:SetMaterial(sg)
	Duel.Release(sg, REASON_SUMMON + REASON_MATERIAL)
end
function s.tg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return true
	end
end
function s.op(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local g = Duel.GetMatchingGroup(Card.IsAbleToGrave, 1 - tp, LOCATION_ONFIELD, 0, nil)
	if #g > 0 and Duel.IsPlayerCanDraw(tp) and Duel.IsPlayerCanDraw(1 - tp) and Duel.SelectYesNo(1 - tp, aux.Stringid(id, 2)) then
		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_TOGRAVE)
		local tg = g:Select(1 - tp, 1, #g, nil)
		if #tg > 0 and Duel.SendtoGrave(tg, REASON_EFFECT) and tg:IsExists(Card.IsLocation, 1, nil, LOCATION_GRAVE) then
			Duel.Draw(tp, #tg, REASON_EFFECT)
			Duel.Draw(1 - tp, #tg, REASON_EFFECT)
		end
	end
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e1:SetCode(EVENT_PHASE + PHASE_END)
	e1:SetCountLimit(1)
	e1:SetOperation(s.todop)
	e1:SetReset(RESET_PHASE + PHASE_END)
	Duel.RegisterEffect(e1, tp)
end
function s.todop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(aux.NecroValleyFilter(Card.IsAbleToDeck), tp, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED, LOCATION_ONFIELD + LOCATION_GRAVE + LOCATION_REMOVED, nil)
	if #g == 0 then
		return
	end
	Duel.Hint(HINT_CARD, 0, id)
	Duel.SendtoDeck(g, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
end

