| | |
| | | import ShareDefine
|
| | | import PyGameData
|
| | | import GameWorld
|
| | | import ChConfig
|
| | |
|
| | | import random
|
| | | import time
|
| | |
| | | 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)
|
| | |
|
| | |
| | | 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)
|
| | |
| | |
|
| | | 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))
|
| | |
|
| | | #已经召唤的保留
|
| | |
| | | nowFreeRelationCount += 1
|
| | | # 机器人NPC
|
| | | elif 1 <= calledPlayerID <= MaxRobotID:
|
| | | nowRobotCount += 1
|
| | | helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
|
| | | else:
|
| | | GameWorld.ErrLog("已召唤的助战玩家找不到镜像缓存!理论上不存在该情况,镜像缓存释放会比登记有效时长多半小时!")
|
| | |
| | | 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
|
| | |
| | | random.shuffle(checkInPlayerIDList)
|
| | | GameWorld.Log(" 登记助战人数=%s" % (len(checkInPlayerIDList)), playerID)
|
| | |
|
| | | if not allowNoRelation:
|
| | | atleastRelationCount = maxHelpPlayerSelectCount
|
| | | GameWorld.DebugLog("不允许出现非社交人数,默认设置至少社交人数为最大可选择人数! %s" % atleastRelationCount)
|
| | | |
| | | # 1. 至少社交关系人数还不足的,先处理至少社交关系人数
|
| | | if nowRelationCount < atleastRelationCount:
|
| | | relationIDList = []
|
| | |
| | | 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
|
| | |
| | | __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:
|
| | |
| | | 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()
|
| | |
| | | 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)
|
| | |
|
| | |
| | | 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)}
|
| | |
|