--十二獣ブルホーン
function c114514027.initial_effect(c)
	--xyz summon
	aux.AddXyzProcedure(c,nil,4,2,c114514027.ovfilter,aux.Stringid(114514027,0),2,c114514027.xyzop)
	c:EnableReviveLimit()
	--atk
	local e1=Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_SINGLE)
	e1:SetCode(EFFECT_UPDATE_ATTACK)
	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
	e1:SetRange(LOCATION_MZONE)
	e1:SetValue(c114514027.atkval)
	c:RegisterEffect(e1)
	local e2=e1:Clone()
	e2:SetCode(EFFECT_UPDATE_DEFENSE)
	e2:SetValue(c114514027.defval)
	c:RegisterEffect(e2)
	--search
	local e3=Effect.CreateEffect(c)
	e3:SetDescription(aux.Stringid(114514027,1))
	e3:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH)
	e3:SetType(EFFECT_TYPE_IGNITION)
	e3:SetCountLimit(1)
	e3:SetRange(LOCATION_MZONE)
	e3:SetCost(c114514027.cost)
	e3:SetTarget(c114514027.target)
	e3:SetOperation(c114514027.operation)
	c:RegisterEffect(e3)
end
function c114514027.ovfilter(c)
	return c:IsFaceup() and c:IsSetCard(0xf1) and not c:IsCode(114514027)
end
function c114514027.xyzop(e,tp,chk)
	if chk==0 then return Duel.GetFlagEffect(tp,114514027)==0 end
	Duel.RegisterFlagEffect(tp,114514027,RESET_PHASE+PHASE_END,EFFECT_FLAG_OATH,1)
end
function c114514027.atkfilter(c)
	return c:IsSetCard(0xf1) and c:GetAttack()>=0
end
function c114514027.atkval(e,c)
	local g=e:GetHandler():GetOverlayGroup():Filter(c114514027.atkfilter,nil)
	return g:GetSum(Card.GetAttack)
end
function c114514027.deffilter(c)
	return c:IsSetCard(0xf1) and c:GetDefense()>=0
end
function c114514027.defval(e,c)
	local g=e:GetHandler():GetOverlayGroup():Filter(c114514027.deffilter,nil)
	return g:GetSum(Card.GetDefense)
end
function c114514027.cost(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,3,REASON_COST) end
	e:GetHandler():RemoveOverlayCard(tp,3,3,REASON_COST)
end
function c114514027.filter(c)
	return c:IsRace(RACE_BEASTWARRIOR) and c:IsAttackBelow(1800) and c:IsLevel(4) and c:IsAbleToHand()
end
function c114514027.target(e,tp,eg,ep,ev,re,r,rp,chk)
	if chk==0 then return Duel.IsExistingMatchingCard(c114514027.filter,tp,LOCATION_DECK,0,1,nil) end
	Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
	Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK)
end
function c114514027.operation(e,tp,eg,ep,ev,re,r,rp)
	Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
	local g=Duel.SelectMatchingCard(tp,c114514027.filter,tp,LOCATION_DECK,0,1,1,nil)
	if g:GetCount()>0 then
		Duel.SendtoHand(g,nil,REASON_EFFECT)
		Duel.ConfirmCards(1-tp,g)
	end
end
