From ac448ba660cafdba69ca409b45942dbad57f5732 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期五, 09 十月 2020 16:40:43 +0800
Subject: [PATCH] 8533 【BT】【后端】宗门试炼助战修(增加可配置至多机器人人数、是否出现非社交关系玩家)

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py |   62 +++++++++++++++++++-----------
 1 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
index f110140..923067f 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
@@ -101,7 +101,7 @@
         recData.SetValue4(checkInPlayer.checkInCount)
         recData.SetValue5(int("%d%02d%02d%d" % (checkInPlayer.playerLV, checkInPlayer.vipLV, checkInPlayer.realmLV, checkInPlayer.job)))
         recData.SetStrValue1(checkInPlayer.playerName)
-        strValue3 = "%s|%s" % (str(checkInPlayer.todayHelpCountDict).replace(" ", ""), 
+        strValue3 = "%s|%s" % (str(checkInPlayer.todayHelpCountDict).replace(" ", ""),
                                str(checkInPlayer.getThanksGiftCountDict).replace(" ", ""))
         recData.SetStrValue3(strValue3)
         
@@ -243,9 +243,11 @@
     
     onlyFree = False
     goldCallCount = 0
-    nowFreeRelationCount, nowRelationCount = 0, 0
+    nowFreeRelationCount, nowRelationCount, nowRobotCount = 0, 0, 0
     atleastFreeRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 1) # 至少免费社交人数,无社交则忽略
     atleastRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 2) # 至少社交人数,无社交则忽略(人数包含免费社交人数)
+    atmostRobotCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 3) # 助战列表机器人至多数量
+    allowNoRelation = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 4) # 助战列表是否出现非社交关系玩家
     GameWorld.DebugLog("    atleastFreeRelationCount=%s,atleastRelationCount=%s" % (atleastFreeRelationCount, atleastRelationCount))
     
     #已经召唤的保留
@@ -263,6 +265,7 @@
                     nowFreeRelationCount += 1
         # 机器人NPC
         elif 1 <= calledPlayerID <= MaxRobotID:
+            nowRobotCount += 1
             helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
         else:
             GameWorld.ErrLog("已召唤的助战玩家找不到镜像缓存!理论上不存在该情况,镜像缓存释放会比登记有效时长多半小时!")
@@ -272,7 +275,7 @@
         GameWorld.Log("已召唤的助战: %s" % str(helpBattlePlayerDict), playerID)
         
     curTime = int(time.time())
-    maxHelpPlayerSelectCount =  IpyGameDataPY.GetFuncCfg("HelpBattleCall", 1) # 最大可以选择助战的玩家个数
+    maxHelpPlayerSelectCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 1) # 最大可以选择助战的玩家个数
     maxGoldHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 3) # 最大付费召唤人数
     checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # 登记有效时长,小时
     checkInValidSeconds = checkInValidHours * 3600
@@ -281,6 +284,10 @@
     random.shuffle(checkInPlayerIDList)
     GameWorld.Log("    登记助战人数=%s" % (len(checkInPlayerIDList)), playerID)
     
+    if not allowNoRelation:
+        atleastRelationCount = maxHelpPlayerSelectCount
+        GameWorld.DebugLog("不允许出现非社交人数,默认设置至少社交人数为最大可选择人数! %s" % atleastRelationCount)
+        
     # 1. 至少社交关系人数还不足的,先处理至少社交关系人数
     if nowRelationCount < atleastRelationCount:
         relationIDList = []
@@ -307,7 +314,7 @@
             if relationID not in checkInPlayerIDList:
                 continue
             helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[relationID]
-            canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
+            canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
                                                        checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
             if not canHelp:
                 continue
@@ -329,35 +336,37 @@
                     __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
     
     # 2. 常规添加助战人数        
