| | |
| | | GameWorld.Log("刷新助战列表: mapID=%s,funcLineID=%s,helpCountLineID=%s,isClientRefresh=%s,costMoneyList=%s,calledPlayerIDDict=%s"
|
| | | % (mapID, funcLineID, helpCountLineID, isClientRefresh, costMoneyList, calledPlayerIDDict), playerID)
|
| | |
|
| | | onlyFree = False
|
| | | goldCallCount = 0
|
| | | nowFreeRelationCount, nowRelationCount = 0, 0
|
| | | atleastFreeRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 1) # 至少免费社交人数,无社交则忽略
|
| | | atleastRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 2) # 至少社交人数,无社交则忽略(人数包含免费社交人数)
|
| | | GameWorld.DebugLog(" atleastFreeRelationCount=%s,atleastRelationCount=%s" % (atleastFreeRelationCount, atleastRelationCount))
|
| | |
|
| | | #已经召唤的保留
|
| | | for calledPlayerID, callInfo in calledPlayerIDDict.items():
|
| | |
| | | helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, job, relation)
|
| | | if needGoldCall:
|
| | | goldCallCount += 1
|
| | | if relation:
|
| | | nowRelationCount += 1
|
| | | if not needGoldCall:
|
| | | nowFreeRelationCount += 1
|
| | | # 机器人NPC
|
| | | elif 1 <= calledPlayerID <= MaxRobotID:
|
| | | helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
|
| | |
| | | checkInValidSeconds = checkInValidHours * 3600
|
| | |
|
| | | checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
|
| | | random.shuffle(checkInPlayerIDList) # 刷新纯随机
|
| | | random.shuffle(checkInPlayerIDList)
|
| | | GameWorld.Log(" 登记助战人数=%s" % (len(checkInPlayerIDList)), playerID)
|
| | | |
| | | # 1. 至少社交关系人数还不足的,先处理至少社交关系人数
|
| | | if nowRelationCount < atleastRelationCount:
|
| | | relationIDList = []
|
| | | friendIDList = PlayerFriend.GetFriendStruct(playerID).GetSocialIDList()
|
| | | relationIDList += friendIDList
|
| | | #GameWorld.DebugLog(" 好友ID列表, friendIDList=%s" % friendIDList, playerID)
|
| | | curFamily = curPlayer.GetFamily()
|
| | | familyMemList = []
|
| | | if curFamily:
|
| | | for index in xrange(curFamily.GetCount()):
|
| | | member = curFamily.GetAt(index)
|
| | | memberID = member.GetPlayerID()
|
| | | familyMemList.append(memberID)
|
| | | if memberID != playerID and memberID not in relationIDList:
|
| | | relationIDList.append(memberID)
|
| | | #GameWorld.DebugLog(" 盟友ID列表, familyMemList=%s" % familyMemList, playerID)
|
| | | |
| | | random.shuffle(relationIDList)
|
| | | #GameWorld.DebugLog(" 有社交的ID列表, relationIDList=%s" % relationIDList, playerID)
|
| | | tempRelationHelpPlayerList = []
|
| | | for relationID in relationIDList:
|
| | | if nowRelationCount >= atleastRelationCount:
|
| | | break
|
| | | if relationID not in checkInPlayerIDList:
|
| | | continue
|
| | | helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[relationID]
|
| | | canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, relationID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, |
| | | checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
|
| | | if not canHelp:
|
| | | continue
|
| | | |
| | | # 免费社交人数不足且免费 or 免费社交人数够了且总社交人数还不够 ; 都直接加入助战列表
|
| | | if (nowFreeRelationCount < atleastFreeRelationCount and not needGoldCall) \
|
| | | or (nowFreeRelationCount >= atleastFreeRelationCount and nowRelationCount < atleastRelationCount):
|
| | | goldCallCount, nowRelationCount, nowFreeRelationCount = \
|
| | | __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
|
| | | else:
|
| | | lackRelationCount = atleastRelationCount - nowRelationCount
|
| | | if len(tempRelationHelpPlayerList) < lackRelationCount:
|
| | | tempRelationHelpPlayerList.append([helpBattlePlayer, needGoldCall])
|
| | | |
| | | lackRelationCount = atleastRelationCount - nowRelationCount
|
| | | if lackRelationCount > 0:
|
| | | for helpBattlePlayer, needGoldCall in tempRelationHelpPlayerList[:lackRelationCount]:
|
| | | goldCallCount, nowRelationCount, nowFreeRelationCount = \
|
| | | __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
|
| | | |
| | | # 2. 常规添加助战人数 |
| | | for checkInPlayerID in checkInPlayerIDList:
|
| | | if checkInPlayerID == playerID:
|
| | | GameWorld.DebugLog(" 自己不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | continue
|
| | | if checkInPlayerID in helpBattlePlayerDict:
|
| | | GameWorld.DebugLog(" 已经在助战里的不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | continue
|
| | | if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
|
| | | GameWorld.DebugLog(" 超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | break
|
| | | helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
|
| | | checkInPlayerLV = helpBattlePlayer.playerLV
|
| | | checkInPlayerFightPower = helpBattlePlayer.fightPower
|
| | | checkInTime = helpBattlePlayer.checkInTime
|
| | | if checkInPlayerLV < limitLV:
|
| | | GameWorld.DebugLog(" 等级不足, checkInPlayerID=%s,checkInPlayerLV=%s < limitLV=%s" % (checkInPlayerID, checkInPlayerLV, limitLV))
|
| | | canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, |
| | | checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree, goldCallCount, maxGoldHelpPlayerCount)
|
| | | if not canHelp:
|
| | | continue
|
| | | if fightPowerMin and checkInPlayerFightPower < fightPowerMin:
|
| | | GameWorld.DebugLog(" 战力不足, checkInPlayerID=%s,checkInPlayerFightPower=%s < fightPowerMin=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMin))
|
| | | continue
|
| | | if fightPowerMax and checkInPlayerFightPower > fightPowerMax:
|
| | | GameWorld.DebugLog(" 战力超出, checkInPlayerID=%s,checkInPlayerFightPower=%s > fightPowerMax=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMax))
|
| | | continue
|
| | | passTime = curTime - checkInTime
|
| | | if passTime > checkInValidSeconds:
|
| | | GameWorld.DebugLog(" 登记超时, checkInPlayerID=%s,checkInTime=%s,passTime=%s > checkInValidSeconds=%s" % (checkInPlayerID, checkInTime, passTime, checkInValidSeconds))
|
| | | continue
|
| | | needGoldCall = False
|
| | | if dayFreeHelpCount:
|
| | | todayHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0)
|
| | | needGoldCall = todayHelpCount >= dayFreeHelpCount
|
| | | if needGoldCall and goldCallCount >= maxGoldHelpPlayerCount:
|
| | | GameWorld.DebugLog(" 超过最大付费召唤人数, checkInPlayerID=%s,goldCallCount=%s > maxGoldHelpPlayerCount=%s" % (checkInPlayerID, goldCallCount, maxGoldHelpPlayerCount))
|
| | | continue
|
| | | goldCallCount += 1
|
| | | relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
|
| | | helpBattlePlayerDict[checkInPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
|
| | |
|
| | | # 不足的机器人NPC补足
|
| | | 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开始
|
| | |
| | |
|
| | | GameWorld.Log(" helpBattlePlayerDict=%s" % (helpBattlePlayerDict), playerID)
|
| | | return [helpBattlePlayerDict]
|
| | |
|
| | | def __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, |
| | | checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree=False, goldCallCount=0, maxGoldHelpPlayerCount=0): |
| | | ## 常规检查是否满足助战条件
|
| | | if checkInPlayerID == playerID:
|
| | | GameWorld.DebugLog(" 自己不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | return False, False
|
| | | if checkInPlayerID in helpBattlePlayerDict:
|
| | | GameWorld.DebugLog(" 已经在助战里的不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | return False, False
|
| | | checkInPlayerLV = helpBattlePlayer.playerLV
|
| | | checkInPlayerFightPower = helpBattlePlayer.fightPower
|
| | | checkInTime = helpBattlePlayer.checkInTime
|
| | | if checkInPlayerLV < limitLV:
|
| | | GameWorld.DebugLog(" 等级不足, checkInPlayerID=%s,checkInPlayerLV=%s < limitLV=%s" % (checkInPlayerID, checkInPlayerLV, limitLV))
|
| | | return False, False
|
| | | if fightPowerMin and checkInPlayerFightPower < fightPowerMin:
|
| | | GameWorld.DebugLog(" 战力不足, checkInPlayerID=%s,checkInPlayerFightPower=%s < fightPowerMin=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMin))
|
| | | return False, False
|
| | | if fightPowerMax and checkInPlayerFightPower > fightPowerMax:
|
| | | GameWorld.DebugLog(" 战力超出, checkInPlayerID=%s,checkInPlayerFightPower=%s > fightPowerMax=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMax))
|
| | | return False, False
|
| | | passTime = curTime - checkInTime
|
| | | if passTime > checkInValidSeconds:
|
| | | GameWorld.DebugLog(" 登记超时, checkInPlayerID=%s,checkInTime=%s,passTime=%s > checkInValidSeconds=%s" % (checkInPlayerID, checkInTime, passTime, checkInValidSeconds))
|
| | | return False, False
|
| | | todayHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0)
|
| | | needGoldCall = dayFreeHelpCount and todayHelpCount >= dayFreeHelpCount
|
| | | if needGoldCall:
|
| | | if onlyFree:
|
| | | GameWorld.DebugLog(" 不是免费, checkInPlayerID=%s,todayHelpCount=%s > dayFreeHelpCount=%s" % (checkInPlayerID, todayHelpCount, dayFreeHelpCount))
|
| | | return False, needGoldCall
|
| | | if goldCallCount >= maxGoldHelpPlayerCount:
|
| | | GameWorld.DebugLog(" 超过最大付费召唤人数, checkInPlayerID=%s,goldCallCount=%s > maxGoldHelpPlayerCount=%s" % (checkInPlayerID, goldCallCount, maxGoldHelpPlayerCount))
|
| | | return False, needGoldCall
|
| | | return True, needGoldCall
|
| | |
|
| | | def __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount):
|
| | | ## 添加助战玩家到助战列表
|
| | | if needGoldCall:
|
| | | goldCallCount += 1
|
| | | relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
|
| | | if relation:
|
| | | nowRelationCount += 1
|
| | | if not needGoldCall:
|
| | | nowFreeRelationCount += 1
|
| | | helpPlayerID = helpBattlePlayer.playerID
|
| | | helpBattlePlayerDict[helpPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
|
| | | GameWorld.DebugLog(" 助战列表添加玩家: helpPlayerID=%s,needGoldCall=%s,relation=%s,goldCallCount=%s,nowRelationCount=%s,nowFreeRelationCount=%s" |
| | | % (helpPlayerID, needGoldCall, relation, goldCallCount, nowRelationCount, nowFreeRelationCount))
|
| | | return goldCallCount, nowRelationCount, nowFreeRelationCount
|
| | |
|
| | | def __GetHelpBattleRelation(curPlayer, helpBattlePlayer):
|
| | | ## 获取助战社交关系 0-无,1-好友,2-盟友
|
| | |
| | | relationCoinAddDict = IpyGameDataPY.GetFuncEvalCfg("HelpBattlePoint", 2, {}) # 社交关系加成 {"社交关系":[过关加成, 助战加成], ...}
|
| | |
|
| | | isSweep = True
|
| | | onlyFree = True
|
| | | checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
|
| | | random.shuffle(checkInPlayerIDList) # 刷新纯随机
|
| | | GameWorld.Log(" 登记助战人数=%s" % (len(checkInPlayerIDList)), playerID)
|
| | | for checkInPlayerID in checkInPlayerIDList:
|
| | | if checkInPlayerID == playerID:
|
| | | GameWorld.DebugLog(" 自己不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | continue
|
| | | if checkInPlayerID in helpBattlePlayerDict:
|
| | | GameWorld.DebugLog(" 已经在助战里的不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | continue
|
| | | if len(helpBattlePlayerDict) >= maxHelpPlayerCount:
|
| | | GameWorld.DebugLog(" 超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
|
| | | break
|
| | | helpBattlePlayer = PyGameData.g_fbHelpBattleCheckInPlayerDict[checkInPlayerID]
|
| | | checkInPlayerLV = helpBattlePlayer.playerLV
|
| | | checkInPlayerFightPower = helpBattlePlayer.fightPower
|
| | | checkInTime = helpBattlePlayer.checkInTime
|
| | | if checkInPlayerLV < limitLV:
|
| | | GameWorld.DebugLog(" 等级不足, checkInPlayerID=%s,checkInPlayerLV=%s < limitLV=%s" % (checkInPlayerID, checkInPlayerLV, limitLV))
|
| | | continue
|
| | | if fightPowerMin and checkInPlayerFightPower < fightPowerMin:
|
| | | GameWorld.DebugLog(" 战力不足, checkInPlayerID=%s,checkInPlayerFightPower=%s < fightPowerMin=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMin))
|
| | | continue
|
| | | if fightPowerMax and checkInPlayerFightPower > fightPowerMax:
|
| | | GameWorld.DebugLog(" 战力超出, checkInPlayerID=%s,checkInPlayerFightPower=%s > fightPowerMax=%s" % (checkInPlayerID, checkInPlayerFightPower, fightPowerMax))
|
| | | continue
|
| | | passTime = curTime - checkInTime
|
| | | if passTime > checkInValidSeconds:
|
| | | GameWorld.DebugLog(" 登记超时, checkInPlayerID=%s,checkInTime=%s,passTime=%s > checkInValidSeconds=%s" % (checkInPlayerID, checkInTime, passTime, checkInValidSeconds))
|
| | | continue
|
| | | needGoldCall = False
|
| | | todayHelpCount = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0)
|
| | | if dayFreeHelpCount:
|
| | | needGoldCall = todayHelpCount >= dayFreeHelpCount
|
| | | if needGoldCall:
|
| | | GameWorld.DebugLog(" 不是免费, checkInPlayerID=%s,todayHelpCount=%s > dayFreeHelpCount=%s" % (checkInPlayerID, todayHelpCount, dayFreeHelpCount))
|
| | | canHelp, needGoldCall = __CheckCanHelpComm(playerID, helpBattlePlayerDict, checkInPlayerID, helpBattlePlayer, limitLV, fightPowerMin, fightPowerMax, |
| | | checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree)
|
| | | if not canHelp:
|
| | | continue
|
| | |
|
| | | relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
|