--閃刀姫－カガリ
--Brandish Maiden Kagari
--Scripted by Eerie Code
function c100408027.initial_effect(c)
	c:SetSPSummonOnce(100408027)
	--link summon
	c:EnableReviveLimit()
	aux.AddLinkProcedure(c,c100408027.matfilter,1,1)
	--atk up
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_UPDATE_ATTACK)
	e1:SetRange(LOCATION_MZONE)
	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e1:SetValue(c100408027.atkval)
	c:RegisterEffect(e1)
	--search
	local e3=Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(100408027,0))
	e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
	e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
	e3:SetTarget(c100408027.thtg)
	e3:SetOperation(c100408027.thop)
	c:RegisterEffect(e3)
end
function c100408027.matfilter(c)
	return c:IsLinkSetCard(0x1215) and not c:IsLinkAttribute(ATTRIBUTE_FIRE)
end
function c100408027.atkval(e)
	return Duel.GetMatchingGroupCount(Card.IsType,e:GetHandlerPlayer(),LOCATION_GRAVE,0,nil,TYPE_SPELL)*100
end
function c100408027.thfilter(c,tp)
	return c:IsSetCard(0x215) and c:IsType(TYPE_SPELL) and c:IsAbleToHand()
end
function c100408027.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
	if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c100408027.thfilter(chkc) end
	if chk==0 then return Duel.IsExistingTarget(c100408027.thfilter,tp,LOCATION_GRAVE,0,1,nil) end
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
	local sg=Duel.SelectTarget(tp,c100408027.thfilter,tp,LOCATION_GRAVE,0,1,1,nil)
	Duel.SetOperationInfo(0,CATEGORY_TOHAND,sg,1,0,0)
end
function c100408027.thop(e,tp,eg,ep,ev,re,r,rp)
	local tc=Duel.GetFirstTarget()
	if tc:IsRelateToEffect(e) then
		Duel.SendtoHand(tc,nil,REASON_EFFECT)
	end
end
