﻿--BUFF 範圍
local range = 2

--自身每回合開始時回復周圍2單位距離內友軍30%內力值
local aroundUnits = {}

function EndMove()
	--更新一下
	Search()
end

function BeginUnit()
	--更新一下
	Search()
	
	--對所有單位進行敵軍判斷
	for i = 1 ,#aroundUnits do 
		OnEvent(aroundUnits[i])
	end
	
end

function Search()

	--搜尋範圍內所有單位
	local newAround = controller.GetAroundUnit(unit, range)
	aroundUnits = newAround
end


function OnEvent(_unit)
	--判斷是友軍、回復內力30%
	if unit.IsEnemy(_unit) == false and _unit.Id ~= unit.Id then
		

		_unit[Prop.MP] = _unit[Prop.MP] + _unit[Prop.MaxMP] * 0.30
		controller.PrintProp(_unit, item.Name, Prop.MP, _unit[Prop.MaxMP] * 0.30)
		
		print(_unit.Name .. " 受到「拱石村長」的影響，回復內力值30%")
	end
end