local BRoleLogic = require("billboard.BRoleLogic")
local BillboardDB = require("billboard.BillboardDB")
local BillboardDefine = require("billboard.BillboardDefine")

local WORLD_LV = 0 -- 世界等级
local LV_CNT = 20  -- 计算人次

function getWorldLv()
   return WORLD_LV
end

function doCalcWorldLv()
	local board = BillboardDB.getBoard(BillboardDefine.TYPE_LV)
    if board == nil then
        return
    end

    local boardLen = #board.rank2data
    boardLen = math.min(boardLen, LV_CNT)
    local lvTotal = 0
    for i = 1, boardLen do
        local rankData = board.rank2data[i]
        if rankData then
           lvTotal = lvTotal + rankData.value1
		end
    end
	
	if lvTotal > 0 then
	   WORLD_LV = math.floor(lvTotal / boardLen)
	end
end


