Преглед на файлове

1.异界之战奖励计算公式修改 2.增加异界之战被挑战中标识

gitxsm преди 6 месеца
родител
ревизия
25e09dca3f

+ 1 - 0
script/common/Lang.lua

@@ -844,5 +844,6 @@ AB_JOINED = [[已报名]]
 AB_OCCUPY_POINT_MAX = [[当前占据的据点已达上限]]
 AB_HERO_IN_OTHER_POINT= [[英雄在其他据点上阵了]]
 AB_UPDATE_LINEUP_SUCC= [[更换防守阵容成功]]
+AB_POINT_CHALLENGING= [[据点正被挑战, 请稍后再试]]
 
 AB_MIYAO_NOT_ENOUG = [[秘钥不足]]

+ 46 - 22
script/module/anotherWorldBattle/AnotherWorldBattleCS.lua

@@ -238,18 +238,21 @@ local function genUnionOccupyInfo(unionId, union, playerListData)
     }
 
     local now = os.time()
-    local tbl = occupyTb.occupyCityArr
-    tbl[#tbl+1] = union.baseCityId
+    local t1 = occupyTb.occupyCityArr
+    local t2 = occupyTb.point2CityIdArr
+
+    t1[#t1+1] = union.baseCityId
 
-    local tbl2 = occupyTb.point2CityIdArr
     for cityId, cityIno in pairs(union.occupCityList or {}) do
         if cityIno.isOccupy then
-            tbl[#tbl+1] = cityId
+            t1[#t1+1] = cityId
         end
 
         for _, pointInfo in pairs(cityIno.occupyPointList) do
             if pointInfo.playerUuid then
-                occupyTb.occuoyPointNum = occupyTb.occuoyPointNum + 1
+                if not cityIno.isOccupy then
+                    occupyTb.occuoyPointNum = occupyTb.occuoyPointNum + 1
+                end
 
                 -- 更新据点最新占领时间段的结束时间
                 local occupyTimeArr = pointInfo.occupyTimeArr
@@ -259,14 +262,14 @@ local function genUnionOccupyInfo(unionId, union, playerListData)
                 end
             end
 
-            tbl2[#tbl2+1] = {cityId, pointInfo.occupyTimeArr}
+            t2[#t2+1] = {cityId, pointInfo.occupyTimeArr}
         end
     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}
+        t2[#t2+1] = {union.baseCityId,  baseCiyuTimeArr}
     end
 
 
@@ -304,7 +307,7 @@ function IssueRewardManager()
     end
 end
 
--- 检测活动各阶段及相关处理
+-- 检测活动各阶段状态及相关处理
 local function timedStageHandle()
     -- 处于报名阶段
     -- if table.find(AnotherWorldBattleDefine.AB_JOIN_WDAY_AREA, wDay) then
@@ -557,8 +560,7 @@ local function isCanChallengePoint(targetCityId, targetPointIdx, myUnionId, play
         return -2
     end
 
-    local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
-    local tagetCityData = cityList[targetCityId]
+    local tagetCityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
     if not tagetCityData then
         return -3
     end
@@ -839,8 +841,8 @@ function N2C_CityDetailed_Query(msg)
         return errTips(msg.sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
     end
 
-    local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
-    if not cityList or not cityList[targetCityId] then
+    local cityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
+    if not cityData then
         return errTips(msg.sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_4)
     end
 
@@ -853,9 +855,8 @@ function N2C_CityDetailed_Query(msg)
     end
     msgData.myUnionOccupyArr = myUnionOccupyArr
 
-    local cityData = cityList[targetCityId]
-    local pointArrMsg = msgData.pointArr
 
+    local pointArrMsg = msgData.pointArr
     for pointIdx, occupyInfo in ipairs(cityData.pointArr) do
         pointArrMsg[pointIdx] = {}
         local state = isCanChallengePoint(targetCityId, pointIdx, myUnionId, playerUuid)
@@ -929,12 +930,11 @@ function N2C_PointDetailed_Query(msg)
         return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
     end
 
-    local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
-    if not cityList or not cityList[targetCityId] then
+    local cityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
+    if not cityData then
         return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_4)
     end
 
-    local cityData = cityList[targetCityId]
     local pointData = cityData.pointArr[targetPointIdx]
     if not pointData then
         return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_4)
@@ -1226,8 +1226,8 @@ function N2C_Try_Challengde_Point(msg)
     end
 
     local groupId = getMyUnionGourpId(myUnionId)
-    local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
-    local targetPointData = cityList[targetCityId].pointArr[targetPointIdx]
+    local cityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
+    local targetPointData = cityData.pointArr[targetPointIdx]
 
     local pointOccupyInfo = {targetCityId = targetCityId, targetPointIdx = targetPointIdx}
     if targetPointData.unionId then
@@ -1241,6 +1241,18 @@ function N2C_Try_Challengde_Point(msg)
         pointOccupyInfo.isGather = 1
     end
 
+    -- 检查据点是否有人挑战
+    local now = os.time()
+    local pointBattleTime = targetPointData.battleTime
+    if pointBattleTime and now - pointBattleTime < AnotherWorldBattleDefine.AB_POINT_BATTLE_TIME then
+        return errTips(msg.sourceServerId, playerUuid, AnotherWorldBattleDefine.ERR_CODE_10)
+    end
+
+    -- 更新据点被挑战时间
+    targetPointData.battleTime = now
+    AnotherWorldBattleDB.UpdateCityData(groupId, targetCityId, cityData)
+
+
     local msgData = InnerMsg.wl.WL_ANOTHERWORLDBATTLE_POINT_ISCAN_CHALLENGE
     msgData.playerUuid = playerUuid
     msgData.targetCityId = targetCityId
@@ -1273,8 +1285,7 @@ local function challenge_Win(msg)
         return errTips(msg.sourceServerId, msg.playerUuid, AnotherWorldBattleDefine.ERR_CODE_3)
     end
 
-    local cityList = AnotherWorldBattleDB.GetCityListByGroupId(groupId)
-    local cityData = cityList[targetCityId]
+    local cityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
     local pointData = cityData.pointArr[targetPointIdx]
 
     local now = os.time()
@@ -1328,6 +1339,9 @@ local function challenge_Win(msg)
     pointData.unionId = myUnionId
     pointData.playerUuid = playerUuid
 
+    -- 据点挑战结束
+    pointData.battleTime = nil
+
     -- 更新进攻方公会数据—— 据点占有者, 最新的据点占有时间
     myUnionData.occupCityList = myUnionData.occupCityList or {}
     local occupCityList = myUnionData.occupCityList
@@ -1388,18 +1402,28 @@ local function challenge_Win(msg)
 
 
     -- 更新城池数据
-    AnotherWorldBattleDB.UpdateCityList(groupId, cityList)
+    AnotherWorldBattleDB.UpdateCityData(groupId, targetCityId, cityData)
 end
 -- 玩家挑战据点失败
 local function challenge_Fail(msg)
     local playerUuid = msg.playerUuid
     local myUnionId = msg.myUnionId
+    local targetCityId = msg.targetCityId
+    local targetPointIdx = msg.targetPointIdx
 
     local groupId = getMyUnionGourpId(myUnionId)
     if not groupId then
         return
     end
 
+    -- 据点挑战结束
+    local cityData = AnotherWorldBattleDB.GetCityData(groupId, targetCityId)
+    if cityData and cityData.pointArr[targetPointIdx] then
+        local targetPointData = cityData.pointArr[targetPointIdx]
+        targetPointData.battleTime = nil
+        AnotherWorldBattleDB.UpdateCityData(groupId, targetCityId, cityData)
+    end
+
     local playerData = AnotherWorldBattleDB.GetPlayerData(playerUuid)
     playerData = playerData or {}
     playerData.name = playerData.name

+ 16 - 2
script/module/anotherWorldBattle/AnotherWorldBattleDB.lua

@@ -282,7 +282,7 @@ local function createPlayerRank()
     end
 
     -- 预分配 tmp 数组,避免运行时扩容
-    for i = 1, 500 do tmp[i] = false end
+    for i = 1, 500 do tmp[i] = nil end
 
     local function updatePlayer(id, name, power, pNum, pWeight)
         -- 1. 取出或新建记录
@@ -592,16 +592,30 @@ end
 
 
 -- 获取城池数据
+function GetCityData(groupId, cityId)
+    if Group_2_CityList[groupId] then
+        return Group_2_CityList[groupId][cityId]
+    end
+end
+-- 更新城池数据
+function UpdateCityData(groupId, cityId, newCityData)
+    if Group_2_CityList[groupId] then
+        Group_2_CityList[groupId][cityId] = newCityData
+    end
+end
+
+-- 获取所有城池数据
 function GetCityListByGroupId(groupId)
     return Group_2_CityList[groupId]
 end
--- 更新城池数据
+-- 更新所有城池数据
 function UpdateCityList(groupId, newCityList)
     Group_2_CityList[groupId] = newCityList
 end
 
 
 
+
 -- 获取公会排行数据
 function GetUnionRankList(groupId)
     local unionRank = Group_2_UnionRankList[groupId]

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

@@ -36,8 +36,12 @@ AB_PLAYER_OCCUPY_POINT_MAX_NUM = 15  -- 每个玩家最多占领据点数量
 AB_RANK_MAX_NUM = 50        -- 公会/个人排行榜最大上榜数量
 
 AB_PLAYER_CHALLENGE_TIMES = 50  -- 玩家初始时挑战次数
+
 AB_PLAYER_CHALLENGETIMES_SEC = 3600  -- 每一个小时恢复一次挑战次数
 
+AB_POINT_BATTLE_TIME = 3        -- 挑战据点从发起战斗 ~ 结束时间
+
+
 
 AB_AWARD_MAIL_ID = 7030        -- 奖励发放邮件Id
 AB_LOSE_POINT_MAIL_ID = 7031   -- 玩家失去据点后通知邮件Id
@@ -57,7 +61,7 @@ ERR_CODE_7 = 7      -- 城池不相邻
 ERR_CODE_8 = 8      -- 公会已报名
 ERR_CODE_9 = 9      -- 没有在本城池发起集结
 ERR_CODE_10 = 10    -- 当前占据的据点已达上限
-
+ERR_CODE_11 = 11    -- 当前据点被挑战中, 请稍后再试
 
 
 

+ 10 - 4
script/module/anotherWorldBattle/AnotherWorldBattleNS.lua

@@ -356,25 +356,29 @@ local function genAwardObjArr(unionOccupyInfo)
         return math.floor(minuteVal / 60)
     end
 
+    -- 没有玩家参与
     if not unionOccupyInfo.playerUuidArr or #unionOccupyInfo.playerUuidArr <= 0 then
         return
     end
 
     local itemList = {}
     local occupyCityInfo = {0,0,0,0,0}
-
     local item_185_Id = 185
     local item_185_Num = 0
-    item_185_Num = item_185_Num + (unionOccupyInfo.occuoyPointNum or 0) -- 待优化
+
+
+    occupyCityInfo[1] = unionOccupyInfo.occuoyPointNum
+
 
     -- 额外奖励
+    item_185_Num = item_185_Num + (unionOccupyInfo.occuoyPointNum or 0)
+
     for _, cityId in ipairs(unionOccupyInfo.occupyCityArr) do
         local cityCfg = AnotherWorldBattleConfig.city[cityId]
 
         if cityCfg then
             if cityCfg.isBaseCity == 1 then
                 item_185_Num = item_185_Num + 20
-                occupyCityInfo[1] = occupyCityInfo[1] + 1
             else
                 if cityCfg.cityLv == 2 then
                     item_185_Num = item_185_Num + 2
@@ -397,8 +401,8 @@ local function genAwardObjArr(unionOccupyInfo)
     for _, pointInfo in ipairs(unionOccupyInfo.point2CityIdArr) do
         local cityId = pointInfo[1]
         local occupyTimeArr = pointInfo[2]
-        local cityCfg = AnotherWorldBattleConfig.city[cityId]
 
+        local cityCfg = AnotherWorldBattleConfig.city[cityId]
         local totalMinVal = calcMinute(occupyTimeArr)
         if totalMinVal > 0 then
             local itemId, itemNum = cityCfg.cityAward[1], cityCfg.cityAward[2]
@@ -850,6 +854,8 @@ function C2N_ErrTips(msg)
         tips = Lang.AB_CITY_NO_GATHER
     elseif errCode == AnotherWorldBattleDefine.ERR_CODE_10 then
         tips = Lang.AB_OCCUPY_POINT_MAX
+    elseif errCode == AnotherWorldBattleDefine.ERR_CODE_11 then
+        tips = Lang.AB_POINT_CHALLENGING
     end
 
     Broadcast.sendErr(human, tips)