7954 【主干】【后端】跨服PVP匹配机器人规则优化(改为由跨服服务器决定是否匹配机器人)
| | |
| | | BYTE _DanLV; //段位等级
|
| | | WORD LVUpScore; //升段位所需积分
|
| | | list MatchRange; //可匹配到的玩家段位区间 [从段位A, 到段位B],配[]代表只匹配本段位的
|
| | | BYTE MatchRobotRate; //匹配机器人基础概率,百分率
|
| | | BYTE MatchRobotRateEx; //匹配机器人失败次数附加概率,百分率
|
| | | };
|
| | |
|
| | | //跨服Boss蓬莱仙境分区地图表
|
| | |
| | | {
|
| | | BYTE _DanLV; //段位等级
|
| | | WORD LVUpScore; //升段位所需积分
|
| | | BYTE MatchRobotRate; //匹配机器人基础概率,百分率
|
| | | BYTE MatchRobotRateEx; //匹配机器人失败次数附加概率,百分率
|
| | | };
|
| | |
|
| | | //跨服竞技场段位奖励表
|
| | |
| | | if msgType == ShareDefine.ClientServerMsg_PKMatch:
|
| | | CrossRealmPK.ClientServerMsg_PKMatch(serverGroupID, msgData, tick)
|
| | |
|
| | | elif msgType == ShareDefine.ClientServerMsg_PKScore:
|
| | | CrossRealmPK.ClientServerMsg_PKScore(serverGroupID, msgData, tick)
|
| | | elif msgType == ShareDefine.ClientServerMsg_PKRobotOver:
|
| | | CrossRealmPK.ClientServerMsg_PKRobotOver(serverGroupID, msgData, tick)
|
| | |
|
| | | elif msgType == ShareDefine.ClientServerMsg_PKCancel:
|
| | | CrossRealmPK.ClientServerMsg_PKCancel(msgData, tick)
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def ClientServerMsg_PKScore(serverGroupID, playerInfoDict, tick):
|
| | | ## 收到子服同步的PK积分信息,子服可能直接更新积分,比如与机器人PK等
|
| | | |
| | | if not GameWorld.IsCrossServer():
|
| | | GameWorld.ErrLog("非跨服服务器不处理跨服PK匹配请求!")
|
| | | return
|
| | | |
| | | seasonID = playerInfoDict["seasonID"] # 赛季ID
|
| | | pkZoneID = playerInfoDict["pkZoneID"] # 所属赛区
|
| | | accID = playerInfoDict["accID"] # 角色账号
|
| | | playerID = playerInfoDict["playerID"] # 角色ID
|
| | | playerName = playerInfoDict["playerName"] # 玩家名
|
| | | job = playerInfoDict["playerJob"] # ְҵ
|
| | | fightPower = playerInfoDict["fightPower"] # 战斗力
|
| | | realmLV = playerInfoDict["realmLV"] # 境界
|
| | | pkScore = playerInfoDict["pkScore"] # 当前积分
|
| | | danLV = playerInfoDict["danLV"] # 当前段位
|
| | | |
| | | pkPlayer = CrossPKPlayer()
|
| | | pkPlayer.accID = accID
|
| | | pkPlayer.playerID = playerID
|
| | | pkPlayer.playerName = playerName
|
| | | pkPlayer.playerJob = job
|
| | | pkPlayer.pkScore = pkScore
|
| | | pkPlayer.danLV = danLV
|
| | | pkPlayer.fightPower = fightPower
|
| | | pkPlayer.realmLV = realmLV
|
| | | pkPlayer.serverGroupID = serverGroupID
|
| | | pkPlayer.pkZoneID = pkZoneID
|
| | | pkPlayer.seasonID = seasonID
|
| | | |
| | | UpdateCrossPKBillboard(pkZoneID, seasonID, pkPlayer, None)
|
| | | return
|
| | |
|
| | | #// C0 01 查看跨服竞技场赛季排行榜 #tagCGViewCrossPKBillboard
|
| | | #
|
| | | #struct tagCGViewCrossPKBillboard
|
| | |
| | | if not preState and isOpen:
|
| | | PyGameData.g_crossPKPlayerDict = {}
|
| | | PyGameData.g_crossPKZoneMatchPlayerDict = {}
|
| | | PyGameData.g_crossPKZoneMatchRobotPlayerDict = {}
|
| | | PyGameData.g_crossPKRoomDict = {}
|
| | | GameWorld.Log("跨服PK匹配状态开启,重置相关匹配数据!")
|
| | |
|
| | |
| | | pkScore = playerInfoDict["pkScore"] # 当前积分
|
| | | danLV = playerInfoDict["danLV"] # 当前段位
|
| | | cWinCount = playerInfoDict["cWinCount"] # 连胜次数
|
| | | cLoseCount = playerInfoDict["cLoseCount"] # 连败次数
|
| | | ondayScore = playerInfoDict["ondayScore"] # 过天时的积分
|
| | |
|
| | | if playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict:
|
| | | GameWorld.Log("玩家已匹配机器人,无法重复发起匹配! playerID=%s,accID=%s" % (playerID, accID))
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 2], [serverGroupID])
|
| | | return
|
| | | zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
|
| | | if playerID in zoneMatchPlayerList:
|
| | | GameWorld.Log("玩家正在匹配中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
|
| | | GameWorld.Log("玩家正在匹配中,无法重复发起匹配! playerID=%s,accID=%s" % (playerID, accID))
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 1], [serverGroupID])
|
| | | return
|
| | | if playerID in PyGameData.g_crossPKPlayerDict:
|
| | | GameWorld.Log("玩家正在战斗中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
|
| | | GameWorld.Log("玩家正在战斗中,无法重复发起匹配! playerID=%s,accID=%s" % (playerID, accID))
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, -2], [serverGroupID])
|
| | | return
|
| | |
|
| | |
| | | pkPlayer.serverGroupID = serverGroupID
|
| | | pkPlayer.pkZoneID = pkZoneID
|
| | | pkPlayer.seasonID = seasonID
|
| | | |
| | | # 判断是否匹配机器人
|
| | | danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
|
| | | if danIpyData:
|
| | | matchRobotRate = danIpyData.GetMatchRobotRate() + danIpyData.GetMatchRobotRateEx() * cLoseCount
|
| | | if matchRobotRate and GameWorld.CanHappen(matchRobotRate, 100):
|
| | | PyGameData.g_crossPKZoneMatchRobotPlayerDict[playerID] = pkPlayer
|
| | | GameWorld.DebugLog("玩家加入匹配: seasonID=%s,pkZoneID=%s,serverGroupID=%s,accID=%s,playerID=%s,pkScore=%s,fightPower=%s,cWinCount=%s" |
| | | % (seasonID, pkZoneID, serverGroupID, accID, playerID, pkScore, fightPower, cWinCount))
|
| | | GameWorld.DebugLog(" 本次匹配到机器人: danLV=%s,cLoseCount=%s,概率=%s" % (danLV, cLoseCount, matchRobotRate), playerID)
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 2], [serverGroupID])
|
| | | return
|
| | | |
| | | PyGameData.g_crossPKPlayerDict[playerID] = pkPlayer
|
| | |
|
| | | # 加入赛区匹配列表
|
| | |
| | | DR_CrossReamlPK("PKOverRoom", dataDict)
|
| | | return
|
| | |
|
| | | def UpdatePKPlayerScore(roomID, pkPlayer, isWin):
|
| | | ## 更新PK玩家积分
|
| | | |
| | | playerID = pkPlayer.playerID
|
| | | cWinCount = pkPlayer.cWinCount
|
| | | pkScore = pkPlayer.pkScore
|
| | | danLV = pkPlayer.danLV
|
| | | dayScore = max(0, pkScore - pkPlayer.ondayScore)# 今日已获得积分,正积分
|
| | | |
| | | GameWorld.DebugLog("roomID=%s,playerID=%s,isWin=%s,dayScore=%s,pkScore=%s,danLV=%s,cWinCount=%s" |
| | | % (roomID, playerID, isWin, dayScore, pkScore, danLV, cWinCount))
|
| | | |
| | | pkDanIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
|
| | | if not pkDanIpyData:
|
| | | GameWorld.ErrLog("跨服PK房间段位数据异常! roomID=%s,playerID=%s,danLV=%s" % (roomID, playerID, danLV))
|
| | | |
| | | baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKScore", 2) # 胜负保底分
|
| | | wBaseScore = baseScoreList[0] if len(baseScoreList) > 0 else 0
|
| | | lBaseScore = baseScoreList[1] if len(baseScoreList) > 1 else 0
|
| | | wExScore = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKScore", 3)) # 胜方附加分
|
| | | lExScore = 0
|
| | | |
| | | if isWin:
|
| | | addScore = wBaseScore + wExScore
|
| | | pkPlayer.cWinCount += 1
|
| | | else:
|
| | | addScore = lBaseScore + lExScore
|
| | | pkPlayer.cWinCount = 0
|
| | | |
| | | dayMaxScore = IpyGameDataPY.GetFuncCfg("CrossRealmPKScore", 1) # 每日获得积分上限,0为不限制
|
| | | if dayMaxScore and addScore:
|
| | | addScore = min(dayMaxScore - dayScore, addScore)
|
| | | pkPlayer.pkScore += addScore
|
| | | |
| | | if pkDanIpyData and pkDanIpyData.GetLVUpScore() and pkPlayer.pkScore >= pkDanIpyData.GetLVUpScore():
|
| | | pkPlayer.danLV += 1
|
| | | |
| | | return addScore
|
| | |
|
| | | def ClientServerMsg_PKRobotOver(serverGroupID, playerInfoDict, tick):
|
| | | ## 收到子服同步的PK机器人结算
|
| | | |
| | | if not GameWorld.IsCrossServer():
|
| | | GameWorld.ErrLog("非跨服服务器不处理跨服PK匹配请求!")
|
| | | return
|
| | | |
| | | playerID = playerInfoDict["playerID"] # 角色ID
|
| | | isWinner = playerInfoDict["isWinner"] # 是否获胜
|
| | | |
| | | if playerID not in PyGameData.g_crossPKZoneMatchRobotPlayerDict:
|
| | | GameWorld.DebugLog("玩家没有匹配到机器人,无法结算PK机器人奖励!", playerID)
|
| | | return
|
| | | pkPlayer = PyGameData.g_crossPKZoneMatchRobotPlayerDict.pop(playerID)
|
| | | zoneID = pkPlayer.pkZoneID
|
| | | seasonID = pkPlayer.seasonID
|
| | | |
| | | GameWorld.Log("机器人跨服PK结算: isWinner=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s" |
| | | % (isWinner, zoneID, seasonID, pkPlayer.pkScore, pkPlayer.danLV, pkPlayer.cWinCount), playerID)
|
| | | |
| | | roomID = 0
|
| | | addScore = UpdatePKPlayerScore(roomID, pkPlayer, isWinner)
|
| | | pkScore = pkPlayer.pkScore
|
| | | danLV = pkPlayer.danLV
|
| | | cWinCount = pkPlayer.cWinCount
|
| | | |
| | | GameWorld.Log(" 更新: addScore=%s,pkScore=%s,danLV=%s,cWinCount=%s" % (addScore,pkScore, danLV, cWinCount), playerID)
|
| | | |
| | | if isWinner:
|
| | | winner, loser = pkPlayer, None
|
| | | else:
|
| | | winner, loser = None, pkPlayer
|
| | | |
| | | # 更新排行榜
|
| | | UpdateCrossPKBillboard(zoneID, seasonID, winner, loser)
|
| | | |
| | | # PK机器人默认结果数据
|
| | | overType = 0
|
| | | roundWinnerIDList = []
|
| | | notifyState = False
|
| | | if winner:
|
| | | winnerID = winner.playerID
|
| | | tagPlayerID = 0
|
| | | tagPlayerName = ""
|
| | | |
| | | timeStr = GameWorld.GetCurrentDataTimeStr()
|
| | | playerOverDict = {}
|
| | | playerOverDict[playerID] = [roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList] \
|
| | | + [serverGroupID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState]
|
| | | |
| | | serverGroupIDList = [pkPlayer.serverGroupID]
|
| | | GameWorld.DebugLog("同步子服战斗结果: seasonID=%s,timeStr=%s,roomID=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s" |
| | | % (seasonID, timeStr, roomID, overType, winnerID, roundWinnerIDList))
|
| | | # 同步子服
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKOverInfo, playerOverDict, serverGroupIDList)
|
| | | |
| | | # 记录流向
|
| | | dataDict = {"zoneID":zoneID, "seasonID":seasonID, "pkPlayer":pkPlayer.GetDRInfo()}
|
| | | DR_CrossReamlPK("PKOverRobot", dataDict)
|
| | | return
|
| | |
|
| | | ##================================== 以下是子服逻辑 ==========================================
|
| | |
|
| | | def OnGameServerInitOK():
|
| | |
| | | if not curPlayer:
|
| | | return
|
| | |
|
| | | if not result:
|
| | | return
|
| | | |
| | | if result == -2:
|
| | | PlayerControl.NotifyCode(curPlayer, "CrossMatching17")
|
| | | return
|
| | |
|
| | | startMatchPack = ChPyNetSendPack.tagGCCrossRealmPKStartMatch()
|
| | | |
| | | if result == 1:
|
| | | SetIsCrossPKMatching(curPlayer, 1)
|
| | | NetPackCommon.SendFakePack(curPlayer, ChPyNetSendPack.tagGCCrossRealmPKStartMatch())
|
| | | startMatchPack.IsRobot = 0
|
| | | elif result == 2:
|
| | | startMatchPack.IsRobot = 1
|
| | |
|
| | | NetPackCommon.SendFakePack(curPlayer, startMatchPack) |
| | | return
|
| | |
|
| | | ## 跨服匹配状态
|
| | |
| | | ("BYTE", "DanLV", 1),
|
| | | ("WORD", "LVUpScore", 0),
|
| | | ("list", "MatchRange", 0),
|
| | | ("BYTE", "MatchRobotRate", 0),
|
| | | ("BYTE", "MatchRobotRateEx", 0),
|
| | | ),
|
| | |
|
| | | "CrossPenglaiZoneMap":(
|
| | |
| | | def __init__(self): |
| | | self.DanLV = 0
|
| | | self.LVUpScore = 0
|
| | | self.MatchRange = [] |
| | | self.MatchRange = []
|
| | | self.MatchRobotRate = 0
|
| | | self.MatchRobotRateEx = 0 |
| | | return |
| | | |
| | | def GetDanLV(self): return self.DanLV # 段位等级
|
| | | def GetLVUpScore(self): return self.LVUpScore # 升段位所需积分
|
| | | def GetMatchRange(self): return self.MatchRange # 可匹配到的玩家段位区间 [从段位A, 到段位B],配[]代表只匹配本段位的 |
| | | def GetMatchRange(self): return self.MatchRange # 可匹配到的玩家段位区间 [从段位A, 到段位B],配[]代表只匹配本段位的
|
| | | def GetMatchRobotRate(self): return self.MatchRobotRate # 匹配机器人基础概率,百分率
|
| | | def GetMatchRobotRateEx(self): return self.MatchRobotRateEx # 匹配机器人失败次数附加概率,百分率 |
| | | |
| | | # 跨服Boss蓬莱仙境分区地图表 |
| | | class IPY_CrossPenglaiZoneMap(): |
| | |
| | |
|
| | | g_crossPKPlayerDict = {} # 跨服PK玩家字典 {playerID:PKPlayer, ...}
|
| | | g_crossPKZoneMatchPlayerDict = {} # 跨服PK匹配中的玩家字典 {zoneID:[playerID, ...], ...}
|
| | | g_crossPKZoneMatchRobotPlayerDict = {} # 跨服PK匹配机器人的玩家字典 {playerID:PKPlayer, ...}
|
| | | g_crossPKRoomDict = {} # 跨服PK房间字典 {roomID:PKRoom, ...}
|
| | | g_crossPKRoomID = 0 # 跨服PK当前已经创建到的房间ID,自增创建
|
| | |
|
| | |
| | | ClientServerMsg_GMCMD = "GMCMD" # GM命令
|
| | | ClientServerMsg_ViewPlayerCache = "ViewPlayerCache" # 查看跨服玩家信息
|
| | | ClientServerMsg_PKMatch = "PKMatch" # 跨服PK匹配
|
| | | ClientServerMsg_PKScore = "PKScore" # 跨服PK同步积分到跨服服务器(某些情况会在本服加积分,如与机器人PK)
|
| | | ClientServerMsg_PKRobotOver = "PKRobotOver" # 跨服PK机器人结算
|
| | | ClientServerMsg_PKCancel = "PKCancel" # 跨服PK取消匹配
|
| | | ClientServerMsg_PKPrepareOK = "PKPrepareOK" # 跨服PK准备完毕
|
| | | ClientServerMsg_PKBillboard = "PKBillboard" # 跨服PK排行榜
|
| | |
| | | Def_PDict_CrossPK_WinCount = "CrossPK_WinCount" # 当前胜利次数
|
| | | Def_PDict_CrossPK_CWinCount = "CrossPK_CWinCount" # 当前连胜次数
|
| | | Def_PDict_CrossPK_CLoseCount = "CrossPK_CLoseCount" # 当前连败次数
|
| | | Def_PDict_CrossPK_IsMatchRobot = "CrossPK_IsMatchRobot" # 本次是否匹配机器人,1-是,0-否
|
| | | Def_PDict_CrossPK_TodayPKCount = "CrossPK_TodayPKCount" # 今日已PK次数
|
| | | Def_PDict_CrossPK_TodayWinCount = "CrossPK_TodayWinCount" # 今日已胜利次数
|
| | | Def_PDict_CrossPK_TodayBuyCount = "CrossPK_TodayBuyCount" # 今日已购买PK次数
|
| | |
| | | "CrossRealmPKDan":(
|
| | | ("BYTE", "DanLV", 1),
|
| | | ("WORD", "LVUpScore", 0),
|
| | | ("BYTE", "MatchRobotRate", 0),
|
| | | ("BYTE", "MatchRobotRateEx", 0),
|
| | | ),
|
| | |
|
| | | "CrossRealmPKDanAward":(
|
| | |
| | | |
| | | def __init__(self): |
| | | self.DanLV = 0
|
| | | self.LVUpScore = 0
|
| | | self.MatchRobotRate = 0
|
| | | self.MatchRobotRateEx = 0 |
| | | self.LVUpScore = 0 |
| | | return |
| | | |
| | | def GetDanLV(self): return self.DanLV # 段位等级
|
| | | def GetLVUpScore(self): return self.LVUpScore # 升段位所需积分
|
| | | def GetMatchRobotRate(self): return self.MatchRobotRate # 匹配机器人基础概率,百分率
|
| | | def GetMatchRobotRateEx(self): return self.MatchRobotRateEx # 匹配机器人失败次数附加概率,百分率 |
| | | def GetLVUpScore(self): return self.LVUpScore # 升段位所需积分 |
| | | |
| | | # 跨服竞技场段位奖励表 |
| | | class IPY_CrossRealmPKDanAward(): |
| | |
| | | if not CheckHavePKCount(curPlayer):
|
| | | return
|
| | |
|
| | | danLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)
|
| | | danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
|
| | | if not danIpyData:
|
| | | return
|
| | | cLoseCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount)
|
| | | matchRobotRate = danIpyData.GetMatchRobotRate() + danIpyData.GetMatchRobotRateEx() * cLoseCount
|
| | | isMatchRobot = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_IsMatchRobot)
|
| | | GameWorld.Log("isMatchRobot=%s,danLV=%s,cLoseCount=%s,匹配机器人概率=%s" % (isMatchRobot, danLV, cLoseCount, matchRobotRate), playerID)
|
| | | if isMatchRobot or (matchRobotRate and GameWorld.CanHappen(matchRobotRate, 100)):
|
| | | GameWorld.Log(" 本次匹配到机器人!", playerID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_IsMatchRobot, 1)
|
| | | startMatchPack = ChPyNetSendPack.tagGCCrossRealmPKStartMatch()
|
| | | startMatchPack.IsRobot = 1
|
| | | NetPackCommon.SendFakePack(curPlayer, startMatchPack)
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_IsMatchRobot, 0)
|
| | | |
| | | dataMsg = {
|
| | | "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # 赛季ID
|
| | | "pkZoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PK赛区
|
| | |
| | | "pkScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore), # 当前积分
|
| | | "danLV":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV), # 当前段位
|
| | | "cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount), # 连胜次数
|
| | | "cLoseCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount), # 连败次数
|
| | | "ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore), # 过天时的积分
|
| | | }
|
| | | GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKMatch, dataMsg)
|
| | |
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_IsMatchRobot, 0)
|
| | |
|
| | | pkCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_PKCount) + 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, pkCount)
|
| | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | isWinner = clientData.IsWin
|
| | |
|
| | | if GameWorld.IsCrossServer():
|
| | | GameWorld.DebugLog("跨服服务器无法发起机器人结算!", playerID)
|
| | | return
|
| | | |
| | | if not CheckHavePKCount(curPlayer):
|
| | | return
|
| | |
|
| | | isMatchRobot = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_IsMatchRobot)
|
| | | if not isMatchRobot:
|
| | | GameWorld.DebugLog("当前不允许结算跨服匹配机器人!IsMatchRobot=%s" % isMatchRobot, playerID)
|
| | | return
|
| | | |
| | | zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
|
| | | seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
|
| | | pkScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)
|
| | | danLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)
|
| | | cWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount)
|
| | | |
| | | if GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState) != 1:
|
| | | GameWorld.Log("OnCrossRealmPKRobotOver 跨服赛季未开启,不可进行机器人结算!", playerID)
|
| | | overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
|
| | | overPack.AddScore = 0
|
| | | overPack.Score = pkScore
|
| | | overPack.DanLV = danLV
|
| | | overPack.CWinCnt = cWinCount
|
| | | NetPackCommon.SendFakePack(curPlayer, overPack)
|
| | | return
|
| | | |
| | | ondayScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore)
|
| | | dayScore = max(0, pkScore - ondayScore) # 今日已获得积分,正积分
|
| | | |
| | | baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKScore", 2) # 胜负保底分
|
| | | wBaseScore = baseScoreList[0] if len(baseScoreList) > 0 else 0
|
| | | lBaseScore = baseScoreList[1] if len(baseScoreList) > 1 else 0
|
| | | wExScore = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKScore", 3)) # 胜方附加分
|
| | | lExScore = 0
|
| | | |
| | | if isWinner:
|
| | | addScore = wBaseScore + wExScore
|
| | | cWinCount += 1
|
| | | else:
|
| | | addScore = lBaseScore + lExScore
|
| | | cWinCount = 0
|
| | | |
| | | dayMaxScore = IpyGameDataPY.GetFuncCfg("CrossRealmPKScore", 1) # 每日获得积分上限,0为不限制
|
| | | if dayMaxScore and addScore:
|
| | | addScore = min(dayMaxScore - dayScore, addScore)
|
| | | |
| | | GameWorld.Log("机器人跨服PK结算: isWinner=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s" |
| | | % (isWinner, zoneID, seasonID, pkScore, danLV, cWinCount, addScore), playerID)
|
| | | |
| | | pkScore += addScore
|
| | | winIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
|
| | | if winIpyData and winIpyData.GetLVUpScore() and pkScore >= winIpyData.GetLVUpScore():
|
| | | danLV += 1
|
| | | |
| | | isToday = True # 机器人结算的默认当天
|
| | | if not __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):
|
| | | return
|
| | | |
| | | # 只同步以下信息,其他信息前端自行补全
|
| | | overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
|
| | | overPack.AddScore = addScore
|
| | | overPack.Score = pkScore
|
| | | overPack.DanLV = danLV
|
| | | overPack.CWinCnt = cWinCount
|
| | | NetPackCommon.SendFakePack(curPlayer, overPack)
|
| | | |
| | | # 如果能上榜的,则通知跨服更新榜单积分数据
|
| | | billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])
|
| | | if billboardCfg and len(billboardCfg) > 1 or danLV >= billboardCfg[1]:
|
| | | dataMsg = {
|
| | | "seasonID":seasonID,
|
| | | "pkZoneID":zoneID,
|
| | | "accID":curPlayer.GetAccID(),
|
| | | "playerID":playerID,
|
| | | "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
|
| | | "playerJob":curPlayer.GetJob(),
|
| | | "fightPower":curPlayer.GetFightPower(),
|
| | | "realmLV":curPlayer.GetOfficialRank(),
|
| | | "pkScore":pkScore,
|
| | | "danLV":danLV,
|
| | | }
|
| | | GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKScore, dataMsg)
|
| | | GameWorld.Log(" 更新积分到跨服服务器 dataMsg=%s" % str(dataMsg), playerID)
|
| | | |
| | | dataMsg = {
|
| | | "playerID":playerID,
|
| | | "isWinner":isWinner,
|
| | | }
|
| | | GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKRobotOver, dataMsg)
|
| | | GameWorld.Log("同步跨服服务器与机器人PK结算: %s" % str(dataMsg), playerID)
|
| | | return
|
| | |
|
| | |
|
| | |
| | | ClientServerMsg_GMCMD = "GMCMD" # GM命令
|
| | | ClientServerMsg_ViewPlayerCache = "ViewPlayerCache" # 查看跨服玩家信息
|
| | | ClientServerMsg_PKMatch = "PKMatch" # 跨服PK匹配
|
| | | ClientServerMsg_PKScore = "PKScore" # 跨服PK同步积分到跨服服务器(某些情况会在本服加积分,如与机器人PK)
|
| | | ClientServerMsg_PKRobotOver = "PKRobotOver" # 跨服PK机器人结算
|
| | | ClientServerMsg_PKCancel = "PKCancel" # 跨服PK取消匹配
|
| | | ClientServerMsg_PKPrepareOK = "PKPrepareOK" # 跨服PK准备完毕
|
| | | ClientServerMsg_PKBillboard = "PKBillboard" # 跨服PK排行榜
|