From d0f353b00a2a805b3327e9fd7f49d55dcc0ec39a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 11 七月 2019 13:44:55 +0800
Subject: [PATCH] 7954 【主干】【后端】跨服PVP匹配机器人规则优化(改为由跨服服务器决定是否匹配机器人)

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py                   |    4 
 ServerPython/CoreServerGroup/GameServer/Script/IpyGameDataPY.py                                  |   10 +
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py                    |  167 +++++++++++++++++++++------
 ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py                                     |    1 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py               |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py             |   10 -
 PySysDB/PySysDBPY.h                                                                              |    2 
 ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py                                    |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py |  108 +----------------
 PySysDB/PySysDBG.h                                                                               |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py                  |    1 
 11 files changed, 158 insertions(+), 151 deletions(-)

diff --git a/PySysDB/PySysDBG.h b/PySysDB/PySysDBG.h
index 1971470..a28162f 100644
--- a/PySysDB/PySysDBG.h
+++ b/PySysDB/PySysDBG.h
@@ -517,6 +517,8 @@
 	BYTE		_DanLV;	//段位等级
 	WORD		LVUpScore;	//升段位所需积分
 	list		MatchRange;	//可匹配到的玩家段位区间 [从段位A, 到段位B],配[]代表只匹配本段位的
+	BYTE		MatchRobotRate;	//匹配机器人基础概率,百分率
+	BYTE		MatchRobotRateEx;	//匹配机器人失败次数附加概率,百分率
 };
 
 //跨服Boss蓬莱仙境分区地图表
diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index a3b1bfa..fbfc1bb 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -1503,8 +1503,6 @@
 {
 	BYTE		_DanLV;	//段位等级
 	WORD		LVUpScore;	//升段位所需积分
-	BYTE		MatchRobotRate;	//匹配机器人基础概率,百分率
-	BYTE		MatchRobotRateEx;	//匹配机器人失败次数附加概率,百分率
 };
 
 //跨服竞技场段位奖励表
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
index ad2bbf7..d660881 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
@@ -68,8 +68,8 @@
         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)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
index 39ea210..2afb3cb 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -317,40 +317,6 @@
             
     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
@@ -704,6 +670,7 @@
     if not preState and isOpen:
         PyGameData.g_crossPKPlayerDict = {}
         PyGameData.g_crossPKZoneMatchPlayerDict = {}
+        PyGameData.g_crossPKZoneMatchRobotPlayerDict = {}
         PyGameData.g_crossPKRoomDict = {}
         GameWorld.Log("跨服PK匹配状态开启,重置相关匹配数据!")
         
@@ -922,15 +889,20 @@
     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
     
@@ -952,6 +924,19 @@
     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
     
     # 加入赛区匹配列表
@@ -1642,6 +1627,106 @@
     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():
@@ -1756,14 +1841,22 @@
     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
 
 ## 跨服匹配状态
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/IpyGameDataPY.py b/ServerPython/CoreServerGroup/GameServer/Script/IpyGameDataPY.py
index 91b57c2..6a43b21 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/IpyGameDataPY.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/IpyGameDataPY.py
@@ -432,6 +432,8 @@
                         ("BYTE", "DanLV", 1),
                         ("WORD", "LVUpScore", 0),
                         ("list", "MatchRange", 0),
+                        ("BYTE", "MatchRobotRate", 0),
+                        ("BYTE", "MatchRobotRateEx", 0),
                         ),
 
                 "CrossPenglaiZoneMap":(
@@ -1370,12 +1372,16 @@
     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():
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py b/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
index 1c3fbd9..3debd06 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
@@ -91,6 +91,7 @@
 
 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,自增创建
 
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
index bb724e6..7649a86 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
@@ -1207,7 +1207,7 @@
 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排行榜
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 1506607..20c640a 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3816,7 +3816,6 @@
 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次数
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index 2db25a8..7461689 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -1180,8 +1180,6 @@
                 "CrossRealmPKDan":(
                         ("BYTE", "DanLV", 1),
                         ("WORD", "LVUpScore", 0),
-                        ("BYTE", "MatchRobotRate", 0),
-                        ("BYTE", "MatchRobotRateEx", 0),
                         ),
 
                 "CrossRealmPKDanAward":(
@@ -3894,15 +3892,11 @@
     
     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():
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
index 85b32c2..36e621f 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
@@ -242,23 +242,6 @@
         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赛区
@@ -274,6 +257,7 @@
                    "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)
@@ -351,7 +335,6 @@
     
     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)
@@ -398,88 +381,19 @@
     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
 
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
index bb724e6..7649a86 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
@@ -1207,7 +1207,7 @@
 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排行榜

--
Gitblit v1.8.0