-    for checkInPlayerID in checkInPlayerIDList:
-        if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
-            GameWorld.DebugLog("    超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
-            break
-        helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
-        canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
-                                                   checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
-        if not canHelp:
-            continue
-        
-        goldCallCount, nowRelationCount, nowFreeRelationCount = \
-            __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
+    if allowNoRelation:
+        for checkInPlayerID in checkInPlayerIDList:
+            if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
+                GameWorld.DebugLog("    超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
+                break
+            helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
+            canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
+                                                       checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
+            if not canHelp:
+                continue
+            
+            goldCallCount, nowRelationCount, nowFreeRelationCount = \
+                __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
         
     # 3. 不足的机器人NPC补足
     openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 开放的职业
     lackCount = maxHelpPlayerSelectCount - len(helpBattlePlayerDict)
     robotID = 0 # 机器人NPC定义ID从1开始
-    while lackCount > 0 and robotID < MaxRobotID:
+    while lackCount > 0 and robotID < MaxRobotID and nowRobotCount < atmostRobotCount:
         robotID += 1
         if robotID in helpBattlePlayerDict:
             continue
         lackCount -= 1
+        nowRobotCount += 1
         randJob = random.choice(openJobList)
         helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
     
     GameWorld.Log("    helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)
     return [helpBattlePlayerDict]
 
-def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
+def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
                        checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree=False, goldCallCount=0, maxGoldHelpPlayerCount=0):            
     ## 常规检查是否满足助战条件
     if checkInPlayerID == playerID:
@@ -469,9 +478,12 @@
     GameWorld.Log("扫荡刷新助战列表: mapID=%s,funcLineID=%s,helpCountLineID=%s" % (mapID, funcLineID, helpCountLineID), playerID)
     
     curTime = int(time.time())
-    maxHelpPlayerCount =  IpyGameDataPY.GetFuncCfg("HelpBattleCall", 2) # 最大助战人数
+    maxHelpPlayerCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall", 2) # 最大助战人数
     checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # 登记有效时长,小时
     checkInValidSeconds = checkInValidHours * 3600
+    
+    atmostRobotCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 3) # 助战列表机器人至多数量
+    allowNoRelation = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 4) # 助战列表是否出现非社交关系玩家
     
     onlyFree = True
     checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
@@ -482,23 +494,27 @@
             GameWorld.DebugLog("    超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
             break
         helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
-        canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, 
+        canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax,
                                                    checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree)
         if not canHelp:
             continue
-        helpBattlePlayer.todayHelpCountDict[helpCountKey] = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
         relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
+        if not allowNoRelation and not relation:
+            continue
+        helpBattlePlayer.todayHelpCountDict[helpCountKey] = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
         helpBattlePlayerDict[checkInPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
         
+    nowRobotCount = 0
     # 不足的机器人NPC补足
     openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 开放的职业
     lackCount = maxHelpPlayerCount - len(helpBattlePlayerDict)
     robotID = 0 # 机器人NPC定义ID从1开始
-    while lackCount > 0 and robotID < MaxRobotID:
+    while lackCount > 0 and robotID < MaxRobotID and nowRobotCount < atmostRobotCount:
         robotID += 1
         if robotID in helpBattlePlayerDict:
             continue
         lackCount -= 1
+        nowRobotCount += 1
         randJob = random.choice(openJobList)
         helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
     
@@ -541,7 +557,7 @@
         if assistPlayerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
             continue
         helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[assistPlayerID]
-        assistPlayerDict[assistPlayerID] = {"PlayerName":helpBattlePlayer.playerName, "Job":helpBattlePlayer.job, 
+        assistPlayerDict[assistPlayerID] = {"PlayerName":helpBattlePlayer.playerName, "Job":helpBattlePlayer.job,
                                             "LV":helpBattlePlayer.playerLV, "RealmLV":helpBattlePlayer.realmLV,
                                             "TodayGiftCount":helpBattlePlayer.getThanksGiftCountDict.get(liheItemID, 0)}
     

--
Gitblit v1.8.0