|
|
@@ -72,14 +72,14 @@ local function isRunning()
|
|
|
end
|
|
|
|
|
|
|
|
|
-
|
|
|
-- 进入新一轮的处理
|
|
|
local function newRoundHandle()
|
|
|
local stage = AnotherWorldBattleDB.GetStage()
|
|
|
|
|
|
-- 上一轮奖励没有发放, 在新一轮开始时, 先发奖
|
|
|
if stage == AnotherWorldBattleDefine.AB_STATE_AWARD then
|
|
|
- -- AwardPrizesHandle()
|
|
|
+ IssueRewardManager()
|
|
|
+ return AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_END)
|
|
|
end
|
|
|
|
|
|
-- 重置数据
|
|
|
@@ -200,7 +200,6 @@ local function grouping()
|
|
|
|
|
|
AnotherWorldBattleDB.UpdateGroupArray(newGroupArray)
|
|
|
end
|
|
|
-
|
|
|
-- 给各个分组中的公会随机分配出生点
|
|
|
local function randomBaseCity()
|
|
|
local baseCityIdArr = {}
|
|
|
@@ -228,39 +227,53 @@ local function randomBaseCity()
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-
|
|
|
--- 统计单个公会的占领情况, 用于发放奖励
|
|
|
-local function genUnionOccupyInfo(unionId, union)
|
|
|
+-- 统计公会的占领情况, 用于发放奖励
|
|
|
+local function genUnionOccupyInfo(unionId, union, playerListData)
|
|
|
local occupyTb = {
|
|
|
- occupyCityArr = {}, -- 曾占领, 当前还占领的城池列表
|
|
|
+ occupyCityArr = {}, -- 当前还占领的城池列表
|
|
|
+ point2CityIdArr = {}, -- 曾占领/当前还占领的据点的所属城池Id列表
|
|
|
occuoyPointNum = 0,
|
|
|
playerUuidArr = {},
|
|
|
+ unionId = unionId,
|
|
|
}
|
|
|
|
|
|
local now = os.time()
|
|
|
local tbl = occupyTb.occupyCityArr
|
|
|
- tbl[#tbl+1] = { union.baseCityId, { {union.baseCityStartTime, union.baseCityEndTime or now} }, true }
|
|
|
-
|
|
|
+ tbl[#tbl+1] = union.baseCityId
|
|
|
|
|
|
+ local tbl2 = occupyTb.point2CityIdArr
|
|
|
for cityId, cityIno in pairs(union.occupCityList or {}) do
|
|
|
- if cityIno.isOccupy or cityIno.occupyTimeArr then
|
|
|
- -- 更新目前还占领的城池的占领结束时间
|
|
|
- local lastTimeTb = cityIno.occupyTimeArr[#cityIno.occupyTimeArr]
|
|
|
- if #lastTimeTb == 1 then
|
|
|
- lastTimeTb[2] = now
|
|
|
+ if cityIno.isOccupy then
|
|
|
+ tbl[#tbl+1] = cityId
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, pointInfo in pairs(cityIno.occupyPointList) do
|
|
|
+ if pointInfo.playerUuid then
|
|
|
+ occupyTb.occuoyPointNum = occupyTb.occuoyPointNum + 1
|
|
|
+
|
|
|
+ -- 更新据点最新占领时间段的结束时间
|
|
|
+ local occupyTimeArr = pointInfo.occupyTimeArr
|
|
|
+ local lastTimeTb = occupyTimeArr[#occupyTimeArr]
|
|
|
+ if #lastTimeTb == 1 then
|
|
|
+ occupyTimeArr[#occupyTimeArr][2] = now
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
- tbl[#tbl+1] = { cityId, cityIno.occupyTimeArr, cityIno.isOccupy }
|
|
|
+ tbl2[#tbl2+1] = {cityId, pointInfo.occupyTimeArr}
|
|
|
end
|
|
|
+ end
|
|
|
|
|
|
- for _,_ in pairs(cityIno.occupyPointList) do
|
|
|
- occupyTb.occuoyPointNum = occupyTb.occuoyPointNum + 1
|
|
|
- end
|
|
|
+ -- 出生点算5个据点
|
|
|
+ local baseCiyuTimeArr = { {union.baseCityStartTime, union.baseCityEndTime or now } }
|
|
|
+ for i=1, AnotherWorldBattleDefine.AB_POINT_MAX_NUM do
|
|
|
+ tbl2[#tbl2+1] = {union.baseCityId, baseCiyuTimeArr}
|
|
|
end
|
|
|
|
|
|
- local tbl2 = occupyTb.playerUuidArr
|
|
|
- for playerUuid in pairs(union.playerList) do
|
|
|
- tbl2[#tbl2+1] = playerUuid
|
|
|
+
|
|
|
+ for playerUuid, playerInfo in pairs(playerListData) do
|
|
|
+ if playerInfo.unionId == unionId then
|
|
|
+ occupyTb.playerUuidArr[#occupyTb.playerUuidArr+1] = playerUuid
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
-- 防止本次没有正常发放奖励,后续补发时, 结束时间异常的情况
|
|
|
@@ -278,35 +291,27 @@ local function issueReward(sourceServerId, occupyInfo)
|
|
|
InnerMsg.sendMsg(fd, msgData)
|
|
|
end
|
|
|
|
|
|
-
|
|
|
-- 奖励发放管理函数
|
|
|
-local function issueRewardManager()
|
|
|
+function IssueRewardManager()
|
|
|
local delay_sec = 0
|
|
|
local unionList = AnotherWorldBattleDB.GetUnionList()
|
|
|
+ local playerListData = AnotherWorldBattleDB.GetPlayerList()
|
|
|
|
|
|
for unionId, union in pairs(unionList) do
|
|
|
- local occupyInfo = genUnionOccupyInfo(unionId, union)
|
|
|
+ local occupyInfo = genUnionOccupyInfo(unionId, union, playerListData)
|
|
|
delay_sec = delay_sec + 5
|
|
|
Timer.addLater(delay_sec, issueReward, union.serverId, occupyInfo)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-function oneMin()
|
|
|
- if _G.is_middle ~= true then return end
|
|
|
-
|
|
|
- if not isOpen() then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
- -- 与 onHour() 处理错开
|
|
|
- if Util.getMin() == 0 then
|
|
|
- return
|
|
|
- end
|
|
|
-
|
|
|
+-- 检测活动各阶段及相关处理
|
|
|
+local function timedStageHandle()
|
|
|
-- 处于报名阶段
|
|
|
- if table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
|
|
|
+ -- if table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
|
|
|
+ -- joinStageCheck()
|
|
|
+ -- end
|
|
|
+
|
|
|
+ if wDay == AnotherWorldBattleDefine.AB_JOIN_WDAY then
|
|
|
joinStageCheck()
|
|
|
end
|
|
|
|
|
|
@@ -324,7 +329,7 @@ function oneMin()
|
|
|
-- 给各个分组中的公会随机分配出生点
|
|
|
randomBaseCity()
|
|
|
|
|
|
- -- 最后更新活动阶段
|
|
|
+ -- 改为战斗阶段
|
|
|
return AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_BATTLE)
|
|
|
end
|
|
|
end
|
|
|
@@ -334,75 +339,53 @@ function oneMin()
|
|
|
if wDay == AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] and now >= (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
|
|
|
local stage = AnotherWorldBattleDB.GetStage()
|
|
|
|
|
|
- if stage == AnotherWorldBattleDefine.AB_STATE_BATTLE then
|
|
|
+ if stage == AnotherWorldBattleDefine.AB_STATE_BATTLE or stage == AnotherWorldBattleDefine.AB_STATE_AWARD then
|
|
|
-- 改为发奖阶段
|
|
|
AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_AWARD)
|
|
|
|
|
|
-- 开始发奖
|
|
|
- issueRewardManager()
|
|
|
+ IssueRewardManager()
|
|
|
|
|
|
-- 改为结束阶段
|
|
|
return AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_END)
|
|
|
end
|
|
|
-
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-function onHour(hour)
|
|
|
- if _G.is_middle ~= true then return end
|
|
|
|
|
|
- if hour == 0 or not wDay then
|
|
|
- updateWDay()
|
|
|
- end
|
|
|
+
|
|
|
+function oneMin()
|
|
|
+ if _G.is_middle ~= true then return end
|
|
|
|
|
|
if not isOpen() then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- -- 处于报名阶段
|
|
|
- if table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
|
|
|
- joinStageCheck()
|
|
|
+ -- 与 onHour() 处理错开
|
|
|
+ if Util.getMin() == 0 then
|
|
|
+ return
|
|
|
end
|
|
|
|
|
|
- local now = os.time()
|
|
|
-
|
|
|
- -- 报名阶段 -> 战斗阶段
|
|
|
- if wDay >= AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[1] and wDay <= AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] then
|
|
|
- local stage = AnotherWorldBattleDB.GetStage()
|
|
|
- local toDayStartTime = getTodayStartTime()
|
|
|
-
|
|
|
- if stage == AnotherWorldBattleDefine.AB_STATE_JOIN and now >= (toDayStartTime + AnotherWorldBattleDefine.AB_START_SEC) then
|
|
|
- -- 分组
|
|
|
- grouping()
|
|
|
+ timedStageHandle()
|
|
|
+end
|
|
|
|
|
|
- -- 给各个分组中的公会随机分配出生点
|
|
|
- randomBaseCity()
|
|
|
+function onHour(hour)
|
|
|
+ if _G.is_middle ~= true then return end
|
|
|
|
|
|
- -- 最后更新活动阶段
|
|
|
- return AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_BATTLE)
|
|
|
- end
|
|
|
+ if hour == 0 or not wDay then
|
|
|
+ updateWDay()
|
|
|
end
|
|
|
|
|
|
- -- 战斗阶段 -> 发奖阶段
|
|
|
- local toDayStartTime = getTodayStartTime()
|
|
|
- if wDay == AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] and now >= (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
|
|
|
- local stage = AnotherWorldBattleDB.GetStage()
|
|
|
-
|
|
|
- if stage == AnotherWorldBattleDefine.AB_STATE_BATTLE then
|
|
|
- AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_AWARD)
|
|
|
-
|
|
|
- -- 开始发奖
|
|
|
- issueRewardManager()
|
|
|
-
|
|
|
- -- 改为结束阶段
|
|
|
- return AnotherWorldBattleDB.UpdateStage(AnotherWorldBattleDefine.AB_STATE_END)
|
|
|
- end
|
|
|
-
|
|
|
+ if not isOpen() then
|
|
|
+ return
|
|
|
end
|
|
|
+
|
|
|
+ timedStageHandle()
|
|
|
end
|
|
|
|
|
|
|
|
|
------------------------------------C2N---------------------------------------------------
|
|
|
+
|
|
|
-- 错误提示
|
|
|
local function errTips(sourceServerId, playerUuid, errCode)
|
|
|
local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_TIPS
|
|
|
@@ -426,6 +409,22 @@ end
|
|
|
|
|
|
------------------------------------N2C---------------------------------------------------
|
|
|
|
|
|
+-- 获取自己公会的组Id
|
|
|
+local function getMyUnionGourpId(myUnionId)
|
|
|
+ local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ return groupId
|
|
|
+end
|
|
|
+
|
|
|
+-- 获取自己公会/所在区服第一公会的组Id
|
|
|
+local function getGroupId(myUnionId, myServerId)
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
+ if not groupId then
|
|
|
+ groupId = AnotherWorldBattleDB.GetGroupIdByServerId(myServerId)
|
|
|
+ end
|
|
|
+
|
|
|
+ return groupId
|
|
|
+end
|
|
|
+
|
|
|
-- 统计单个服公会报名数量
|
|
|
local function calcSvrUnionJoinNum(serverId)
|
|
|
local num = 0
|
|
|
@@ -472,19 +471,22 @@ local function calcOccupyCityNum(occupCityList, cityLv)
|
|
|
return num
|
|
|
end
|
|
|
|
|
|
--- 统计公会占领的据点数量
|
|
|
-local function calcOccupyPointNum(occupCityList)
|
|
|
+-- 统计公会占领的据点所属城池数组
|
|
|
+local function calcOccupyPointArr(occupCityList)
|
|
|
+ local pointInfoArr = {}
|
|
|
+
|
|
|
if not occupCityList then
|
|
|
- return 0
|
|
|
+ return pointInfoArr
|
|
|
end
|
|
|
|
|
|
- local num = 0
|
|
|
for cityId, occupyInfo in pairs(occupCityList) do
|
|
|
- for _,_ in pairs(occupyInfo.occupyPointList) do
|
|
|
- num = num + 1
|
|
|
+ for _, pointInfo in pairs(occupyInfo.occupyPointList) do
|
|
|
+ if pointInfo.playerUuid then
|
|
|
+ pointInfoArr[#pointInfoArr+1] = cityId
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
- return num
|
|
|
+ return pointInfoArr
|
|
|
end
|
|
|
|
|
|
-- 获取公会占领的城池列表
|
|
|
@@ -526,67 +528,74 @@ local function isadJoin(cityIdArr, targetCityId)
|
|
|
return false
|
|
|
end
|
|
|
|
|
|
+-- 统计玩家占据的据点数量
|
|
|
+local function calcPlayerOccupyPointNum(playerUuid)
|
|
|
+ local playerOccupyPonitNum = 0
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ if playerData and playerData.heroList then
|
|
|
+ for _, pointList in pairs(playerData.heroList) do
|
|
|
+ for _, _ in pairs(pointList) do
|
|
|
+ playerOccupyPonitNum = playerOccupyPonitNum + 1
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ return playerOccupyPonitNum
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
-- 检查某个据点是否能被玩家挑战
|
|
|
local function isCanChallengePoint(targetCityId, targetPointIdx, myUnionId, playerUuid)
|
|
|
-- 活动未开启
|
|
|
if not isRunning() then
|
|
|
- return false
|
|
|
+ return -1
|
|
|
end
|
|
|
|
|
|
-- 公会没有参加活动
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
if not groupId then
|
|
|
- return false
|
|
|
+ return -2
|
|
|
end
|
|
|
|
|
|
local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
|
|
|
local tagetCityData = cityList[targetCityId]
|
|
|
if not tagetCityData then
|
|
|
- return false
|
|
|
- end
|
|
|
-
|
|
|
- -- 城池已被本公会占领
|
|
|
- if tagetCityData.occupyUnion and tagetCityData.occupyUnion == myUnionId then
|
|
|
- return false
|
|
|
+ return -3
|
|
|
end
|
|
|
|
|
|
local targetPointData = tagetCityData.pointArr[targetPointIdx]
|
|
|
if not targetPointData then
|
|
|
- return false
|
|
|
+ return -5
|
|
|
end
|
|
|
|
|
|
+ -- 自己占领了该据点
|
|
|
+ if targetPointData.unionId and targetPointData.unionId == myUnionId and targetPointData.playerUuid == playerUuid then
|
|
|
+ return 2
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 据点已被本公会占领
|
|
|
+ if tagetCityData.occupyUnion and tagetCityData.occupyUnion == myUnionId then
|
|
|
+ return -4
|
|
|
+ end
|
|
|
+
|
|
|
+
|
|
|
-- 据点已被本公会占领
|
|
|
if targetPointData.unionId and targetPointData.unionId == myUnionId then
|
|
|
- return false
|
|
|
+ return -6
|
|
|
end
|
|
|
|
|
|
local myUnionData = AnotherWorldBattleDB.GetUnionData(myUnionId)
|
|
|
if not myUnionData then
|
|
|
- return false
|
|
|
+ return -7
|
|
|
end
|
|
|
|
|
|
-- 城池是否相邻
|
|
|
local occupyCityArr = getUnionOccupyArr(myUnionId)
|
|
|
if not isadJoin(occupyCityArr, targetCityId) then
|
|
|
- return false
|
|
|
+ return -8
|
|
|
end
|
|
|
|
|
|
- -- 每个玩家最多占领据点数量是否超出
|
|
|
- local playerOccupyPonitNum = 0
|
|
|
- if myUnionData.playerList and myUnionData.playerList[playerUuid] then
|
|
|
- local heroList = myUnionData.playerList[playerUuid].heroList
|
|
|
- for cityId, pointList in pairs(heroList) do
|
|
|
- for _, _ in pairs(pointList) do
|
|
|
- playerOccupyPonitNum = playerOccupyPonitNum + 1
|
|
|
- end
|
|
|
- end
|
|
|
- end
|
|
|
-
|
|
|
- if playerOccupyPonitNum >= AnotherWorldBattleDefine.AB_PLAYER_OCCUPY_POINT_MAX_NUM then
|
|
|
- return false
|
|
|
- end
|
|
|
-
|
|
|
- return true
|
|
|
+ return 1
|
|
|
end
|
|
|
|
|
|
-- 公会是否能报名
|
|
|
@@ -622,60 +631,73 @@ local function isCompleteOccupy(cityData, myUnionId)
|
|
|
return true
|
|
|
end
|
|
|
|
|
|
--- 查询玩家是否上榜
|
|
|
-local function getPlayerRank(playerRankList, playerUuid)
|
|
|
- for _, rankData in ipairs(playerRankList) do
|
|
|
- if rankData.playerUuid == playerUuid then
|
|
|
- return true
|
|
|
- end
|
|
|
+-- 获取玩家挑战次数相关数据
|
|
|
+local function getPlayerChallengeTimesInfo(playerUuid)
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ if not playerData then
|
|
|
+ return AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES, 0
|
|
|
end
|
|
|
|
|
|
- return false
|
|
|
-end
|
|
|
+ local now = os.time()
|
|
|
+ local subSex = now - playerData.lastTime
|
|
|
+
|
|
|
+ if subSex >= AnotherWorldBattleDefine.AB_PLAYER_CHALLENGETIMES_SEC then
|
|
|
+ local addTimes = math.floor(subSex / AnotherWorldBattleDefine.AB_PLAYER_CHALLENGETIMES_SEC)
|
|
|
+ playerData.challengeTimes = math.min(playerData.challengeTimes + addTimes, AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES)
|
|
|
+ playerData.lastTime = playerData.lastTime + addTimes* AnotherWorldBattleDefine.AB_PLAYER_CHALLENGETIMES_SEC
|
|
|
|
|
|
--- 更新公会排行榜数据
|
|
|
-local function updateUnionRanktData(unionRankList, unionId, cityNum, pointNum)
|
|
|
- for rank, rankData in ipairs(unionRankList) do
|
|
|
- if rankData.unionId == unionId then
|
|
|
- unionRankList[rank].occupyCityNum = unionRankList[rank].occupyCityNum + cityNum
|
|
|
- unionRankList[rank].occupyPointNum = unionRankList[rank].occupyPointNum + pointNum
|
|
|
+ if playerData.challengeTimes == AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES then
|
|
|
+ playerData.lastTime = 0
|
|
|
end
|
|
|
+
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
|
|
|
end
|
|
|
+
|
|
|
+ return playerData.challengeTimes, playerData.lastTime
|
|
|
end
|
|
|
|
|
|
--- 更新玩家排行榜数据
|
|
|
-local function updatePlayerRanktData(playerRankList, playerUuid, pointNum, pointWeight)
|
|
|
- local playerRank = 0
|
|
|
- for rank, rankData in ipairs(playerRankList) do
|
|
|
- if rankData.playerUuid == playerUuid then
|
|
|
- playerRank = rank
|
|
|
- end
|
|
|
+-- 获取城池被占领状态
|
|
|
+local function getCityState(cityData)
|
|
|
+ local state = 0
|
|
|
+ if cityData.occupyUnion then
|
|
|
+ state = 1
|
|
|
+ return state
|
|
|
end
|
|
|
|
|
|
- if playerRank ~= 0 then
|
|
|
- playerRankList[playerRank].pointNum = playerRankList[playerRank].pointNum + pointNum
|
|
|
- playerRankList[playerRank].pointAllWeight = playerRankList[playerRank].pointAllWeight + pointWeight
|
|
|
- end
|
|
|
-end
|
|
|
+ local occupyPlayerUuid
|
|
|
+ for _, pointInfo in ipairs(cityData.pointArr) do
|
|
|
+ if pointInfo.playerUuid then
|
|
|
+ if not occupyPlayerUuid then
|
|
|
+ occupyPlayerUuid = pointInfo.playerUuid
|
|
|
+ end
|
|
|
|
|
|
+ if pointInfo.playerUuid ~= occupyPlayerUuid then
|
|
|
+ state = 2
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
|
|
|
+ return state
|
|
|
+end
|
|
|
|
|
|
|
|
|
-- 查询状态
|
|
|
function N2C_Get_State(msg)
|
|
|
- local sourceServerId = msg.sourceServerId
|
|
|
-
|
|
|
local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_GET_STATE
|
|
|
msgData.playerUuid = msg.playerUuid
|
|
|
+ msgData.systemState = 0
|
|
|
+ msgData.joinState = 0
|
|
|
|
|
|
local stage = AnotherWorldBattleDB.GetStage()
|
|
|
msgData.systemState = stage
|
|
|
- msgData.joinState = 0
|
|
|
|
|
|
if stage == 0 then
|
|
|
local lastRoundStartTime = AnotherWorldBattleDB.GetLastRoundStartTime()
|
|
|
if lastRoundStartTime == 0 then
|
|
|
msgData.systemState = 0
|
|
|
+ else
|
|
|
+ msgData.systemState = 3
|
|
|
end
|
|
|
end
|
|
|
|
|
|
@@ -686,6 +708,7 @@ function N2C_Get_State(msg)
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ local sourceServerId = msg.sourceServerId
|
|
|
local num = calcSvrUnionJoinNum(sourceServerId)
|
|
|
if num >= AnotherWorldBattleDefine.AB_SRV_UNION_MAX_NUM then
|
|
|
msgData.joinState = 2
|
|
|
@@ -708,6 +731,7 @@ function N2C_Join(msg)
|
|
|
return errTips(sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_8)
|
|
|
end
|
|
|
|
|
|
+ -- 更新参赛列表数据
|
|
|
local joinUnionArr = AnotherWorldBattleDB.GetJoinUnionArr()
|
|
|
joinUnionArr = joinUnionArr or {}
|
|
|
joinUnionArr[#joinUnionArr+1] = {
|
|
|
@@ -715,18 +739,15 @@ function N2C_Join(msg)
|
|
|
power = unionInfo.power,
|
|
|
serverId = sourceServerId
|
|
|
}
|
|
|
-
|
|
|
AnotherWorldBattleDB.UpdateJoinUnionArr(joinUnionArr)
|
|
|
|
|
|
- local unionList = AnotherWorldBattleDB.GetUnionList()
|
|
|
- unionList = unionList or {}
|
|
|
- unionList[unionInfo.unionId] = {
|
|
|
+ -- 更新公会列表数据
|
|
|
+ local newUnionData = {
|
|
|
serverId = sourceServerId,
|
|
|
power = unionInfo.power,
|
|
|
name = unionInfo.name,
|
|
|
}
|
|
|
-
|
|
|
- AnotherWorldBattleDB.UpdateUnionList(unionList)
|
|
|
+ AnotherWorldBattleDB.UpdateUnionData(unionInfo.unionId, newUnionData)
|
|
|
|
|
|
-- 通知报名成功
|
|
|
local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_JOIN
|
|
|
@@ -739,15 +760,17 @@ end
|
|
|
-- 查询所有城池信息
|
|
|
function N2C_AllCity_Query(msg)
|
|
|
local myUnionId = msg.myUnionId
|
|
|
-
|
|
|
local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_ALLCITY_QUERY
|
|
|
msgData.cityArr = {}
|
|
|
msgData.playerUuid = msg.playerUuid
|
|
|
msgData.myUnionBaseCityId = 0
|
|
|
msgData.myOccupyCityArr = {}
|
|
|
+ msgData.hasPointNum = 0
|
|
|
+ msgData.challengeTimes = 0
|
|
|
+ msgData.lastTime = 0
|
|
|
local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
|
|
|
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getGroupId(myUnionId, msg.sourceServerId)
|
|
|
if not groupId then
|
|
|
-- 报名阶段, 或者活动开未开启过处于默认的结束状态
|
|
|
local stage = AnotherWorldBattleDB.GetStage()
|
|
|
@@ -778,9 +801,15 @@ function N2C_AllCity_Query(msg)
|
|
|
cityArrMsg[cityId].occupyPointNum = cityArrMsg[cityId].occupyPointNum + 1
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
+ cityArrMsg[cityId].cityState = getCityState(cityInfo)
|
|
|
end
|
|
|
|
|
|
msgData.myOccupyCityArr = getUnionOccupyArr(myUnionId)
|
|
|
+ msgData.hasPointNum = calcPlayerOccupyPointNum(msg.playerUuid)
|
|
|
+ local challengeTimes, leftTime = getPlayerChallengeTimesInfo(msg.playerUuid)
|
|
|
+ msgData.challengeTimes = challengeTimes
|
|
|
+ msgData.lastTime = leftTime
|
|
|
|
|
|
InnerMsg.sendMsg(fd, msgData)
|
|
|
end
|
|
|
@@ -799,7 +828,7 @@ function N2C_CityDetailed_Query(msg)
|
|
|
msgData.pointArr = {}
|
|
|
msgData.gatherState = 0
|
|
|
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getGroupId(myUnionId, msg.sourceServerId)
|
|
|
if not groupId then
|
|
|
-- 报名阶段, 或者活动开未开启过处于默认的结束状态
|
|
|
local stage = AnotherWorldBattleDB.GetStage()
|
|
|
@@ -816,25 +845,32 @@ function N2C_CityDetailed_Query(msg)
|
|
|
end
|
|
|
|
|
|
|
|
|
- local cityData = cityList[targetCityId]
|
|
|
- local myUnionOccupyArr = getUnionOccupyArr(myUnionId)
|
|
|
+ local union = AnotherWorldBattleDB.GetUnionData(myUnionId)
|
|
|
+ local occupCityList = union and union.occupCityList
|
|
|
+ local myUnionOccupyArr = calcOccupyPointArr(occupCityList)
|
|
|
+ if union then
|
|
|
+ myUnionOccupyArr[#myUnionOccupyArr+1] = union.baseCityId
|
|
|
+ end
|
|
|
msgData.myUnionOccupyArr = myUnionOccupyArr
|
|
|
|
|
|
-
|
|
|
+ local cityData = cityList[targetCityId]
|
|
|
local pointArrMsg = msgData.pointArr
|
|
|
+
|
|
|
for pointIdx, occupyInfo in ipairs(cityData.pointArr) do
|
|
|
pointArrMsg[pointIdx] = {}
|
|
|
- local bl = isCanChallengePoint(targetCityId, pointIdx, myUnionId, playerUuid)
|
|
|
- pointArrMsg[pointIdx].isCanChallenge = bl and 1 or 0
|
|
|
+ local state = isCanChallengePoint(targetCityId, pointIdx, myUnionId, playerUuid)
|
|
|
+ pointArrMsg[pointIdx].state = state < 0 and 0 or state
|
|
|
|
|
|
if occupyInfo.unionId and occupyInfo.playerUuid then
|
|
|
local occupyUnionData = AnotherWorldBattleDB.GetUnionData(occupyInfo.unionId)
|
|
|
- if occupyUnionData then
|
|
|
+ local occupyPlayerData = AnotherWorldBattleDB.GetPlayerData(occupyInfo.playerUuid)
|
|
|
+
|
|
|
+ if occupyUnionData and occupyPlayerData then
|
|
|
pointArrMsg[pointIdx].occupyUnionName = occupyUnionData.name
|
|
|
- pointArrMsg[pointIdx].occupyPlayerName = occupyUnionData.playerList[occupyInfo.playerUuid].name
|
|
|
+ pointArrMsg[pointIdx].occupyPlayerName = occupyPlayerData.name
|
|
|
|
|
|
pointArrMsg[pointIdx].power = 0
|
|
|
- local heroList = occupyUnionData.playerList[occupyInfo.playerUuid].heroList
|
|
|
+ local heroList = occupyPlayerData.heroList
|
|
|
if heroList and heroList[targetCityId] and heroList[targetCityId][pointIdx] then
|
|
|
pointArrMsg[pointIdx].power = calcHerosPower(heroList[targetCityId][pointIdx])
|
|
|
end
|
|
|
@@ -882,7 +918,7 @@ function N2C_PointDetailed_Query(msg)
|
|
|
msgData.targetPointIdx = targetPointIdx
|
|
|
msgData.pointInfo = {}
|
|
|
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getGroupId(myUnionId, msg.sourceServerId)
|
|
|
if not groupId then
|
|
|
-- 报名阶段, 或者活动开未开启过处于默认的结束状态
|
|
|
local stage = AnotherWorldBattleDB.GetStage()
|
|
|
@@ -907,12 +943,7 @@ function N2C_PointDetailed_Query(msg)
|
|
|
|
|
|
local pointInfoMsg = msgData.pointInfo
|
|
|
if pointData.unionId and pointData.playerUuid then
|
|
|
- local union = AnotherWorldBattleDB.GetUnionData(pointData.unionId)
|
|
|
- if not union then
|
|
|
- return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_4)
|
|
|
- end
|
|
|
-
|
|
|
- local playerData = union.playerList and union.playerList[pointData.playerUuid]
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(pointData.playerUuid)
|
|
|
if not playerData then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_4)
|
|
|
end
|
|
|
@@ -936,12 +967,14 @@ function N2C_PointDetailed_Query(msg)
|
|
|
heroLv = heroInfo.heroLevel,
|
|
|
heroCamp = heroInfo.heroCamp,
|
|
|
heroIcon = heroInfo.heroIcon,
|
|
|
+ heroId = heroInfo.heroId,
|
|
|
+ heroQuality = heroInfo.heroQuality,
|
|
|
}
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- local isCanChallenge = isCanChallengePoint(targetCityId, targetPointIdx, myUnionId, msg.playerUuid)
|
|
|
- pointInfoMsg.isCanChallenge = isCanChallenge and 1 or 0
|
|
|
+ local state = isCanChallengePoint(targetCityId, targetPointIdx, myUnionId, msg.playerUuid)
|
|
|
+ pointInfoMsg.state = state < 0 and 0 or state
|
|
|
|
|
|
InnerMsg.sendMsg(fd, msgData)
|
|
|
end
|
|
|
@@ -949,7 +982,7 @@ end
|
|
|
-- 查询公会出生点信息
|
|
|
function N2C_BaseCity_Query(msg)
|
|
|
local myUnionId = msg.myUnionId
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getGroupId(myUnionId, msg.sourceServerId)
|
|
|
if not groupId then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
|
|
|
end
|
|
|
@@ -966,8 +999,10 @@ function N2C_BaseCity_Query(msg)
|
|
|
msgData.baseCityInfo = baseCityInfo
|
|
|
|
|
|
baseCityInfo.cityId = union.baseCityId
|
|
|
- baseCityInfo.occupyPointNum = calcOccupyPointNum(union.occupCityList)
|
|
|
- baseCityInfo.myUnionOccupyArr = getUnionOccupyArr(myUnionId)
|
|
|
+ local pointInfoArr = calcOccupyPointArr(union.occupCityList)
|
|
|
+ baseCityInfo.occupyPointNum = #pointInfoArr
|
|
|
+ baseCityInfo.myUnionOccupyArr = calcOccupyPointArr(union.occupCityList)
|
|
|
+ baseCityInfo.myUnionOccupyArr[#baseCityInfo.myUnionOccupyArr+1] = baseCityInfo.cityId
|
|
|
baseCityInfo.occupyCityLv2Num = calcOccupyCityNum(union.occupCityList, 2)
|
|
|
baseCityInfo.occupyCityLv3Num = calcOccupyCityNum(union.occupCityList, 3)
|
|
|
baseCityInfo.occupyCityLv4Num = calcOccupyCityNum(union.occupCityList, 4)
|
|
|
@@ -999,14 +1034,14 @@ function N2C_PlayerOccupyPoint_Query(msg)
|
|
|
end
|
|
|
|
|
|
|
|
|
- local playerList = union.playerList
|
|
|
- if not playerList[playerUuid] then
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ if not playerData then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_5)
|
|
|
end
|
|
|
|
|
|
- local heroList = playerList[playerUuid].heroList
|
|
|
+ local heroList = playerData.heroList
|
|
|
if not heroList then
|
|
|
- return errTips(msg.sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_4)
|
|
|
+ return errTips(msg.sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_5)
|
|
|
end
|
|
|
|
|
|
|
|
|
@@ -1020,14 +1055,16 @@ function N2C_PlayerOccupyPoint_Query(msg)
|
|
|
heroArr = {},
|
|
|
}
|
|
|
|
|
|
- local TargetHeroArr = occupyPointArrMsg[#occupyPointArrMsg].heroArr
|
|
|
+ local targetHeroArr = occupyPointArrMsg[#occupyPointArrMsg].heroArr
|
|
|
for _, heroInfo in ipairs(heroInfoArr) do
|
|
|
- TargetHeroArr[#TargetHeroArr+1] = {
|
|
|
+ targetHeroArr[#targetHeroArr+1] = {
|
|
|
heroBody = heroInfo.heroBody,
|
|
|
heroStar = heroInfo.heroStar,
|
|
|
heroLv = heroInfo.heroLevel,
|
|
|
heroCamp = heroInfo.heroCamp,
|
|
|
heroIcon = heroInfo.heroIcon,
|
|
|
+ heroId = heroInfo.heroId,
|
|
|
+ heroQuality = heroInfo.heroQuality
|
|
|
}
|
|
|
end
|
|
|
end
|
|
|
@@ -1039,7 +1076,7 @@ end
|
|
|
-- 查询公会排行榜
|
|
|
function N2C_UnionRank_Query(msg)
|
|
|
local myUnionId = msg.myUnionId
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getGroupId(myUnionId, msg.sourceServerId)
|
|
|
if not groupId then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
|
|
|
end
|
|
|
@@ -1051,19 +1088,14 @@ function N2C_UnionRank_Query(msg)
|
|
|
msgData.unionRankArr = {}
|
|
|
|
|
|
for rank, randkData in ipairs(unionRankList) do
|
|
|
- if rank > AnotherWorldBattleDefine.AB_RANK_MAX_NUM then
|
|
|
- break
|
|
|
- end
|
|
|
-
|
|
|
- local unionName = AnotherWorldBattleDB.GetUnionName(randkData.unionId)
|
|
|
msgData.unionRankArr[rank] = {
|
|
|
- name = unionName,
|
|
|
+ name = randkData.name,
|
|
|
power = randkData.power,
|
|
|
cityNum = randkData.occupyCityNum,
|
|
|
pointNum = randkData.occupyPointNum,
|
|
|
}
|
|
|
|
|
|
- if randkData.unionId == myUnionId then
|
|
|
+ if randkData.guildId == myUnionId then
|
|
|
msgData.myUnionRank = rank
|
|
|
end
|
|
|
end
|
|
|
@@ -1075,7 +1107,7 @@ end
|
|
|
-- 查询玩家排行榜
|
|
|
function N2C_PlayerRank_Query(msg)
|
|
|
local myUnionId = msg.myUnionId
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getGroupId(myUnionId, msg.sourceServerId)
|
|
|
if not groupId then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
|
|
|
end
|
|
|
@@ -1091,15 +1123,14 @@ function N2C_PlayerRank_Query(msg)
|
|
|
break
|
|
|
end
|
|
|
|
|
|
- local playerName = AnotherWorldBattleDB.GetPlayerName(randkData.unionId, randkData.playerUuid)
|
|
|
- msgData.unionRankArr[rank] = {
|
|
|
- name = playerName,
|
|
|
+ msgData.playerRankArr[rank] = {
|
|
|
+ name = randkData.name,
|
|
|
power = randkData.power,
|
|
|
- pointNum = randkData.occupyPointNum,
|
|
|
+ pointNum = randkData.pointNum,
|
|
|
pointWeight = randkData.pointAllWeight,
|
|
|
}
|
|
|
|
|
|
- if randkData.playerUuid == msg.playerUuid then
|
|
|
+ if randkData.playerId == msg.playerUuid then
|
|
|
msgData.myRank = rank
|
|
|
end
|
|
|
end
|
|
|
@@ -1118,7 +1149,7 @@ function N2C_Gather(msg)
|
|
|
return errTips(sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_1)
|
|
|
end
|
|
|
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
if not groupId then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
|
|
|
end
|
|
|
@@ -1129,25 +1160,52 @@ function N2C_Gather(msg)
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
|
|
|
end
|
|
|
|
|
|
- local now = os.time()
|
|
|
- if myUnionData.gatherInfo then
|
|
|
- local gatherTime = myUnionData.gatherInfo.gatherTime
|
|
|
- if now - gatherTime < AnotherWorldBattleDefine.AB_GATHER_CD_SEC then
|
|
|
- return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_6)
|
|
|
+ local gatherInfo = myUnionData.gatherInfo
|
|
|
+ if msg.opType == 1 then --集结
|
|
|
+ -- 集结冷却时间判断
|
|
|
+ local now = os.time()
|
|
|
+ if gatherInfo then
|
|
|
+ local gatherTime = gatherInfo.gatherTime
|
|
|
+ if now - gatherTime < AnotherWorldBattleDefine.AB_GATHER_CD_SEC then
|
|
|
+ return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_6)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 城池是否相邻判断
|
|
|
+ local occupCityyArr = getUnionOccupyArr(myUnionId)
|
|
|
+ if not isadJoin(occupCityyArr, targetCityId) then
|
|
|
+ return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_7)
|
|
|
+ end
|
|
|
+
|
|
|
+ myUnionData.gatherInfo = myUnionData.gatherInfo or {}
|
|
|
+ myUnionData.gatherInfo.gatherTime = now
|
|
|
+ myUnionData.gatherInfo.gatherCity = targetCityId
|
|
|
+ else
|
|
|
+ -- 取消集结
|
|
|
+
|
|
|
+ if not gatherInfo then
|
|
|
+ return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_9)
|
|
|
+ end
|
|
|
+
|
|
|
+ if targetCityId ~= gatherInfo.gatherCity then
|
|
|
+ return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_9)
|
|
|
end
|
|
|
- end
|
|
|
|
|
|
- local occupCityyArr = getUnionOccupyArr(myUnionId)
|
|
|
- if not isadJoin(occupCityyArr, targetCityId) then
|
|
|
- return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_7)
|
|
|
+ gatherInfo.gatherCity = 0
|
|
|
end
|
|
|
|
|
|
- myUnionData.gatherInfo = myUnionData.gatherInfo or {}
|
|
|
- myUnionData.gatherInfo.gatherTime = now
|
|
|
- myUnionData.gatherInfo.gatherCity = targetCityId
|
|
|
AnotherWorldBattleDB.UpdateUnionData(myUnionId, myUnionData)
|
|
|
|
|
|
+ -- 推送城池数据给客户端,刷新界面
|
|
|
N2C_CityDetailed_Query(msg)
|
|
|
+
|
|
|
+ -- 发给本地服, 用于在公会聊天频道生成链接
|
|
|
+ local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_GATHER
|
|
|
+ msgData.playerUuid = msg.playerUuid
|
|
|
+ msgData.targetCityId = targetCityId
|
|
|
+ msgData.opType = msg.opType
|
|
|
+ local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
|
|
|
+ InnerMsg.sendMsg(fd, msgData)
|
|
|
end
|
|
|
|
|
|
-- 查询据点是否可以被挑战
|
|
|
@@ -1157,12 +1215,17 @@ function N2C_Try_Challengde_Point(msg)
|
|
|
local targetCityId = msg.targetCityId
|
|
|
local targetPointIdx = msg.targetPointIdx
|
|
|
|
|
|
- local isCanChallenge = isCanChallengePoint(targetCityId, msg.targetPointIdx, msg.myUnionId, playerUuid)
|
|
|
- if not isCanChallenge then
|
|
|
+ local state = isCanChallengePoint(targetCityId, msg.targetPointIdx, msg.myUnionId, playerUuid)
|
|
|
+ if state ~= 1 then
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local occupyPointNum = calcPlayerOccupyPointNum(msg.playerUuid)
|
|
|
+ if occupyPointNum >= AnotherWorldBattleDefine.AB_PLAYER_OCCUPY_POINT_MAX_NUM then
|
|
|
+ return errTips(msg.sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_10)
|
|
|
+ end
|
|
|
+
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
|
|
|
local targetPointData = cityList[targetCityId].pointArr[targetPointIdx]
|
|
|
|
|
|
@@ -1189,7 +1252,7 @@ function N2C_Try_Challengde_Point(msg)
|
|
|
end
|
|
|
|
|
|
-- 玩家挑战据点胜利
|
|
|
-function N2C_Point_Challenge_Win(msg)
|
|
|
+local function challenge_Win(msg)
|
|
|
local playerUuid = msg.playerUuid
|
|
|
local myUnionId = msg.myUnionId
|
|
|
local targetCityId = msg.targetCityId
|
|
|
@@ -1200,7 +1263,7 @@ function N2C_Point_Challenge_Win(msg)
|
|
|
return
|
|
|
end
|
|
|
|
|
|
- local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
if not groupId then
|
|
|
return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
|
|
|
end
|
|
|
@@ -1213,9 +1276,9 @@ function N2C_Point_Challenge_Win(msg)
|
|
|
local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
|
|
|
local cityData = cityList[targetCityId]
|
|
|
local pointData = cityData.pointArr[targetPointIdx]
|
|
|
- local unionRankList = AnotherWorldBattleDB.GetUnionRankList(groupId)
|
|
|
- local playerRankList = AnotherWorldBattleDB.GetPlayerRankList(groupId)
|
|
|
|
|
|
+ local now = os.time()
|
|
|
+ local cityNum, pointNum = 0, 1
|
|
|
local pointWeight = AnotherWorldBattleConfig.city[targetCityId].pointWeight
|
|
|
|
|
|
-- 防守方是真实玩家
|
|
|
@@ -1224,8 +1287,6 @@ function N2C_Point_Challenge_Win(msg)
|
|
|
local defUnionData = AnotherWorldBattleDB.GetUnionData(pointData.unionId)
|
|
|
local defOccupCityList = defUnionData.occupCityList
|
|
|
|
|
|
- local cityNum, pointNum = 0, -1
|
|
|
-
|
|
|
-- 防守方之前占领了城池
|
|
|
if defOccupCityList[targetCityId].isOccupy then
|
|
|
|
|
|
@@ -1233,23 +1294,28 @@ function N2C_Point_Challenge_Win(msg)
|
|
|
defOccupCityList[targetCityId].isOccupy = false
|
|
|
|
|
|
-- 更新防守方对该城池的最后占领时间
|
|
|
- local defOccupyTimeArr = defOccupCityList[targetCityId].occupyTimeArr
|
|
|
- defOccupyTimeArr[#defOccupyTimeArr][2] = os.time()
|
|
|
+ local defOccupyPointList = defOccupCityList[targetCityId].occupyPointList
|
|
|
+ local defPointInfo = defOccupyPointList[targetPointIdx]
|
|
|
+ local defOccupyTimeArr = defPointInfo.occupyTimeArr
|
|
|
+ defOccupyTimeArr[#defOccupyTimeArr][2] = now
|
|
|
|
|
|
-- 删除防守方的该据点的占领者
|
|
|
- local defOccupyPointList = defOccupCityList[targetCityId].occupyPointList
|
|
|
- defOccupyPointList[targetCityId] = nil
|
|
|
+ defPointInfo.playerUuid = nil
|
|
|
|
|
|
-- 删除防守方玩家的防守阵容数据
|
|
|
- local defPlayData = defUnionData.playerList[pointData.playerUuid]
|
|
|
- defPlayData.heroList[targetCityId][targetPointIdx] = nil
|
|
|
+ local defPlayData = AnotherWorldBattleDB.GetPlayerData(pointData.playerUuid)
|
|
|
+ if defPlayData then
|
|
|
+ defPlayData.heroList[targetCityId][targetPointIdx] = nil
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerData(pointData.playerUuid, defPlayData)
|
|
|
+ end
|
|
|
|
|
|
cityNum = -1
|
|
|
end
|
|
|
|
|
|
- -- 更新排行榜数据
|
|
|
- updateUnionRanktData(unionRankList, pointData.unionId, cityNum, pointNum)
|
|
|
- updatePlayerRanktData(playerRankList, pointData.playerUuid, pointNum, -pointWeight)
|
|
|
+ -- 更新防守方公会的排行榜数据
|
|
|
+ AnotherWorldBattleDB.UpdateUnionRankList(groupId, pointData.unionId, cityNum, pointNum)
|
|
|
+ -- 更新防守方玩家的排行榜数据
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerUuid, -pointNum, -pointWeight)
|
|
|
|
|
|
-- 通知玩家
|
|
|
pointLose(defUnionData.serverId, pointData.playerUuid, targetCityId, targetPointIdx)
|
|
|
@@ -1262,75 +1328,205 @@ function N2C_Point_Challenge_Win(msg)
|
|
|
pointData.unionId = myUnionId
|
|
|
pointData.playerUuid = playerUuid
|
|
|
|
|
|
- -- 更新进攻方公会数据——据点占有者
|
|
|
+ -- 更新进攻方公会数据—— 据点占有者, 最新的据点占有时间
|
|
|
myUnionData.occupCityList = myUnionData.occupCityList or {}
|
|
|
local occupCityList = myUnionData.occupCityList
|
|
|
occupCityList[targetCityId] = occupCityList[targetCityId] or {}
|
|
|
occupCityList[targetCityId].occupyPointList = occupCityList[targetCityId].occupyPointList or {}
|
|
|
- occupCityList[targetCityId].occupyPointList[targetPointIdx] = playerUuid
|
|
|
+ occupCityList[targetCityId].occupyPointList[targetPointIdx] = occupCityList[targetCityId].occupyPointList[targetPointIdx] or {}
|
|
|
+ local atkPointInfo = occupCityList[targetCityId].occupyPointList[targetPointIdx]
|
|
|
+ atkPointInfo.playerUuid = playerUuid
|
|
|
+ atkPointInfo.occupyTimeArr = atkPointInfo.occupyTimeArr or {}
|
|
|
+ atkPointInfo.occupyTimeArr[#atkPointInfo.occupyTimeArr+1] = { now }
|
|
|
|
|
|
--更新进攻者的展示数据
|
|
|
- myUnionData.playerList = myUnionData.playerList or {}
|
|
|
- myUnionData.playerList[playerUuid] = myUnionData.playerList[playerUuid] or {}
|
|
|
- local playerData = myUnionData.playerList[playerUuid]
|
|
|
- playerData.name = playerShowInfo.name
|
|
|
- playerData.lv = playerShowInfo.lv
|
|
|
- playerData.head = playerShowInfo.head
|
|
|
- playerData.headFrame = playerShowInfo.headFrame
|
|
|
- playerData.power = playerShowInfo.power
|
|
|
-
|
|
|
- playerData.heroList = playerData.heroList or {}
|
|
|
- playerData.heroList[targetCityId] = playerData.heroList[targetCityId] or {}
|
|
|
- playerData.heroList[targetCityId][targetPointIdx] = playerShowInfo.heroArr
|
|
|
-
|
|
|
-
|
|
|
- -- 更新公会排行榜数据: 进攻方公会占领据点数量+1
|
|
|
- updateUnionRanktData(unionRankList, myUnionId, 0, 1)
|
|
|
-
|
|
|
- local bl = getPlayerRank(playerRankList, playerUuid)
|
|
|
- if not bl then -- 如果玩家是第一次挑战据点, 则把玩家加入到玩家排行榜中
|
|
|
- playerRankList[#playerRankList+1] = {
|
|
|
- unionId = myUnionId,
|
|
|
- playerUuid = playerUuid,
|
|
|
- pointNum = 1,
|
|
|
- pointAllWeight = pointWeight,
|
|
|
- power = playerData.power
|
|
|
- }
|
|
|
- else
|
|
|
- updatePlayerRanktData(playerRankList, playerUuid, 1, pointWeight)
|
|
|
- end
|
|
|
+ local atkPlayerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ atkPlayerData = atkPlayerData or {}
|
|
|
+ atkPlayerData.name = playerShowInfo.name
|
|
|
+ atkPlayerData.lv = playerShowInfo.lv
|
|
|
+ atkPlayerData.head = playerShowInfo.head
|
|
|
+ atkPlayerData.headFrame = playerShowInfo.headFrame
|
|
|
+ atkPlayerData.power = playerShowInfo.power
|
|
|
+ atkPlayerData.unionId = myUnionId
|
|
|
+ -- 更新挑战次数
|
|
|
+ atkPlayerData.challengeTimes = (atkPlayerData.challengeTimes or AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES) - 1
|
|
|
+ if not atkPlayerData.lastTime or atkPlayerData.lastTime == 0 then
|
|
|
+ atkPlayerData.lastTime = os.time()
|
|
|
+ end
|
|
|
+ -- 增加防守阵容数据
|
|
|
+ atkPlayerData.heroList = atkPlayerData.heroList or {}
|
|
|
+ atkPlayerData.heroList[targetCityId] = atkPlayerData.heroList[targetCityId] or {}
|
|
|
+ atkPlayerData.heroList[targetCityId][targetPointIdx] = playerShowInfo.heroArr
|
|
|
+
|
|
|
+ cityNum = 0
|
|
|
|
|
|
-- 进攻方完全占领城池了
|
|
|
if isCompleteOccupy(cityData, myUnionId) then
|
|
|
-
|
|
|
-- 更新城池的占领公会
|
|
|
cityData.occupyUnion = myUnionId
|
|
|
|
|
|
-- 更新进攻方公会对该城池的占领状态
|
|
|
occupCityList[targetCityId].isOccupy = true
|
|
|
|
|
|
- -- 增加进攻方公会对该城池的占领开始时间戳
|
|
|
- local now = os.time()
|
|
|
- occupCityList[targetCityId].occupyTimeArr = occupCityList[targetCityId].occupyTimeArr or {}
|
|
|
- local occupyTimeArr = occupCityList[targetCityId].occupyTimeArr
|
|
|
- occupyTimeArr[#occupyTimeArr+1] = { now }
|
|
|
-
|
|
|
-- 如果占领的是发起集结的城池, 那么取消集结
|
|
|
if myUnionData.gatherInfo and myUnionData.gatherInfo.gatherCity == targetCityId then
|
|
|
myUnionData.gatherInfo.gatherCity = 0
|
|
|
end
|
|
|
|
|
|
- -- 更新公会排行榜数据
|
|
|
- updateUnionRanktData(unionRankList, myUnionId, 1, 0)
|
|
|
+ cityNum = 1
|
|
|
end
|
|
|
|
|
|
-- 更新进攻方公会数据
|
|
|
AnotherWorldBattleDB.UpdateUnionData(myUnionId, myUnionData)
|
|
|
+ -- 更新进攻方玩家数据
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerData(playerUuid, atkPlayerData)
|
|
|
+
|
|
|
+ -- 更新进攻方公会的排行榜数据
|
|
|
+ AnotherWorldBattleDB.UpdateUnionRankList(groupId, myUnionId, cityNum, pointNum)
|
|
|
+ -- 更新进攻方玩家的排行榜数据
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerUuid, pointNum, pointWeight)
|
|
|
+
|
|
|
|
|
|
-- 更新城池数据
|
|
|
AnotherWorldBattleDB.UpdateCityList(groupId, cityList)
|
|
|
+end
|
|
|
+-- 玩家挑战据点失败
|
|
|
+local function challenge_Fail(msg)
|
|
|
+ local playerUuid = msg.playerUuid
|
|
|
+ local myUnionId = msg.myUnionId
|
|
|
|
|
|
- -- 更新公会/个人排行榜
|
|
|
- AnotherWorldBattleDB.UpdateUnionRankList(groupId, unionRankList)
|
|
|
- AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerRankList)
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
+ if not groupId then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ playerData = playerData or {}
|
|
|
+ playerData.name = playerData.name
|
|
|
+ playerData.lv = playerData.lv
|
|
|
+ playerData.power = playerData.power
|
|
|
+ playerData.unionId = myUnionId
|
|
|
+ playerData.challengeTimes = (playerData.challengeTimes or AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES) - 1
|
|
|
+ if not playerData.lastTime or playerData.lastTime == 0 then
|
|
|
+ playerData.lastTime = os.time()
|
|
|
+ end
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
|
|
|
+
|
|
|
+ -- 加入个人排行榜
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerUuid, 0, 0)
|
|
|
+end
|
|
|
+
|
|
|
+--挑战据点结束的处理函数
|
|
|
+function N2C_Point_Challenge_End_Handle(msg)
|
|
|
+ if msg.challengeRes == CombatDefine.RESULT_WIN then
|
|
|
+ challenge_Win(msg)
|
|
|
+ else
|
|
|
+ challenge_Fail(msg)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+-- 玩家数据更新
|
|
|
+function N2C_Update_Player_Data(msg)
|
|
|
+ if not isRunning() then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local playerUuid = msg.playerUuid
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ if not playerData then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local groupId = getMyUnionGourpId(playerData.unionId)
|
|
|
+ if not groupId then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local isUpdatePower = false
|
|
|
+ for k,v in pairs(msg.updateData) do
|
|
|
+ if k == "power" then
|
|
|
+ isUpdatePower = true
|
|
|
+ end
|
|
|
+
|
|
|
+ playerData[k] = v
|
|
|
+ end
|
|
|
+
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
|
|
|
+
|
|
|
+ -- 如果是战力更新, 更新玩家排行榜
|
|
|
+ if isUpdatePower then
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerUuid, 0, 0, playerData.power)
|
|
|
+ end
|
|
|
+
|
|
|
+end
|
|
|
+
|
|
|
+-- 公会数据更新
|
|
|
+function N2C_Update_Union_Data(msg)
|
|
|
+ if not isRunning() then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local myUnionId = msg.myUnionId
|
|
|
+ local unionData = AnotherWorldBattleDB.GetUnionData(myUnionId)
|
|
|
+ if not unionData then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local groupId = getMyUnionGourpId(myUnionId)
|
|
|
+ if not groupId then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local isUpdatePower = false
|
|
|
+ for k,v in pairs(msg.updateData) do
|
|
|
+ if k == "power" then
|
|
|
+ isUpdatePower = true
|
|
|
+ end
|
|
|
+ unionData[k] = v
|
|
|
+ end
|
|
|
+
|
|
|
+ AnotherWorldBattleDB.UpdateUnionData(myUnionId, unionData)
|
|
|
+
|
|
|
+ -- 如果是战力更新, 更新公会排行榜
|
|
|
+ if isUpdatePower then
|
|
|
+ AnotherWorldBattleDB.UpdateUnionRankList(groupId, myUnionId, 0, 0, unionData.power)
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+-- 更新玩家据点防守阵容数据
|
|
|
+function N2C_Update_Point_Lineup(msg)
|
|
|
+ if not isRunning() then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local playerUuid = msg.playerUuid
|
|
|
+ local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
|
|
|
+ if not playerData or not playerData.heroList then
|
|
|
+ return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_5)
|
|
|
+ end
|
|
|
+
|
|
|
+ local groupId = getMyUnionGourpId(playerData.unionId)
|
|
|
+ if not groupId then
|
|
|
+ return
|
|
|
+ end
|
|
|
+
|
|
|
+ local targetCityId, targetPointIdx = msg.targetCityId, msg.targetPointIdx
|
|
|
+ local heroList = playerData.heroList
|
|
|
+ if not heroList[targetCityId] or not heroList[targetCityId][targetPointIdx] then
|
|
|
+ return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_5)
|
|
|
+ end
|
|
|
+
|
|
|
+ heroList[targetCityId][targetPointIdx] = msg.heroArr
|
|
|
+ AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
|
|
|
+
|
|
|
+ local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP
|
|
|
+ msgData.playerUuid = playerUuid
|
|
|
+ msgData.targetCityId = targetCityId
|
|
|
+ msgData.targetPointIdx = targetPointIdx
|
|
|
+ msgData.formation = msg.formation
|
|
|
+ msgData.heroList = msg.heroList
|
|
|
+ msgData.helpList = msg.helpList
|
|
|
+ local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
|
|
|
+ InnerMsg.sendMsg(fd, msgData)
|
|
|
end
|