| | |
| | | import ShareDefine
|
| | | import PyGameData
|
| | | import GameWorld
|
| | | import ChConfig
|
| | |
|
| | | import random
|
| | | import time
|
| | |
| | | def __init__(self, playerID):
|
| | | self.playerID = playerID
|
| | | self.job = 0
|
| | | self.face = 0
|
| | | self.facePic = 0
|
| | | self.playerName = ""
|
| | | self.playerLV = 0
|
| | | self.realmLV = 0
|
| | |
| | | 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 "{}"
|
| | |
| | | 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)
|
| | |
|
| | |
| | | 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)
|
| | |
| | | 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()
|
| | |
| | | ## 更新登记的助战玩家等级战力
|
| | | 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
|
| | |
| | | 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)
|
| | |
| | |
|
| | | 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:
|
| | |
| | | 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
|
| | |
| | | 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,
|
| | | "Face":helpBattlePlayer.face, "FacePic":helpBattlePlayer.facePic,
|
| | | "LV":helpBattlePlayer.playerLV, "RealmLV":helpBattlePlayer.realmLV,
|
| | | "TodayGiftCount":helpBattlePlayer.getThanksGiftCountDict.get(liheItemID, 0)}
|
| | |
|