--キューキューロイド
function c36378213.initial_effect(c)
	--Activate
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(36378213,0))
	e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetCode(EVENT_TO_HAND)
	e1:SetRange(LOCATION_MZONE)
	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
	e1:SetTarget(c36378213.target)
	e1:SetOperation(c36378213.activate)
	c:RegisterEffect(e1)
end
function c36378213.filter(c,e,tp)
	return c:IsPreviousLocation(LOCATION_GRAVE) and c:GetPreviousControler()==tp and c:IsSetCard(0x16)
		and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c36378213.target(e,tp,eg,ep,ev,re,r,rp,chk)
	local g=eg:Filter(c36378213.filter,nil,e,tp)
	if chk==0 then return g:GetCount()~=0 and Duel.GetLocationCount(tp,LOCATION_MZONE)>=g:GetCount() end
	Duel.SetTargetCard(eg)
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0)
end
function c36378213.spfilter(c,e,tp)
	return c:IsPreviousLocation(LOCATION_GRAVE) and c:GetPreviousControler()==tp and c:IsSetCard(0x16)
		and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsRelateToEffect(e)
end
function c36378213.activate(e,tp,eg,ep,ev,re,r,rp)
	local g=eg:Filter(c36378213.spfilter,nil,e,tp)
	if g:GetCount()==0 or Duel.GetLocationCount(tp,LOCATION_MZONE)<g:GetCount() then return end
	Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
