name: Tatsunoko
card_text: 1 Tuner + 1 or more non-Tuner monsters
  If this Synchro Summoned monster would be used as a Synchro Material, 1 monster in your hand can be used as 1 of the other Synchro Materials. Unaffected by other monsters' effects.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--synchro custom
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SYNCHRO_MATERIAL_CUSTOM)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCondition(s.syncon)
  	e1:SetTarget(s.syntg)
  	e1:SetValue(1)
  	e1:SetOperation(s.synop)
  	c:RegisterEffect(e1)
  	--immune
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_IMMUNE_EFFECT)
  	e2:SetValue(s.efilter)
  	c:RegisterEffect(e2)
  	--hand synchro
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SPSUM_PARAM)
  	e3:SetCondition(s.syncon)
  	e3:SetCode(EFFECT_HAND_SYNCHRO)
  	e3:SetTargetRange(0, 1)
  	c:RegisterEffect(e3)
  end
  function s.synfilter(c, syncard, tuner, f)
  	return c:IsFaceupEx() and c:IsCanBeSynchroMaterial(syncard, tuner) and (f == nil or f(c, syncard))
  end
  function s.syncheck(c, g, mg, tp, lv, syncard, minc, maxc)
  	g:AddCard(c)
  	local ct = g:GetCount()
  	local res = s.syngoal(g, tp, lv, syncard, minc, ct) or (ct < maxc and mg:IsExists(s.syncheck, 1, g, g, mg, tp, lv, syncard, minc, maxc))
  	g:RemoveCard(c)
  	return res
  end
  function s.syngoal(g, tp, lv, syncard, minc, ct)
  	return ct >= minc
  		and g:CheckWithSumEqual(Card.GetSynchroLevel, lv, ct, ct, syncard)
  		and Duel.GetLocationCountFromEx(tp, tp, g, syncard) > 0
  		and g:FilterCount(Card.IsLocation, nil, LOCATION_HAND) <= 1
  		and aux.MustMaterialCheck(g, tp, EFFECT_MUST_BE_SMATERIAL)
  end
  function s.syncon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.syntg(e, syncard, f, min, max)
  	local minc = min + 1
  	local maxc = max + 1
  	local c = e:GetHandler()
  	local tp = syncard:GetControler()
  	local lv = syncard:GetLevel()
  	if lv <= c:GetLevel() then
  		return false
  	end
  	local g = Group.FromCards(c)
  	local mg = Duel.GetSynchroMaterial(tp):Filter(s.synfilter, c, syncard, c, f)
  	local exg = Duel.GetMatchingGroup(s.synfilter, tp, LOCATION_HAND, 0, c, syncard, c, f)
  	mg:Merge(exg)
  	return mg:IsExists(s.syncheck, 1, g, g, mg, tp, lv, syncard, minc, maxc)
  end
  function s.synop(e, tp, eg, ep, ev, re, r, rp, syncard, f, min, max)
  	local minc = min + 1
  	local maxc = max + 1
  	local c = e:GetHandler()
  	local lv = syncard:GetLevel()
  	local g = Group.FromCards(c)
  	local mg = Duel.GetSynchroMaterial(tp):Filter(s.synfilter, c, syncard, c, f)
  	local exg = Duel.GetMatchingGroup(s.synfilter, tp, LOCATION_HAND, 0, c, syncard, c, f)
  	mg:Merge(exg)
  	for i = 1, maxc do
  		local cg = mg:Filter(s.syncheck, g, g, mg, tp, lv, syncard, minc, maxc)
  		if cg:GetCount() == 0 then
  			break
  		end
  		local minct = 1
  		if s.syngoal(g, tp, lv, syncard, minc, i) then
  			minct = 0
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SMATERIAL)
  		local sg = cg:Select(tp, minct, 1, nil)
  		if sg:GetCount() == 0 then
  			break
  		end
  		g:Merge(sg)
  	end
  	Duel.SetSynchroMaterial(g)
  end
  function s.efilter(e, te)
  	return te:IsActiveType(TYPE_MONSTER) and te:GetOwner() ~= e:GetOwner()
  end
  
  
