From 388823edfe6308cba6f76ca6dc4f20022c5cb2be Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 30 六月 2025 19:03:50 +0800
Subject: [PATCH] 10431 【英文】看广告获得限时代金券

---
 ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py |   83 +++++++++++++++++++++++++++++------------
 1 files changed, 59 insertions(+), 24 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
index f110140..78a13f2 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
@@ -23,6 +23,7 @@
 import ShareDefine
 import PyGameData
 import GameWorld
+import ChConfig
 
 import random
 import time
@@ -37,6 +38,8 @@
     def __init__(self, playerID):
         self.playerID = playerID
         self.job = 0
+        self.face = 0
+        self.facePic = 0
         self.playerName = ""
         self.playerLV = 0
         self.realmLV = 0
@@ -67,6 +70,10 @@
         helpBattlePlayer.realmLV = int(str(value5)[-3:-1])
         helpBattlePlayer.job = value5 % 10
         helpBattlePlayer.playerName = recData.GetStrValue1()
+        strValue2 = recData.GetStrValue2()
+        strValue2List = strValue2.split("|")
+        helpBattlePlayer.face = GameWorld.ToIntDef(strValue2List[0] if len(strValue2List) > 0 else "0", 0)
+        helpBattlePlayer.facePic = GameWorld.ToIntDef(strValue2List[1] if len(strValue2List) > 1 else "0", 0)
         strValue3 = recData.GetStrValue3()
         strValue3List = strValue3.split("|")
         helpCountDictStr = strValue3List[0] if len(strValue3List) > 0 else "{}"
@@ -96,12 +103,13 @@
         recData = checkInPlayerRecList.AddRec()
         recData.SetTime(checkInPlayer.checkInTime)
         recData.SetValue1(playerID)
-        recData.SetValue2(checkInPlayer.fightPower)
+        recData.SetValue2(min(max(checkInPlayer.fightPower, 0), ChConfig.Def_UpperLimit_DWord))
         recData.SetValue3(checkInPlayer.familyID)
         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(" ", ""), 
+        recData.SetStrValue2("%s|%s" % (checkInPlayer.face, checkInPlayer.facePic))
+        strValue3 = "%s|%s" % (str(checkInPlayer.todayHelpCountDict).replace(" ", ""),
                                str(checkInPlayer.getThanksGiftCountDict).replace(" ", ""))
         recData.SetStrValue3(strValue3)
         
@@ -165,6 +173,7 @@
 def __DoPlayerFBHelpBattleCheckIn(curPlayer, msgList):
     ## 玩家登记
     checkInCount, fightPower = msgList[1:]
+    fightPower = min(fightPower, ChConfig.Def_UpperLimit_DWord) # 登记助战战力最高暂支持20E
     curTime = int(time.time())
     playerID = curPlayer.GetPlayerID()
     curCache = PlayerViewCache.FindViewCache(playerID)
@@ -177,6 +186,8 @@
     helpBattlePlayer.playerName = curPlayer.GetName()
     helpBattlePlayer.playerLV = curPlayer.GetLV()
     helpBattlePlayer.job = curPlayer.GetJob()
+    helpBattlePlayer.face = curPlayer.GetFace()
+    helpBattlePlayer.facePic = curPlayer.GetFacePic()
     helpBattlePlayer.realmLV = curPlayer.GetOfficialRank()
     helpBattlePlayer.fightPower = fightPower
     helpBattlePlayer.familyID = curPlayer.GetFamilyID()
@@ -193,6 +204,7 @@
     ## 更新登记的助战玩家等级战力
     if playerID not in PyGameData.g_fbHelpBattleCheckInPlayerDict:
         return
+    fightPower = min(fightPower, ChConfig.Def_UpperLimit_DWord) # 登记助战战力最高暂支持20E
     helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[playerID]
     helpBattlePlayer.fightPower = fightPower
     helpBattlePlayer.familyID = familyID
@@ -210,6 +222,10 @@
         helpBattlePlayer.playerLV = value
     elif refreshType == IPY_GameServer.CDBPlayerRefresh_VIPLv:
         helpBattlePlayer.vipLV = value
+    elif refreshType == IPY_GameServer.CDBPlayerRefresh_Face:
+        helpBattlePlayer.face = value
+    elif refreshType == IPY_GameServer.CDBPlayerRefresh_HairColor:
+        helpBattlePlayer.facePic = value
     else:
         return
     GameWorld.DebugLog("更新助战玩家信息: refreshType=%s,value=%s" % (refreshType, value), playerID)
@@ -243,9 +259,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 +281,7 @@
                     nowFreeRelationCount += 1
         # 机器人NPC
         elif 1 <= calledPlayerID <= MaxRobotID:
+            nowRobotCount += 1
             helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
         else:
             GameWorld.ErrLog("已召唤的助战玩家找不到镜像缓存!理论上不存在该情况,镜像缓存释放会比登记有效时长多半小时!")
@@ -272,7 +291,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 +300,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 +330,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 +352,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:
@@ -435,6 +460,8 @@
     helpPlayerDict["Name"] = helpBattlePlayer.playerName
     helpPlayerDict["LV"] = helpBattlePlayer.playerLV
     #helpPlayerDict["Job"] = helpBattlePlayer.job
+    helpPlayerDict["Face"] = helpBattlePlayer.face
+    helpPlayerDict["FacePic"] = helpBattlePlayer.facePic
     helpPlayerDict["RealmLV"] = helpBattlePlayer.realmLV
     helpPlayerDict["FightPower"] = helpBattlePlayer.fightPower
     helpPlayerDict["Relation"] = relation
@@ -469,9 +496,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 +512,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 +575,8 @@
         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,
+                                            "Face":helpBattlePlayer.face, "FacePic":helpBattlePlayer.facePic,
                                             "LV":helpBattlePlayer.playerLV, "RealmLV":helpBattlePlayer.realmLV,
                                             "TodayGiftCount":helpBattlePlayer.getThanksGiftCountDict.get(liheItemID, 0)}
     

--
Gitblit v1.8.0