gitxsm 5 сар өмнө
parent
commit
54405a6656

+ 1 - 0
script/common/CommonDB.lua

@@ -43,6 +43,7 @@ KEY_JJCLADDER_INFO = "jjcNewladderInfo"					-- 天梯赛信息
 KEY_COMMERCEACT_MIDDLE_INFO = "commerceMiddleActInfo"	-- 中心服跨服商业活动信息
 KEY_BAN_DATA = "banData"								-- 封禁数据
 KEY_REBATE_DATA = "rebateData"							-- 渠道返利数据
+KEY_ANOTHERWORLDBATTLE_START_TI = "anotherWorldBattleStart" -- 最近一轮异界之战开启时间
 
 db = db or {
 	serverStartTime = nil,								-- 开服时间

+ 20 - 1
script/common/InnerHandler.lua

@@ -917,11 +917,30 @@ function LW_ANOTHERWORLDBATTLE_UPDATE_UNION(fd, msg)
 end
 
 
-
 function LW_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP(fd, msg)
     if _G.is_middle ~= true then return end
     AnotherWorldBattleCS.N2C_Update_Point_Lineup(msg)
 end
 function WL_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP(fd, msg)
     AnotherWorldBattleNS.C2N_Update_Point_Lineup(msg)
+end
+
+
+function WL_ANOTHERWORLDBATTLE_ACT_START(fd, msg)
+    AnotherWorldBattleNS.C2N_Act_Start(msg)
+end
+
+
+function LW_ANOTHERWORLDBATTLE_UPDATE_HERO(fd, msg)
+    if _G.is_middle ~= true then return end
+    AnotherWorldBattleCS.N2C_Update_HeroData(msg)
+end
+
+
+function LW_ANOTHERWORLDBATTLE_LEAVE_POINT(fd, msg)
+    if _G.is_middle ~= true then return end
+    AnotherWorldBattleCS.N2C_Leave_Point(msg)
+end
+function WL_ANOTHERWORLDBATTLE_LEAVE_POINT(fd, msg)
+    AnotherWorldBattleNS.C2N_Leave_Point(msg)
 end

+ 29 - 0
script/common/InnerProto.lua

@@ -1079,6 +1079,7 @@ WL_ANOTHERWORLDBATTLE_ALLCITY_QUERY  = {
   {"hasPointNum",                 "int"},  -- 玩家当前占领的据点数量
   {"challengeTimes",            "int"},   -- 公会出生点城池Id
   {"lastTime",                  "int"},   -- 公会出生点城池Id
+  {"occupyPointData",           "table"},  -- 公会占领的据点数据
 }
 
 -- 查询单个城池的详细信息
@@ -1248,4 +1249,32 @@ WL_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP = {
   {"formation",		            "short"},--阵法
 	{"heroList"	,			          "table"},--上阵英雄
 	{"helpList"	,			          "table"},--辅助对象
+}
+
+-- 异界之战活动开启
+WL_ANOTHERWORLDBATTLE_ACT_START = {
+  {"startTime",              "int"},
+}
+
+
+-- 玩家英雄更新
+LW_ANOTHERWORLDBATTLE_UPDATE_HERO = {
+  {"playerUuid",              "string"},
+  {"targetCityId",            "int"},
+  {"targetPointIdx",          "int"},
+  {"heroData",               "table"},
+}
+
+-- 放弃某个据点
+LW_ANOTHERWORLDBATTLE_LEAVE_POINT = {
+  {"sourceServerId",          "int"},
+  {"playerUuid",              "string"},
+  {"myUnionId",               "string"},
+  {"targetCityId",            "int"},
+  {"targetPointIdx",           "int"},
+}
+WL_ANOTHERWORLDBATTLE_LEAVE_POINT = {
+  {"playerUuid",              "string"},
+  {"targetCityId",            "int"},
+  {"targetPointIdx",          "int"},
 }

+ 4 - 1
script/common/InnerProtoID.lua

@@ -162,5 +162,8 @@ _ENV[159] = 'LW_ANOTHERWORLDBATTLE_UPDATE_UNION'
 _ENV[160] = 'WL_ANOTHERWORLDBATTLE_GATHER'
 _ENV[161] = 'LW_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP'
 _ENV[162] = 'WL_ANOTHERWORLDBATTLE_UPDATE_POINT_LINEIP'
-
+_ENV[163] = 'WL_ANOTHERWORLDBATTLE_ACT_START'
+_ENV[164] = 'LW_ANOTHERWORLDBATTLE_UPDATE_HERO'
+_ENV[165] = 'LW_ANOTHERWORLDBATTLE_LEAVE_POINT'
+_ENV[166] = 'WL_ANOTHERWORLDBATTLE_LEAVE_POINT'
 

+ 238 - 49
script/module/anotherWorldBattle/AnotherWorldBattleCS.lua

@@ -14,7 +14,6 @@ local AnotherWorldBattleConfig = require("excel.anotherWorldBattle")
 local wDay
 
 
-
 local function updateWDay()
     wDay = Util.getWeekDay()
 end
@@ -91,9 +90,12 @@ local function newRoundHandle()
     -- 更新活动开始时间
     local now = os.time()
     AnotherWorldBattleDB.UpdateLastRoundStartTime(now)
+
+    -- 通知所有普通服, 新一轮活动开启了
+    ActOpen(now)
 end
 
--- 能否进入新一轮的报名阶段
+-- 进入新一轮报名阶段检测
 local function joinStageCheck()
     local stage = AnotherWorldBattleDB.GetStage()
 
@@ -202,6 +204,7 @@ local function grouping()
 
     AnotherWorldBattleDB.UpdateGroupArray(newGroupArray)
 end
+
 -- 给各个分组中的公会随机分配出生点
 local function randomBaseCity()
     local baseCityIdArr = {}
@@ -281,7 +284,7 @@ local function genUnionOccupyInfo(unionId, union, playerListData)
         end
     end
 
-    -- 防止本次没有正常发放奖励,后续补发时, 结束时间异常的情况
+    -- 防止本次没有正常发放奖励, 后续补发时, 结束时间异常的情况
     union.baseCityEndTime = now
     AnotherWorldBattleDB.UpdateUnionData(unionId, union)
 
@@ -312,14 +315,14 @@ end
 -- 检测活动各阶段状态及相关处理
 local function timedStageHandle()
     -- 处于报名阶段
-    -- if table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
-    --     joinStageCheck()
-    -- end
-
-    if wDay == AnotherWorldBattleDefine.AB_JOIN_WDAY then
+    if table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
         joinStageCheck()
     end
 
+    -- if wDay == AnotherWorldBattleDefine.AB_JOIN_WDAY then
+    --     joinStageCheck()
+    -- end
+
     local now = os.time()
 
     -- 报名阶段 -> 战斗阶段
@@ -411,16 +414,26 @@ local function pointLose(sourceServerId, playerUuid, loseCityId, losePointIdx)
     InnerMsg.sendMsg(fd, msgData)
 end
 
+-- 通知所有普通服, 活动开启
+function ActOpen(ti)
+    local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_ACT_START
+    msgData.startTime = ti or os.time()
+
+    local fdList = MiddleManager.MiddleManager_GetAllFD()
+    for _, fd in pairs(fdList) do
+        InnerMsg.sendMsg(fd, msgData)
+    end
+end
 
 ------------------------------------N2C---------------------------------------------------
 
--- 获取自己公会的组Id
+-- 获取自己公会所在分组的Id
 local function getMyUnionGourpId(myUnionId)
     local groupId = AnotherWorldBattleDB.GetUnionGroupId(myUnionId)
     return groupId
 end
 
--- 获取自己公会/所在区服第一公会的组Id
+-- 获取自己公会/所在区服第一公会所在分组Id
 local function getGroupId(myUnionId, myServerId)
     local groupId = getMyUnionGourpId(myUnionId)
     if not groupId then
@@ -476,7 +489,7 @@ local function calcOccupyCityNum(occupCityList, cityLv)
     return num
 end
 
--- 统计公会占领的据点所属城池数组
+-- 统计公会占领的据点所属城池Id数组
 local function calcOccupyPointArr(occupCityList)
     local pointInfoArr = {}
 
@@ -548,7 +561,6 @@ local function calcPlayerOccupyPointNum(playerUuid)
     return playerOccupyPonitNum
 end
 
-
 -- 检查某个据点是否能被玩家挑战
 local function isCanChallengePoint(targetCityId, targetPointIdx, myUnionId, playerUuid)
     -- 活动未开启
@@ -577,7 +589,7 @@ local function isCanChallengePoint(targetCityId, targetPointIdx, myUnionId, play
         return 2
     end
 
-    -- 据点已被本公会占领
+    -- 城池已被本公会占领
     if tagetCityData.occupyUnion and tagetCityData.occupyUnion == myUnionId then
         return -4
     end
@@ -639,7 +651,7 @@ end
 local function getPlayerChallengeTimesInfo(playerUuid)
     local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
     if not playerData then
-        return AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES, 0
+        return AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_INIT_TIMES, 0
     end
 
     local now = os.time()
@@ -647,10 +659,10 @@ local function getPlayerChallengeTimesInfo(playerUuid)
 
     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.challengeTimes = math.min(playerData.challengeTimes + addTimes, AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_MAX_TIMES)
         playerData.lastTime = playerData.lastTime + addTimes* AnotherWorldBattleDefine.AB_PLAYER_CHALLENGETIMES_SEC
 
-        if playerData.challengeTimes == AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES then
+        if playerData.challengeTimes == AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_MAX_TIMES then
             playerData.lastTime = 0
         end
 
@@ -685,6 +697,30 @@ local function getCityState(cityData)
     return state
 end
 
+-- 获取公会占领据点的数据
+local function getOccupPointData(unionId)
+    local t2 = {}
+
+    local unionData = AnotherWorldBattleDB.GetUnionData(unionId)
+    if not unionData then
+        return t2
+    end
+
+    for cityId, cityIno in pairs(unionData.occupCityList or {}) do
+        for _, pointInfo in pairs(cityIno.occupyPointList) do
+            t2[#t2+1] = {cityId, pointInfo.occupyTimeArr}
+        end
+    end
+
+    -- 出生点算5个据点
+    local baseCiyuTimeArr = { {unionData.baseCityStartTime, unionData.baseCityEndTime or now } }
+    for i=1, AnotherWorldBattleDefine.AB_POINT_MAX_NUM do
+        t2[#t2+1] = {unionData.baseCityId,  baseCiyuTimeArr}
+    end
+
+    return t2
+end
+
 
 -- 查询状态
 function N2C_Get_State(msg)
@@ -814,6 +850,7 @@ function N2C_AllCity_Query(msg)
     local challengeTimes, leftTime = getPlayerChallengeTimesInfo(msg.playerUuid)
     msgData.challengeTimes = challengeTimes
     msgData.lastTime = leftTime
+    msgData.occupyPointData = getOccupPointData(myUnionId)
 
     InnerMsg.sendMsg(fd, msgData)
 end
@@ -1295,7 +1332,7 @@ local function challenge_Win(msg)
     local pointWeight = AnotherWorldBattleConfig.city[targetCityId].pointWeight
 
 
-    -- 如果城池之前被占领了, 则重置占领城池的公会Id
+    -- 如果城池之前被占领了, 则删除占领城池的公会Id
     if cityData.occupyUnion then
         cityData.occupyUnion = nil
     end
@@ -1305,32 +1342,38 @@ local function challenge_Win(msg)
         -- 更新防守方公会数据
         local defUnionData = AnotherWorldBattleDB.GetUnionData(pointData.unionId)
         local defOccupCityList = defUnionData.occupCityList
+        local defTargerCityData = defOccupCityList[targetCityId]
+
+        -- 更新防守方公会对该据点的占领状态和最后占领时间
+        if defTargerCityData and defTargerCityData.occupyPointList and defTargerCityData.occupyPointList[targetPointIdx] then
+            local defTargetPointData = defTargerCityData.occupyPointList[targetPointIdx]
+            if defTargetPointData then
+                -- 删除占领该据点的玩家uuid
+                defTargetPointData.playerUuid = nil
+
+                -- 更新对该据点最后占领时间段的结束时间
+                if defTargetPointData.occupyTimeArr then
+                    local lastOccupyTimeTb = defTargetPointData.occupyTimeArr[#defTargetPointData.occupyTimeArr]
+                    lastOccupyTimeTb[2] = now
+                end
+            end
+        end
 
-        -- 防守方之前占领了城池
-        if defOccupCityList[targetCityId].isOccupy then
-
-            -- 修改防守方的占领状态
-            defOccupCityList[targetCityId].isOccupy = false
-
-            -- 更新防守方对该城池的最后占领时间
-            local defOccupyPointList = defOccupCityList[targetCityId].occupyPointList
-            local defPointInfo = defOccupyPointList[targetPointIdx]
-            local defOccupyTimeArr = defPointInfo.occupyTimeArr
-            defOccupyTimeArr[#defOccupyTimeArr][2] = now
-
-            -- 删除防守方的该据点的占领者
-            defPointInfo.playerUuid = nil
+        -- 删除防守方玩家的防守阵容数据
+        local defPlayData = AnotherWorldBattleDB.GetPlayerData(pointData.playerUuid)
+        if defPlayData then
+            defPlayData.heroList[targetCityId][targetPointIdx] = nil
+            AnotherWorldBattleDB.UpdatePlayerData(pointData.playerUuid, defPlayData)
+        end
 
-            -- 删除防守方玩家的防守阵容数据
-            local defPlayData = AnotherWorldBattleDB.GetPlayerData(pointData.playerUuid)
-            if defPlayData then
-                defPlayData.heroList[targetCityId][targetPointIdx] = nil
-                AnotherWorldBattleDB.UpdatePlayerData(pointData.playerUuid, defPlayData)
-            end
 
+        -- 如果防守方公会之前占领了城池, 则修改占领状态
+        if defTargerCityData and defTargerCityData.isOccupy then
+            defTargerCityData.isOccupy = false
             cityNum = -1
         end
 
+
         -- 更新防守方公会的排行榜数据
         AnotherWorldBattleDB.UpdateUnionRankList(groupId, pointData.unionId, cityNum, pointNum)
         -- 更新防守方玩家的排行榜数据
@@ -1347,7 +1390,7 @@ local function challenge_Win(msg)
     pointData.unionId = myUnionId
     pointData.playerUuid = playerUuid
 
-    -- 据点挑战结束
+    -- 重置据点被挑战标识
     pointData.battleTime = nil
 
     -- 更新进攻方公会数据—— 据点占有者, 最新的据点占有时间
@@ -1371,7 +1414,7 @@ local function challenge_Win(msg)
     atkPlayerData.power = playerShowInfo.power
     atkPlayerData.unionId = myUnionId
     -- 更新挑战次数
-    atkPlayerData.challengeTimes = (atkPlayerData.challengeTimes or AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES) - 1
+    atkPlayerData.challengeTimes = (atkPlayerData.challengeTimes or AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_INIT_TIMES) - 1
     if not atkPlayerData.lastTime or atkPlayerData.lastTime == 0 then
         atkPlayerData.lastTime = os.time()
     end
@@ -1438,7 +1481,7 @@ local function challenge_Fail(msg)
     playerData.lv = playerData.lv
     playerData.power = playerData.power
     playerData.unionId = myUnionId
-    playerData.challengeTimes = (playerData.challengeTimes or AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_TIMES) - 1
+    playerData.challengeTimes = (playerData.challengeTimes or AnotherWorldBattleDefine.AB_PLAYER_CHALLENGE_INIT_TIMES) - 1
     if not playerData.lastTime or playerData.lastTime == 0 then
         playerData.lastTime = os.time()
     end
@@ -1475,10 +1518,10 @@ function N2C_Update_Player_Data(msg)
         return
     end
 
-    local isUpdatePower = false
+    local isUpdate = false
     for k,v in pairs(msg.updateData) do
-        if k == "power" then
-            isUpdatePower = true
+        if k == "power" or k == "name" then
+            isUpdate = true
         end
 
         playerData[k] = v
@@ -1486,8 +1529,8 @@ function N2C_Update_Player_Data(msg)
 
     AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
 
-    -- 如果是战力更新, 更新玩家排行榜
-    if isUpdatePower then
+    -- 如果是战力/名字更新, 更新玩家排行榜
+    if isUpdate then
         AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerUuid, 0, 0, playerData.power)
     end
 
@@ -1510,10 +1553,10 @@ function N2C_Update_Union_Data(msg)
         return
     end
 
-    local isUpdatePower = false
+    local isUpdate = false
     for k,v in pairs(msg.updateData) do
-        if k == "power" then
-            isUpdatePower = true
+        if k == "power" or k == "name" then
+            isUpdate = true
         end
         unionData[k] = v
     end
@@ -1521,7 +1564,7 @@ function N2C_Update_Union_Data(msg)
     AnotherWorldBattleDB.UpdateUnionData(myUnionId, unionData)
 
     -- 如果是战力更新, 更新公会排行榜
-    if isUpdatePower then
+    if isUpdate then
         AnotherWorldBattleDB.UpdateUnionRankList(groupId, myUnionId, 0, 0, unionData.power)
     end
 end
@@ -1561,4 +1604,150 @@ function N2C_Update_Point_Lineup(msg)
     msgData.helpList = msg.helpList
     local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
     InnerMsg.sendMsg(fd, msgData)
+end
+
+-- 更新玩家英雄数据
+function N2C_Update_HeroData(msg)
+    if not isRunning() then
+        return
+    end
+
+    local playerUuid = msg.playerUuid
+    local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
+    if not playerData then
+        return
+    end
+
+    local heroList = playerData.heroList
+    if not heroList then
+        return
+    end
+
+    local targetCityId, targetPointIdx = msg.targetCityId, msg.targetPointIdx
+    if not heroList[targetCityId] or not heroList[targetCityId][targetPointIdx] then
+        return
+    end
+
+    local isUpdate = false
+    local newHeroData = msg.heroData
+    local heroArr = heroList[targetCityId][targetPointIdx]
+
+    for _, heroData in ipairs(heroArr) do
+        if heroData.heroUuid == newHeroData.heroUuid then
+            for k, v in pairs(newHeroData) do
+                heroData[k] = v
+            end
+
+            isUpdate = true
+            break
+        end
+    end
+
+    if isUpdate then
+        AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
+    end
+end
+
+-- 放弃据点
+function N2C_Leave_Point(msg)
+    local playerUuid = msg.playerUuid
+    local myUnionId = msg.myUnionId
+    local targetCityId = msg.targetCityId
+    local targetPointIdx = msg.targetPointIdx
+
+    if not isRunning() then
+        return
+    end
+
+    local groupId = getMyUnionGourpId(myUnionId)
+    local cityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
+    local targetPointData = cityData.pointArr[targetPointIdx]
+
+    if not targetPointData.unionId or targetPointData.unionId ~= myUnionId or targetPointData.playerUuid ~= playerUuid then
+        return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_5)
+    end
+
+    local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
+    if not playerData then
+        return
+    end
+
+    local heroList = playerData.heroList
+    if not heroList or not heroList[targetCityId] or not heroList[targetCityId][targetPointIdx] then
+        return
+    end
+
+
+    local defUnionData = AnotherWorldBattleDB.GetUnionData(targetPointData.unionId)
+    if not defUnionData then
+        return
+    end
+
+    local defOccupCityList = defUnionData.occupCityList
+    if not defOccupCityList then
+        return
+    end
+
+    local defTargerCityData = defOccupCityList[targetCityId]
+    if not defTargerCityData or not defTargerCityData.occupyPointList or not defTargerCityData.occupyPointList[targetPointIdx] then
+        return
+    end
+
+    local cityNum, pointNum = 0, -1
+
+    -- 更新城池数据, 如果城池之前被本公会占领了, 则删除
+    if cityData.occupyUnion and cityData.occupyUnion == myUnionId then
+        cityData.occupyUnion = nil
+    end
+
+    -- 更新据点数据, 删除据点的 unionId, playerUuid
+    targetPointData.unionId = nil
+    targetPointData.playerUuid = nil
+
+    -- 更新公会数据, 删除公会数据中占领该据点的玩家uuid
+    local defTargetPointData = defTargerCityData.occupyPointList[targetPointIdx]
+    defTargetPointData.playerUuid = nil
+
+    -- 更新公会数据, 更新该据点最后占领时间段的结束时间
+    if defTargetPointData.occupyTimeArr then
+        local lastOccupyTimeTb = defTargetPointData.occupyTimeArr[#defTargetPointData.occupyTimeArr]
+        lastOccupyTimeTb[2] = now
+    end
+
+    -- 更新公会数据, 如果本公会之前占领了城池, 则修改占领状态
+    if defTargerCityData and defTargerCityData.isOccupy then
+        defTargerCityData.isOccupy = false
+        cityNum = -1
+    end
+
+    -- 更新玩家数据, 删除玩家数据中该据点的防守数据
+    heroList[targetCityId][targetPointIdx] = nil
+    if not next(heroList[targetCityId]) then
+        heroList[targetCityId] = nil
+    end
+
+
+    -- 更新公会数据
+    AnotherWorldBattleDB.UpdateUnionData(myUnionId, defUnionData)
+    -- 更新玩家数据
+    AnotherWorldBattleDB.UpdatePlayerData(playerUuid, playerData)
+
+    -- 更新公会的排行榜数据
+    AnotherWorldBattleDB.UpdateUnionRankList(groupId, myUnionId, cityNum, pointNum)
+    -- 更新玩家的排行榜数据
+    local pointWeight = AnotherWorldBattleConfig.city[targetCityId].pointWeight
+    AnotherWorldBattleDB.UpdatePlayerRankList(groupId, playerUuid, pointNum, -pointWeight)
+
+    -- 更新城池数据
+    AnotherWorldBattleDB.UpdateCityData(groupId, targetCityId, cityData)
+
+    -- 通知普通服, 放弃据点成功
+    local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_LEAVE_POINT
+    msgData.playerUuid = playerUuid
+    msgData.targetCityId = targetCityId
+    msgData.targetPointIdx = targetPointIdx
+    local fd = MiddleManager.getFDBySvrIndex(msg.sourceServerId)
+    InnerMsg.sendMsg(fd, msgData)
+
+    N2C_AllCity_Query(msg)
 end

+ 76 - 25
script/module/anotherWorldBattle/AnotherWorldBattleDB.lua

@@ -208,6 +208,7 @@ end
 local function createGuildRank()
     local guilds = {}      -- id -> guildRec(永久表,不删)
     local rank   = {}      -- 1..#guilds 复用数组
+    local dirty  = true    -- 脏标记:true表示rank需要重新计算
 
     local function cmp(a, b)
         if a.occupyCityNum ~= b.occupyCityNum then
@@ -228,52 +229,77 @@ local function createGuildRank()
                 power = power or 0 }
             guilds[id] = g
         else
+            -- 原地更新,保持table引用
             g.occupyCityNum = occupyCityNum or g.occupyCityNum
             g.occupyPointNum = occupyPointNum or g.occupyPointNum
             g.power = power or g.power
             if name then g.name = name end
         end
 
-        -- 全量重建(8 条以内,可忽略性能)
+        -- 标记rank缓存失效(数据量小,但统一设计模式)
+        dirty = true
+    end
+
+    -- 内部函数:按需重新排序
+    local function sortIfNeeded()
+        if not dirty then return end
+
+        -- 全量收集到rank(复用数组)
         local n = 0
         for _, v in pairs(guilds) do
             n = n + 1
             rank[n] = v
         end
-        table.sort(rank, cmp)
-        for i = n + 1, #rank do rank[i] = nil end   -- 清理旧数据
+
+        -- 排序
+        if n > 1 then
+            table.sort(rank, cmp)
+        end
+
+        -- 清除尾部残留数据
+        for i = n + 1, #rank do
+            rank[i] = nil
+        end
+
+        dirty = false
     end
 
     local function getRankList()
+        -- 确保排行已更新
+        sortIfNeeded()
+
+        -- 构建返回列表
         local ret = {}
         for i = 1, #rank do
             local g = rank[i]
-            ret[i] =
-            {
+            ret[i] = {
                 rank = i, guildId = g.id, name = g.name,
                 occupyCityNum = g.occupyCityNum,
                 occupyPointNum = g.occupyPointNum,
-                power = g.power}
+                power = g.power
+            }
         end
         return ret
     end
 
-    local function getGuildDetail(id) return guilds[id] end
-    -- 在返回表里加
-    return { 
+    local function getGuildDetail(id)
+        return guilds[id]
+    end
+
+    return {
         updateGuild = updateGuild,
         getRankList = getRankList, 
         getGuildDetail = getGuildDetail
     }
-
 end
 
 -- 玩家排行榜
 -- 当前每个公会最多25人,8个公会为一组,最多200人
 local function createPlayerRank()
     local players     = {}              -- id -> rec(永久存在,不删)
-    local rank        = {}              -- 1..RANK_MAX 复用
-    local tmp         = {}              -- 一次性长到 MAX_PEOPLE
+    local rank        = {}              -- 已排序的前RANK_MAX名,复用
+    local tmp         = {}              -- 临时排序数组,预分配
+    local dirty       = true            -- 脏标记:true表示rank需要重新计算
 
     local function cmp(a, b)
         if a.pointNum ~= b.pointNum then return a.pointNum > b.pointNum end
@@ -281,42 +307,64 @@ local function createPlayerRank()
         return a.power > b.power
     end
 
-    -- 预分配 tmp 数组,避免运行时扩容
+    -- 预分配tmp容量,避免运行时动态扩容
     for i = 1, 500 do tmp[i] = nil end
 
     local function updatePlayer(id, name, power, pNum, pWeight)
-        -- 1. 取出或新建记录
+        -- 更新或创建玩家记录
         local rec = players[id]
         if not rec then
             rec = { id = id, name = name or "", power = power,
                     pointNum = pNum or 0, pointAllWeight = pWeight or 0 }
             players[id] = rec
         else
-            -- 原地更新
+            -- 原地更新,保持table引用不变
             rec.power = power
             if pNum ~= nil then rec.pointNum = pNum end
             if pWeight ~= nil then rec.pointAllWeight = pWeight end
             if name then rec.name = name end
         end
 
-        -- 2. 全量收集(只复制引用,不创建新表)
+        -- 标记rank缓存失效
+        dirty = true
+    end
+
+    -- 内部函数:按需重新排序
+    local function sortIfNeeded()
+        if not dirty then return end
+
+        -- 收集所有玩家记录到tmp(仅复制引用)
         local n = 0
         for _, v in pairs(players) do
             n = n + 1
             tmp[n] = v
         end
 
-        -- 3. 只排序有用部分
-        table.sort(tmp, cmp)
+        -- 排序
+        if n > 1 then
+            table.sort(tmp, cmp)
+        end
 
-        -- 4. 取前 RANK_MAX 到 rank,复用 rank 数组
-        for i = 1, AnotherWorldBattleDefine.AB_RANK_MAX_NUM do
-            rank[i] = tmp[i]
+        -- 将前RANK_MAX名复制到rank(复用数组)
+        local rankMax = AnotherWorldBattleDefine.AB_RANK_MAX_NUM
+        local oldRankLen = #rank
+        for i = 1, rankMax do
+            rank[i] = tmp[i]  -- 若i>n,则赋值为nil,自动缩小rank长度
         end
-        for i = AnotherWorldBattleDefine.AB_RANK_MAX_NUM + 1, #rank do rank[i] = nil end
+
+        -- 清除rank数组尾部残留的旧数据
+        for i = rankMax + 1, oldRankLen do
+            rank[i] = nil
+        end
+
+        dirty = false
     end
 
     local function getRankList()
+        -- 确保排行已更新
+        sortIfNeeded()
+
+        -- 构建返回列表
         local ret = {}
         for i = 1, #rank do
             local p = rank[i]
@@ -326,10 +374,13 @@ local function createPlayerRank()
         return ret
     end
 
-    local function getPlayerDetail(id) return players[id] end
+    local function getPlayerDetail(id)
+        return players[id]
+    end
+
     return {
-        updatePlayer = updatePlayer,
-        getRankList  = getRankList,
+        updatePlayer    = updatePlayer,
+        getRankList     = getRankList,
         getPlayerDetail = getPlayerDetail,
     }
 end

+ 5 - 3
script/module/anotherWorldBattle/AnotherWorldBattleDefine.lua

@@ -11,8 +11,8 @@ AB_SUB_DAY = 9  -- 两次活动之间相隔的天数
 
 AB_OPEN_WDAY_AREA = {7, 4}      -- 活动开启时间范围, 周六 ~ 下周周三
 
-AB_JOIN_WDAY = 7
--- AB_JOIN_WDAY_AREA = {7, 1}      -- 报名时间范围, 周六 ~ 周日
+-- AB_JOIN_WDAY = 7             -- 报名时间, 周六
+AB_JOIN_WDAY_AREA = {7, 1}      -- 报名时间范围, 周六 ~ 周日
 
 AB_BATTLE_WDAY_AREA = {1, 4}    -- 战斗时间范围, 周日 ~ 周三
 
@@ -35,7 +35,9 @@ AB_PLAYER_OCCUPY_POINT_MAX_NUM = 15  -- 每个玩家最多占领据点数量
 
 AB_RANK_MAX_NUM = 50        -- 公会/个人排行榜最大上榜数量
 
-AB_PLAYER_CHALLENGE_TIMES = 50  -- 玩家初始时挑战次数
+AB_PLAYER_CHALLENGE_INIT_TIMES = 10  -- 玩家初始时挑战次数
+
+AB_PLAYER_CHALLENGE_MAX_TIMES = 50  -- 玩家最大挑战次数
 
 AB_PLAYER_CHALLENGETIMES_SEC = 3600  -- 每一个小时恢复一次挑战次数
 

+ 266 - 26
script/module/anotherWorldBattle/AnotherWorldBattleNS.lua

@@ -51,6 +51,10 @@ local HeroExcel = require("excel.hero")
 local MiddleCommonLogic = require("middle.MiddleCommonLogic")
 local CombatImpl = require("combat.CombatImpl")
 local RoleAttr = require("role.RoleAttr")
+local CommonDB = require("common.CommonDB")
+
+
+local HeroLogic
 
 
 local function writeLog(logStr)
@@ -119,6 +123,30 @@ local function getWDay()
     return Util.getWeekDay()
 end
 
+-- 开服天数和玩家等级检查
+local function baseCondCheck(human)
+    return RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1216)
+end
+
+-- 根据最近一轮活动开启时间, 判断当前是否处于活动开启时间范围
+local function actStartTimeCheck()
+    local wDay = getWDay()
+    if wDay > AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[2] and wDay < AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[1] then
+        return false
+    end
+
+    local startTime = CommonDB.getValueByKey(CommonDB.KEY_ANOTHERWORLDBATTLE_START_TI)
+    if not startTime then
+        return false
+    end
+
+    if not IsRuning(startTime) then
+        return false
+    end
+
+    return true
+end
+
 -- 计算怪物战力
 local function calcMonsterPower(monsterOutID)
     local power = 0
@@ -173,7 +201,7 @@ end
 
 -- 单个英雄数据
 local function getHeroInfo(human, targetHeroUuid)
-    local HeroLogic = require("hero.HeroLogic")
+    HeroLogic = HeroLogic or require("hero.HeroLogic")
     local heroGrid = HeroLogic.getHeroGridByUuid(human, targetHeroUuid)
     if heroGrid then
         local heroCfg = HeroExcel.hero[heroGrid.id]
@@ -243,6 +271,7 @@ local function formationDataCheeck(human)
     local wDay = getWDay()
     if AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[1] > wDay and AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] < wDay then
         human.db.anotherWorlBattle = nil
+        return
     end
 
     -- 处于战斗阶段最后一天, 但是活动已经结束
@@ -250,9 +279,10 @@ local function formationDataCheeck(human)
     local toDayStartTime = Util.getDayStartTime(now)
     if AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] == wDay and now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
         human.db.anotherWorlBattle = nil
+        return
     end
 
-    -- 处于战斗阶段时间范围内, 但是活动未开(因为两轮活动时间间隔至少9天)
+    -- 处于战斗阶段时间范围内, 但是活动未开(因为两轮活动时间间隔至少9天)
     local startTime = human.db.anotherWorlBattle.startTime
     local diffDays = Util.diffDay(startTime)
     if diffDays > 3 then
@@ -262,14 +292,15 @@ end
 
 -- 把玩家最新的异界之战所有防守英雄uuid推给客户端
 local function sendDefHeroArr(human)
+    local msgRet = Msg.gc.GC_AB_DEF_HERO_QUERY
+    msgRet.heroUuidArr[0] = 0
+
     if not human.db.anotherWorlBattle then
-        return
+        return Msg.send(msgRet, human.fd)
     end
 
     local len = 0
-    local msgRet = Msg.gc.GC_AB_DEF_HERO_QUERY
     local heroUuidArrMsg = msgRet.heroUuidArr
-    heroUuidArrMsg[0] = 0
 
     for _, pointList in pairs(human.db.anotherWorlBattle.formation) do
         for _, combatData in pairs(pointList) do
@@ -292,7 +323,7 @@ end
 -- 是否是防守阵容中的英雄
 local function isDefHero(human, checkHeroUuid, excludeCityId, excludePointIdx)
     if not human.db.anotherWorlBattle then
-        return false
+        return
     end
 
     for cityId, pointList in pairs(human.db.anotherWorlBattle.formation) do
@@ -304,13 +335,13 @@ local function isDefHero(human, checkHeroUuid, excludeCityId, excludePointIdx)
             local heroList = combatData.list
             for _, heroUuid in pairs(heroList) do
                 if heroUuid == checkHeroUuid then
-                    return true
+                    return cityId, pointIdx
                 end
             end
         end
     end
 
-    return false
+    return
 end
 
 -- 是否是公会前二名
@@ -342,6 +373,16 @@ local function isBattleStage()
     return false
 end
 
+-- 重置在线玩家的防守数据
+local function resetDefData(playerUuidArr)
+    for _, playerUuid in ipairs(playerUuidArr or {}) do
+        local human = ObjHuman.onlineUuid[playerUuid]
+        if human then
+            onLogin(human)
+        end
+    end
+end
+
 -- 生成奖励发放对象列表
 local function genAwardObjArr(unionOccupyInfo)
     local function calcMinute(timeArr)
@@ -429,16 +470,27 @@ end
 
 -- 活动是否处于开启中
 function IsRuning(joinTime)
+    if not joinTime then
+        return true
+    end
+
     local wDay = getWDay()
     if wDay > AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[2] and wDay < AnotherWorldBattleDefine.AB_OPEN_WDAY_AREA[1] then
         return false
     end
 
+    local now = os.time()
+    local toDayStartTime = Util.getDayStartTime(now)
+    if AnotherWorldBattleDefine.AB_BATTLE_WDAY_AREA[2] == wDay and now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
+        return false
+    end
+
+
     local diffDays = Util.diffDay(joinTime)
-    -- 活动最后一天, 如果当前时间 >  结束时间则标识活动结束
-    if diffDays == 5 then
-        local now = os.time()
-        local toDayStartTime = Util.getDayStartTime(now)
+    local joinWday = Util.getWeekDay(joinTime)
+
+    -- 如果是周六加入则相差5天, 如果是周日加入则相差4天。 当前时间与加入时间相差4或5天, 则都表示当前可能是活动最后一天, 如果当前时间 > 结束时间则活动结束
+    if (diffDays == 5 and joinWday == 7) or (diffDays == 4 and joinWday == 1) then
         if now > (toDayStartTime + AnotherWorldBattleDefine.AB_BATTLE_END_SEC) then
             return false
         end
@@ -469,8 +521,8 @@ end
 
 -- 公会战力更新
 function UnionPowerChange(unionId, newPower)
-    if not isBattleStage() then
-        return
+    if not actStartTimeCheck() then
+        return false
     end
 
     local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_UNION
@@ -482,8 +534,12 @@ end
 
 -- 玩家战力更新
 function PlayerPowerChange(human)
-    if not isBattleStage() then
-        return
+    if not baseCondCheck(human) then
+        return false
+    end
+
+    if not actStartTimeCheck() then
+        return false
     end
 
     local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_PLAYER
@@ -494,10 +550,82 @@ function PlayerPowerChange(human)
     InnerMsg.sendMsg(0, msgData)
 end
 
+-- 英雄更新
+function HeroDataUpdate(human, heroUuid)
+    if not baseCondCheck(human) then
+        return false
+    end
 
+    if not actStartTimeCheck() then
+        return false
+    end
 
-function isOpen(human)
-    return RoleSystemLogic.isOpen(human, RoleSystemDefine.ROLE_SYS_ID_1306) -- 待改
+    local cityId, pointIdx = isDefHero(human, heroUuid)
+    if not cityId then
+        return
+    end
+
+    HeroLogic = HeroLogic or require("hero.HeroLogic")
+    local heroGrid = HeroLogic.getHeroGridByUuid(human, heroUuid)
+    if heroGrid then
+        RoleAttr.calcHeroGrid(heroGrid, nil, human)
+        local heroInfo = {
+            heroUuid  = heroUuid,
+            heroStar  = heroGrid.star,
+            heroLevel = heroGrid.lv,
+            heroPower = heroGrid.zhandouli,
+        }
+
+        local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_HERO
+        msgData.playerUuid = human.db._id
+        msgData.targetCityId = cityId
+        msgData.targetPointIdx = pointIdx
+        msgData.heroData = heroInfo
+        InnerMsg.sendMsg(0, msgData)
+    end
+end
+
+-- 玩家改名
+function PlayerChangeName(human)
+    if not baseCondCheck(human) then
+        return false
+    end
+
+    if not actStartTimeCheck() then
+        return false
+    end
+
+    local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_PLAYER
+    msgData.playerUuid = human.db._id
+    msgData.myUnionId = human.db.unionUuid
+    msgData.updateData = {}
+    msgData.updateData.name = human.db.name
+    InnerMsg.sendMsg(0, msgData)
+end
+
+-- 公会改名
+function UnionChangeName(unionId, newName)
+    if not actStartTimeCheck() then
+        return false
+    end
+
+    local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_UPDATE_UNION
+    msgData.myUnionId = unionId
+    msgData.updateData = {}
+    msgData.updateData.name = newName
+    InnerMsg.sendMsg(0, msgData)
+end
+
+function isDot(human)
+    if not baseCondCheck(human) then
+        return false
+    end
+
+    if not actStartTimeCheck() then
+        return false
+    end
+
+    return true
 end
 
 function onLogin(human)
@@ -506,6 +634,8 @@ function onLogin(human)
 end
 
 
+
+
 -- 请求状态
 function AB_GetState(human)
     local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_GET_STATE
@@ -525,17 +655,13 @@ function AB_Join(human)
         return Msg.send(msgRet, human.fd)
     end
 
-    -- if not isOpen(human) then
-    --     return Broadcast.sendErr(human, Lang.AB_JOIN_COND_NOT_SATIFY)
-    -- end
-
     local wDay = getWDay()
-    -- if not table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
+    -- if wDay ~= AnotherWorldBattleDefine.AB_JOIN_WDAY then
     --     msgRet.Joinstate = 5
     --     return Msg.send(msgRet, human.fd)
     -- end
 
-    if wDay ~= AnotherWorldBattleDefine.AB_JOIN_WDAY then
+    if not table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
         msgRet.Joinstate = 5
         return Msg.send(msgRet, human.fd)
     end
@@ -818,10 +944,60 @@ function AB_Update_Lineup(human, msg)
     InnerMsg.sendMsg(0, msgData)
 end
 
+-- 放弃据点
+function AB_Leave_Point(human, msg)
+    local targetCityId = msg.cityId
+    if not AnotherWorldBattleConfig.city[targetCityId] then
+        return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
+    end
+
+    local targetPointIdx = msg.pointIdx
+    if targetPointIdx <= 0 or targetPointIdx > AnotherWorldBattleDefine.AB_POINT_MAX_NUM then
+        return Broadcast.sendErr(human, Lang.COMMON_ARGUMENT_ERROR)
+    end
+
+    local msgData = InnerMsg.lw.LW_ANOTHERWORLDBATTLE_LEAVE_POINT
+    msgData.sourceServerId = Config.SVR_INDEX
+    msgData.playerUuid = human.db._id
+    msgData.myUnionId = human.db.unionUuid
+    msgData.targetCityId = targetCityId
+    msgData.targetPointIdx = targetPointIdx
+
+    InnerMsg.sendMsg(0, msgData)
+end
+
+--获取据点的防守阵容数据
+function AB_Get_Point_Lineup(human, msg)
+    local targetCityId = msg.cityId
+    local targetPointIdx = msg.pointIdx
+
+    local anotherWorlBattle = human.db.anotherWorlBattle
+    local formationData = anotherWorlBattle.formation
+    if not formationData[targetCityId] or not formationData[targetCityId][targetPointIdx] then
+        return Broadcast.sendErr(human, Lang.AB_NOT_OCCUPY_TARGET_POINT)
+    end
+
+    local extraArgs = {
+        cityId = targetCityId,
+        pointIdx = targetPointIdx
+    }
+    CombatPosLogic.posQuery(human, msg.type, msg.groupID, msg.param, 1, extraArgs)
+end
 
 
 ------------------------------------C2N---------------------------------------------------
 
+-- 跨服通知活动开启
+function C2N_Act_Start(msg)
+    local startTime = msg.startTime
+
+    if not startTime or startTime == 0 then
+        return
+    end
+
+    CommonDB.updateValue(CommonDB.KEY_ANOTHERWORLDBATTLE_START_TI, startTime)
+end
+
 -- 错误提示
 function C2N_ErrTips(msg)
     local human = ObjHuman.onlineUuid[msg.playerUuid]
@@ -944,6 +1120,31 @@ function C2N_AllCity_Query(msg)
         msgRet.myOccupyCityArr[i] = cityId
     end
 
+
+    -- 据点每分钟的奖励
+    local itemId, itemNum = 0, 0
+    local cityCfg = AnotherWorldBattleConfig.city[1]
+    itemId = cityCfg.cityAward[1]
+
+    for _, pointInfo in ipairs(msg.occupyPointData) do
+        local cityId = pointInfo[1]
+        local occupyTimeArr = pointInfo[2]
+        local cityCfg = AnotherWorldBattleConfig.city[cityId]
+
+        local minuteVal = 0
+        for _, timeTb in ipairs(occupyTimeArr) do
+            local sec = (timeTb[2] or now) - (timeTb[1] or now)
+            if sec > 0 then
+                minuteVal = minuteVal + sec
+            end
+
+            minuteVal = math.floor(minuteVal / 60)
+        end
+
+        itemNum = itemNum + minuteVal * cityCfg.cityAward[2]
+    end
+    Grid.makeItem(msgRet.myUnionAward, itemId, itemNum)
+
     Msg.send(msgRet, human.fd)
 end
 
@@ -1319,10 +1520,45 @@ function C2N_Update_Point_Lineup(msg)
     Broadcast.sendCenter(human, Lang.AB_UPDATE_LINEUP_SUCC)
 end
 
+-- 跨服通知放弃据点成功
+function C2N_Leave_Point(msg)
+    local human = ObjHuman.onlineUuid[msg.playerUuid]
+    if not human then
+        local db = RoleDBLogic.getDb(msg.playerUuid)
+        if not db then
+            return
+        end
+        human = {}
+        human.db = db
+    end
+
+    local anotherWorlBattle = human.db.anotherWorlBattle
+    if not anotherWorlBattle or not anotherWorlBattle.formation then
+        return
+    end
+
+    local cityId = msg.targetCityId
+    local pointIdx = msg.targetPointIdx
+    anotherWorlBattle.formation[cityId][pointIdx] = nil
+    if not next(anotherWorlBattle.formation[cityId]) then
+        anotherWorlBattle.formation[cityId] = nil
+    end
+
+    -- 玩家不在线, 手动保存数据
+    if not human.fd then
+        ObjHuman.save(human) --后续可优化只更新 anotherWorlBattle 数据
+    else
+        -- 把最新的防守阵容数据推给客户端
+        sendDefHeroArr(human)
+    end
+end
+
 -- 跨服通知给玩家发奖
 function C2N_IssueReward(msg)
     -- 删除公会参加异界之战活动时间
-    UnionLogic.UpdateJoinAbTime(msg.unionId, nil)
+    UnionLogic.UpdateJoinAbTime(msg.unionOccupyInfo.unionId, nil)
+
+    resetDefData(msg.unionOccupyInfo.playerUuidArr)
 
     -- 发奖
     local awardObjArr, occupyCityInfo = genAwardObjArr(msg.unionOccupyInfo)
@@ -1345,7 +1581,7 @@ function getCombatMonsterOutID(human, side, args)
 
     local cityId = args[2]
     local cityCfg = AnotherWorldBattleConfig.city[cityId]
-    return cityCfg.pointMonsterId
+    return cityCfg and cityCfg.pointMonsterId
 end
 
 function getCombatObjList(human, side, args, combatType, extraArgs)
@@ -1373,6 +1609,10 @@ function getCombatHeros(human, combatType, args)
         return
     end
 
+    if not args then
+        return
+    end
+
     local formation = human.db.anotherWorlBattle.formation
     if not formation then
         return

+ 8 - 0
script/module/anotherWorldBattle/Handler.lua

@@ -55,6 +55,14 @@ function CG_AB_UPDATE_LINEUP(human, msg)
 end
 
 
+function CG_AB_LEAVE_POINT(human, msg)
+    AnotherWorldBattleNS.AB_Leave_Point(human, msg)
+end
+
+function CG_AB_GET_POINT_LINEUP(human, msg)
+    AnotherWorldBattleNS.AB_Get_Point_Lineup(human, msg)
+end
+
 -------------------------------------------------异界寻宝------------------------------------------
 
 function CG_AB_TREASURE_QUERY(human, msg)

+ 15 - 0
script/module/anotherWorldBattle/Proto.lua

@@ -86,6 +86,7 @@ GC_AB_ALLCITY_QUERY = {
     {"hasPointNum",        1,      "byte"},      -- 玩家当前占领的据点数量
     {"challengeTimes",     1,      "byte"},      -- 玩家当前挑战次数
     {"leftTime",           1,      "int"},       -- 距离下一次增加挑战次数的秒数, 挑战次数达到最大/玩家公会没有参加时, 该值为0
+    {"myUnionAward",       1,      ItemData},    -- 累计产出道具
 }
 
 
@@ -192,6 +193,7 @@ CG_AB_POINT_CHAllENGE = {
     {"pointIdx",        1,      "byte"},    -- 据点索引
 }
 
+
 -- 更换某个据点的防守阵容
 CG_AB_UPDATE_LINEUP = {
     {"type",	    1,		"byte"},--阵容类型
@@ -202,7 +204,20 @@ CG_AB_UPDATE_LINEUP = {
     {"pointIdx",    1,      "byte"},    -- 据点索引
 }
 
+-- 放弃据点
+CG_AB_LEAVE_POINT = {
+    {"cityId",          1,      "int"},     -- 城池Id
+    {"pointIdx",        1,      "byte"},    -- 据点索引
+}
 
+-- 获取据点的防守阵容数据
+CG_AB_GET_POINT_LINEUP = {
+    {"cityId",          1,      "int"},     -- 城池Id
+    {"pointIdx",        1,      "byte"},    -- 据点索引
+    {"type",	        1,		"byte"},    --阵容类型
+	{"groupID",	        1,		"byte"},    --0 查询某个战斗类型,type为阵容类型 ,不等于0,查询某个组
+    {"param",	        1,		"string"},  --0 查询参数
+}
 
 
 -- 异界寻宝查询

+ 11 - 2
script/module/combat/CombatPosLogic.lua

@@ -52,6 +52,8 @@ local NewFirstChargeLogic = require("present.NewFirstChargeLogic")
 local ElfLogic = require("elf.ElfLogic")
 local Skill = require("combat.Skill")
 
+local AnotherWorldBattleNS
+
 
 --秘宝的加成
 local function getTalismanAdd(human)
@@ -621,7 +623,7 @@ function fontHelpNet(net,type,id,icon)
 end
 
 
-function posQuery(human, combatType, group, param, flag)
+function posQuery(human, combatType, group, param, flag, extraArgs)
 	local combatConfig = CombatExcel.combat[combatType]
 	if not combatConfig then return end
 	local msgRet = Msg.gc.GC_COMBAT_POS_QUERY
@@ -671,7 +673,14 @@ function posQuery(human, combatType, group, param, flag)
 	msgRet.type = combatType
     msgRet.teamType = combatConfig.teamType
 	msgRet.list[0] = len
-	local heroList,helpList,formation,combatHeroDB = getCombatHeros(human,combatType)
+	local heroList,helpList,formation
+	if combatType == CombatDefine.COMBAT_TYPE36 and extraArgs then
+		AnotherWorldBattleNS = AnotherWorldBattleNS or require("anotherWorldBattle.AnotherWorldBattleNS")
+		heroList,helpList,formation = AnotherWorldBattleNS.getCombatHeros(human,combatType, extraArgs)
+	else
+		heroList,helpList,formation = getCombatHeros(human,combatType)
+	end
+
 	local formationConf = FormationExcel[formation]
 	msgRet.formation = formation
 	len = 0

+ 6 - 0
script/module/hero/HeroLogic.lua

@@ -76,6 +76,7 @@ local GodsAreaNS = require("godsArea.GodsAreaNS")
 local Abs365CardLogic = require("absAct.Abs365CardLogic")
 local HeroSeed = require("hero.HeroSeed")
 local DeleteHeroConfig = require("excel.delteHero")
+local AnotherWorldBattleNS = require("anotherWorldBattle.AnotherWorldBattleNS")
 
 
 HERO_MAX_STAR    =        15    -- 目前英雄最大星级
@@ -792,6 +793,7 @@ function heroLvUp(human, heroID, heroIndex)
 	checkChangeMaxZDL(human, heroGrid)
 
 	GodsAreaNS.UpdateHeroData(human, heroGrid.uuid, 1)
+	AnotherWorldBattleNS.HeroDataUpdate(human, heroGrid.uuid)
 end
 
 -- 英雄升阶查询
@@ -1289,6 +1291,8 @@ function heroJueXingDo(human, heroID, heroIndex, inputIDList, inputIndexList)
 	end
 
 	GodsAreaNS.UpdateHeroData(human, heroGrid.uuid, 1)
+
+	AnotherWorldBattleNS.HeroDataUpdate(human, heroGrid.uuid)
 end
 
 --返还宝石
@@ -1750,6 +1754,8 @@ function huituiHero(human, heroID, heroIndex)
 	end
 
 	GodsAreaNS.UpdateHeroData(human, heroGrid.uuid, 1)
+
+	AnotherWorldBattleNS.HeroDataUpdate(human, heroGrid.uuid)
 end
 
 function getHeroListById(human,heroId)

+ 13 - 0
script/module/middle/MiddleCommonLogic.lua

@@ -240,6 +240,19 @@ function MiddleCommonLogic_CombatBegin_WL(fd, msg)
             [1] = nDesUID
         }
         local objList, helpList, rolebase, formation,jiban, elfList = moduleFn.getCombatObjList(nil, CombatDefine.DEFEND_SIDE, args, msg.nCombatType, msg.extraArgs)
+
+        if not objList and msg.nCombatType == CombatDefine.COMBAT_TYPE35 then
+            if moduleFn.getCombatMonsterOutID then
+                args[2] = msg.extraArgs.cityId
+                local monsterOutId = moduleFn.getCombatMonsterOutID(nil, CombatDefine.DEFEND_SIDE, args)
+
+                if monsterOutId then
+                    objList, helpList, rolebase, formation, jiban, elfList = CombatLogic.getMonsterObjList(monsterOutId)
+                end
+            end
+
+        end
+
         if objList then
             tMsgData.nResult = MiddleDefine.MIDDLE_GET_COMBAT_OK
             tMsgData.tObjList = objList

+ 6 - 0
script/module/role/CreateRole.lua

@@ -34,6 +34,9 @@ local ROLE_NAME_LEN_MIN = 5
 local OP_RET_SUCC = 1
 local OP_RET_FAIL = 0
 
+
+local AnotherWorldBattleNS
+
 -- 特定渠道用户创角时发送的邮件ID
 local NEW_ROLE_MAIL_ID = 7023
 -- 特定渠道列表
@@ -192,6 +195,9 @@ function changeName(human, roleName)
 	local GodsAreaNS = require("godsArea.GodsAreaNS")
 	GodsAreaNS.UpdateShowData(human, 1)
 
+	AnotherWorldBattleNS = AnotherWorldBattleNS or require("anotherWorldBattle.AnotherWorldBattleNS")
+	AnotherWorldBattleNS.PlayerChangeName(human)
+
 	if human.db.changeNameCnt == 1 then
 		-- Log.write(Log.LOGID_OSS_REGISTER, human.db._id, human.db.account, human.db.name, human.ip,human.pf or "",human.appid, human.db.changeNameCnt)
 		-- Log.write(Log.LOGID_OSS_CREATELOSS,human.db.account, human.db.name, LogDefine.HUMAN_LOST.CREATE_NAME_FINISH, human.db.ip,human.pf or "",human.appid, human.phpChanelID)

+ 1 - 0
script/module/roleSystem/RoleSystemDefine.lua

@@ -68,6 +68,7 @@ ROLE_SYS_ID_1212 = 1212 -- 种族试炼-人族试炼
 ROLE_SYS_ID_1213 = 1213 -- 种族试炼-兽族试炼
 ROLE_SYS_ID_1214 = 1214 -- 种族试炼-仙/魔族试炼
 ROLE_SYS_ID_1215 = 1215 -- 幽暗禁地
+ROLE_SYS_ID_1216 = 1216 -- 异界之战
 
 ROLE_SYS_ID_1300 = 1300 -- 主界面竞技
 ROLE_SYS_ID_1301 = 1301 -- 竞技-冠军联赛

+ 12 - 6
script/module/union/UnionLogic.lua

@@ -78,7 +78,7 @@ UNION_CHANGE_OP_3 = 3     -- 解散公会
 local AnotherWorldBattleNS
 
 -- 如果异界之战处于战斗阶段,并且本公会参加了, 则不能做踢人等操作
-local function isCanOperation(union)
+local function isABEnd(union)
     if not union.joinAnotherWorldBattleTi then
         return true
     end
@@ -468,7 +468,7 @@ function dismissUnion(human)
     --     return Broadcast.sendErr(human, Lang.UNION_IS_WARRING)
     -- end
 
-    local res = isCanOperation(union)
+    local res = isABEnd(union)
     if not res then
         return Broadcast.sendErr(human, Lang.AB_CANNOT_OPERATION)
     end
@@ -528,7 +528,7 @@ function applyJoinUnion(human, unionUuid)
         end
 	else
     
-        local res = isCanOperation(union)
+        local res = isABEnd(union)
         if not res then
             return Broadcast.sendErr(human, Lang.AB_CANNOT_OPERATION)
         end
@@ -578,7 +578,7 @@ function agreeJoinUnion(human, uuid, isArgee)
     end
     local isJoin = false
     if isArgee == 1 then
-        local res = isCanOperation(union)
+        local res = isABEnd(union)
         if not res then
             return Broadcast.sendErr(human, Lang.AB_CANNOT_OPERATION)
         end
@@ -666,7 +666,7 @@ function expelPlayer(human, uuid)
         return Broadcast.sendErr(human, Lang.UNION_PLAYER_IN_OTHER)
     end
 
-    local res = isCanOperation(union)
+    local res = isABEnd(union)
     if not res then
         return Broadcast.sendErr(human, Lang.AB_CANNOT_OPERATION)
     end
@@ -694,7 +694,7 @@ function leaveUnion(human)
         return Broadcast.sendErr(human, Lang.UNION_LEVEL_ERR_LEADER)
     end
 
-    local res = isCanOperation(union)
+    local res = isABEnd(union)
     if not res then
         return Broadcast.sendErr(human, Lang.AB_CANNOT_OPERATION)
     end
@@ -968,6 +968,12 @@ function changeUnionName(human, name, bannerID)
     UnionDBLogic.setUnionName(union, name)    
     sendUnionChange(union)
     Broadcast.sendErr(human, Lang.UNION_CHANGE_NAME_SUCCESS)
+
+    if union.joinAnotherWorldBattleTi then
+        union = UnionDBLogic.getUnion(human.db.unionUuid)
+        AnotherWorldBattleNS = AnotherWorldBattleNS or require("anotherWorldBattle.AnotherWorldBattleNS")
+        AnotherWorldBattleNS.UnionChangeName(human.db.unionUuid, union.name)
+    end
 end
 
 -- 公会改旗帜