source_text: Tatsunoko
  1 Tuner + 1 or more non-Tuner monsters
  If this Synchro Summoned monster would be used as a Synchro Material, 1 monster in your hand can be used as 1 of the other Synchro Materials. Unaffected by other monsters' effects.
target_text: -- Tatsunoko
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--synchro custom
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SYNCHRO_MATERIAL_CUSTOM)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCondition(s.syncon)
  	e1:SetTarget(s.syntg)
  	e1:SetValue(1)
  	e1:SetOperation(s.synop)
  	c:RegisterEffect(e1)
  	--immune
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCode(EFFECT_IMMUNE_EFFECT)
  	e2:SetValue(s.efilter)
  	c:RegisterEffect(e2)
  	--hand synchro
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE + EFFECT_FLAG_SPSUM_PARAM)
  	e3:SetCondition(s.syncon)
  	e3:SetCode(EFFECT_HAND_SYNCHRO)
  	e3:SetTargetRange(0, 1)
  	c:RegisterEffect(e3)
  end
  function s.synfilter(c, syncard, tuner, f)
  	return c:IsFaceupEx() and c:IsCanBeSynchroMaterial(syncard, tuner) and (f == nil or f(c, syncard))
  end
  function s.syncheck(c, g, mg, tp, lv, syncard, minc, maxc)
  	g:AddCard(c)
  	local ct = g:GetCount()
  	local res = s.syngoal(g, tp, lv, syncard, minc, ct) or (ct < maxc and mg:IsExists(s.syncheck, 1, g, g, mg, tp, lv, syncard, minc, maxc))
  	g:RemoveCard(c)
  	return res
  end
  function s.syngoal(g, tp, lv, syncard, minc, ct)
  	return ct >= minc
  		and g:CheckWithSumEqual(Card.GetSynchroLevel, lv, ct, ct, syncard)
  		and Duel.GetLocationCountFromEx(tp, tp, g, syncard) > 0
  		and g:FilterCount(Card.IsLocation, nil, LOCATION_HAND) <= 1
  		and aux.MustMaterialCheck(g, tp, EFFECT_MUST_BE_SMATERIAL)
  end
  function s.syncon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.syntg(e, syncard, f, min, max)
  	local minc = min + 1
  	local maxc = max + 1
  	local c = e:GetHandler()
  	local tp = syncard:GetControler()
  	local lv = syncard:GetLevel()
  	if lv <= c:GetLevel() then
  		return false
  	end
  	local g = Group.FromCards(c)
  	local mg = Duel.GetSynchroMaterial(tp):Filter(s.synfilter, c, syncard, c, f)
  	local exg = Duel.GetMatchingGroup(s.synfilter, tp, LOCATION_HAND, 0, c, syncard, c, f)
  	mg:Merge(exg)
  	return mg:IsExists(s.syncheck, 1, g, g, mg, tp, lv, syncard, minc, maxc)
  end
  function s.synop(e, tp, eg, ep, ev, re, r, rp, syncard, f, min, max)
  	local minc = min + 1
  	local maxc = max + 1
  	local c = e:GetHandler()
  	local lv = syncard:GetLevel()
  	local g = Group.FromCards(c)
  	local mg = Duel.GetSynchroMaterial(tp):Filter(s.synfilter, c, syncard, c, f)
  	local exg = Duel.GetMatchingGroup(s.synfilter, tp, LOCATION_HAND, 0, c, syncard, c, f)
  	mg:Merge(exg)
  	for i = 1, maxc do
  		local cg = mg:Filter(s.syncheck, g, g, mg, tp, lv, syncard, minc, maxc)
  		if cg:GetCount() == 0 then
  			break
  		end
  		local minct = 1
  		if s.syngoal(g, tp, lv, syncard, minc, i) then
  			minct = 0
  		end
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SMATERIAL)
  		local sg = cg:Select(tp, minct, 1, nil)
  		if sg:GetCount() == 0 then
  			break
  		end
  		g:Merge(sg)
  	end
  	Duel.SetSynchroMaterial(g)
  end
  function s.efilter(e, te)
  	return te:IsActiveType(TYPE_MONSTER) and te:GetOwner() ~= e:GetOwner()
  end
  
  