--剣闘獣セクトル
function c77642288.initial_effect(c)
	--special summon
	local e1=Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(77642288,0))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
	e1:SetCode(EVENT_PHASE+PHASE_BATTLE)
	e1:SetRange(LOCATION_MZONE)
	e1:SetProperty(EFFECT_FLAG_REPEAT)
	e1:SetCountLimit(1)
	e1:SetCondition(c77642288.spcon)
	e1:SetTarget(c77642288.sptg)
	e1:SetOperation(c77642288.spop)
	c:RegisterEffect(e1)
end
function c77642288.spcon(e,tp,eg,ep,ev,re,r,rp)
	return e:GetHandler():GetFlagEffect(77642288)>0 and e:GetHandler():GetBattledGroupCount()>0
end
function c77642288.filter(c,e,tp)
	return not c:IsCode(77642288) and c:IsSetCard(0x19) and c:IsCanBeSpecialSummoned(e,106,tp,false,false)
end
function c77642288.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return true end
	Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,LOCATION_DECK)
end
function c77642288.spop(e,tp,eg,ep,ev,re,r,rp)
	local zc=Duel.GetLocationCount(tp,LOCATION_MZONE)
	if zc==0 then return end
	if not Duel.IsExistingMatchingCard(c77642288.filter,tp,LOCATION_DECK,0,2,nil,e,tp) then return end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
	local g=Duel.SelectMatchingCard(tp,c77642288.filter,tp,LOCATION_DECK,0,2,2,nil,e,tp)
	if zc==1 then
		local sg=g:Select(tp,1,1,nil)
		local sc=sg:GetFirst()
		g:RemoveCard(sc)
		Duel.SpecialSummon(sc,106,tp,tp,false,false,POS_FACEUP)
		sc:RegisterFlagEffect(sc:GetOriginalCode(),RESET_EVENT+0x1ff0000,0,0)
		Duel.Destroy(g,REASON_EFFECT)
	else
		local tc=g:GetFirst()
		while tc do
			Duel.SpecialSummonStep(tc,106,tp,tp,false,false,POS_FACEUP)
			tc:RegisterFlagEffect(tc:GetOriginalCode(),RESET_EVENT+0x1ff0000,0,0)
			tc=g:GetNext()
		end
		Duel.SpecialSummonComplete()
	end
end
