From 78a2ce57d2d546ebade26a801b33c5cb0d8a408c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 21 十月 2019 14:09:33 +0800
Subject: [PATCH] 8309 【恺英】邮件神装物品传奇属性异常
---
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py | 916 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 725 insertions(+), 191 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
index 24fca7d..57fd24b 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -18,6 +18,7 @@
import GameWorld
import PlayerControl
import CrossRealmMsg
+import DataRecordPack
import ChPyNetSendPack
import CrossRealmPlayer
import PyGameDataStruct
@@ -45,17 +46,26 @@
self.playerJob = 0
self.playerLV = 0
self.maxHP = 0
+ self.maxProDef = 0
self.fightPower = 0
self.realmLV = 0
self.pkScore = 0
self.danLV = 0
self.matchTick = 0
+ self.prepareOKTick = 0
self.cWinCount = 0 # 连胜次数
self.ondayScore = 0 # 过天时的积分
self.serverGroupID = 0 # 所属服务器ID,一个服务器ID由多个服组成
self.pkZoneID = 0 # 所属赛区ID,一个赛区由多个服务器ID组成
self.seasonID = 0 # 赛季ID
+ self.notifyMatchRobotTick = 0 # 通知匹配到机器人的tick
return
+
+ def GetDRInfo(self):
+ ## 流向记录信息
+ return {"accID":self.accID, "playerID":self.playerID, "fightPower":self.fightPower, "pkScore":self.pkScore,
+ "danLV":self.danLV, "matchTick":self.matchTick, "prepareOKTick":self.prepareOKTick, "cWinCount":self.cWinCount,
+ "ondayScore":self.ondayScore, "serverGroupID":self.serverGroupID, "ondayScore":self.ondayScore}
class CrossPKRoom():
## 跨服PK房间类
@@ -70,9 +80,13 @@
self.roomState = ShareDefine.Def_VsRoom_State_WaitPlayer # 默认状态
self.roomPlayerIDList = [] # 对战玩家ID列表
self.readyPlayerIDList = [] # 已经准备好的玩家ID列表
- self.isMapOpen = False # 地图是否已经开启该房间,未开启的房间超时后,本次匹配视为无效,有玩家进地图才会开启副本分线
+ self.mapFBOpenTick = 0 # 地图开启该房间tick,未开启的房间超时后,本次匹配视为无效,有玩家进地图才会开启副本分线
return
+ def GetDRInfo(self):
+ return {"zoneID":self.pkZoneID, "seasonID":self.seasonID, "roomID":self.roomID, "mapID":self.mapID, "openTick":self.openTick,
+ "readyTick":self.readyTick, "roomPlayerIDList":self.roomPlayerIDList, "mapFBOpenTick":self.mapFBOpenTick}
+
#跨服PK排行榜管理,注意该类只处理数据逻辑,功能相关逻辑不要写在该类,不然重读脚本不会生效
class CrossPKBillboardManager(object):
@@ -228,14 +242,16 @@
return
maxCount = min(2000, maxCount)
upBillboardList = []
- if winner.danLV >= danLVLimit:
- upBillboardList.append(winner)
- else:
- GameWorld.DebugLog(" 段位不足,无法上榜! winnerDanLV=%s < danLVLimit=%s" % (winner.danLV, danLVLimit), winner.playerID)
- if loser.danLV >= danLVLimit:
- upBillboardList.append(loser)
- else:
- GameWorld.DebugLog(" 段位不足,无法上榜! loserDanLV=%s < danLVLimit=%s" % (loser.danLV, danLVLimit), loser.playerID)
+ if winner:
+ if winner.danLV >= danLVLimit:
+ upBillboardList.append(winner)
+ else:
+ GameWorld.DebugLog(" 段位不足,无法上榜! winnerDanLV=%s < danLVLimit=%s" % (winner.danLV, danLVLimit), winner.playerID)
+ if loser:
+ if loser.danLV >= danLVLimit:
+ upBillboardList.append(loser)
+ else:
+ GameWorld.DebugLog(" 段位不足,无法上榜! loserDanLV=%s < danLVLimit=%s" % (loser.danLV, danLVLimit), loser.playerID)
if not upBillboardList:
return
@@ -284,7 +300,7 @@
billboardData.PKScore = pkPlayer.pkScore
billboardData.DanLV = pkPlayer.danLV
billboardData.Time = billboardTime
- GameWorld.Log(" 更新PK积分排行榜: playerID=%s,pkScore=%s,order=%s" % (playerID, billboardData.PKScore, order), playerID)
+ GameWorld.DebugLog(" 更新PK积分排行榜: playerID=%s,pkScore=%s,order=%s" % (playerID, billboardData.PKScore, order), playerID)
# 战斗结算更新榜单先不排序,只设置需要排序
if isUpd:
@@ -294,7 +310,8 @@
matchState = GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
if not matchState and not PyGameData.g_crossPKRoomDict:
GameWorld.Log("匹配已结束,且当前没有PK中的房间了!主动广播子服最新榜单! ")
- zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKZone", zoneID)
+ crossZoneName = GameWorld.GetCrossZoneName()
+ zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID)
if zoneIpyData:
serverGroupIDList = zoneIpyData.GetServerGroupIDList()
SyncPKSyncBillboardToClientServer(zoneID, seasonID, serverGroupIDList)
@@ -353,7 +370,8 @@
serverTime = GameWorld.GetServerTime()
curSeasonID = 0
seasonState = 0
- seasonList = IpyGameDataPY.GetIpyGameDataList("CrossRealmPKSeason", zoneID)
+ crossZoneName = GameWorld.GetCrossZoneName()
+ seasonList = IpyGameDataPY.GetIpyGameDataList("CrossRealmPKSeason", crossZoneName, zoneID)
seasonList = [] if not seasonList else seasonList
for seasonIpyData in seasonList:
startDateStr = seasonIpyData.GetStartDate()
@@ -460,8 +478,8 @@
def CrossServerMsg_PKSyncBillboard(syncInfo):
## 收到跨服服务器同步的排行榜信息
zoneID, seasonID, syncBillboardList, exData, isFinalBillboardData = syncInfo
- GameWorld.Log("收到跨服服务器同步的排行榜信息: zoneID=%s,seasonID=%s,billboardDataCount=%s,exData=%s,isFinalBillboardData=%s"
- % (zoneID, seasonID, len(syncBillboardList), exData, isFinalBillboardData))
+ GameWorld.DebugLog("收到跨服服务器同步的排行榜信息: zoneID=%s,seasonID=%s,billboardDataCount=%s,exData=%s,isFinalBillboardData=%s"
+ % (zoneID, seasonID, len(syncBillboardList), exData, isFinalBillboardData))
crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
billboardList, orderDict = crossPKBillboardMgr.UpdClientServerPKBillboard(zoneID, seasonID, syncBillboardList, isFinalBillboardData)
@@ -522,18 +540,19 @@
zoneSeasonTimeDict = {}
serverTime = GameWorld.GetServerTime()
- ipyDataMgr = IpyGameDataPY.IPY_Data()
- for index in xrange(ipyDataMgr.GetCrossRealmPKZoneCount()):
- zoneIpyData = ipyDataMgr.GetCrossRealmPKZoneByIndex(index)
+ crossZoneName = GameWorld.GetCrossZoneName()
+ crossZoneList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZonePK", {"CrossZoneName":crossZoneName}, True)
+ if not crossZoneList:
+ return zoneSeasonTimeDict
+
+ for zoneIpyData in crossZoneList:
zoneID = zoneIpyData.GetZoneID()
# 规定每个赛区的赛季时间需按顺序配置
- seasonIpyDataList = []
- for sIndex in xrange(ipyDataMgr.GetCrossRealmPKSeasonCount()):
- seasonIpyData = ipyDataMgr.GetCrossRealmPKSeasonByIndex(sIndex)
- if zoneID == seasonIpyData.GetZoneID():
- seasonIpyDataList.append(seasonIpyData)
-
+ seasonIpyDataList = IpyGameDataPY.GetIpyGameDataList("CrossRealmPKSeason", crossZoneName, zoneID)
+ if not seasonIpyDataList:
+ continue
+
for i, seasonIpyData in enumerate(seasonIpyDataList):
seasonID = seasonIpyData.GetSeasonID()
startDateStr = seasonIpyData.GetStartDate()
@@ -591,8 +610,9 @@
gameWorld = GameWorld.GetGameWorld()
serverTime = GameWorld.GetServerTime()
+ crossZoneName = GameWorld.GetCrossZoneName()
for zoneID, seasonTimeInfo in zoneSeasonTimeDict.items():
- zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKZone", zoneID)
+ zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID)
if not zoneIpyData:
continue
@@ -644,11 +664,23 @@
return
gameWorld = GameWorld.GetGameWorld()
+ preState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK, isOpen)
+
+ # 匹配状态从关闭到开启
+ if not preState and isOpen:
+ PyGameData.g_crossPKPlayerDict = {}
+ PyGameData.g_crossPKZoneMatchPlayerDict = {}
+ PyGameData.g_crossPKZoneMatchRobotPlayerDict = {}
+ PyGameData.g_crossPKRoomDict = {}
+ GameWorld.Log("跨服PK匹配状态开启,重置相关匹配数据!")
+
+ crossZoneName = GameWorld.GetCrossZoneName()
+ crossZoneList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZonePK", {"CrossZoneName":crossZoneName}, True)
+ if not crossZoneList:
+ return
- ipyDataMgr = IpyGameDataPY.IPY_Data()
- for index in xrange(ipyDataMgr.GetCrossRealmPKZoneCount()):
- zoneIpyData = ipyDataMgr.GetCrossRealmPKZoneByIndex(index)
+ for zoneIpyData in crossZoneList:
zoneID = zoneIpyData.GetZoneID()
# 广播当前赛区的所有子服跨服PK赛季状态变更
@@ -661,82 +693,132 @@
return
-def ClientServerMsg_ServerInitOK(serverGroupID, tick):
- ## 子服启动成功
- GameWorld.Log("子服启动成功,同步给子服对应的赛季信息: serverGroupID=%s" % (serverGroupID))
- zoneID = GetCrossPKServerGroupZoneID(serverGroupID)
- if not zoneID:
- GameWorld.Log(" 该子服没有分配赛区,不同步!")
+def Sync_CrossPKInitDataToClientServer(tick, serverGroupID=0):
+ ''' 同步跨服PK活动数据到子服务器
+ @param serverGroupID: 为0时同步所有子服
+ '''
+
+ GameWorld.Log("同步给子服对应的赛季信息: syncServerGroupID=%s" % (serverGroupID))
+ if serverGroupID:
+ ipyData = GetCrossPKServerGroupZone(serverGroupID)
+ if not ipyData:
+ return
+ crossZoneList = [ipyData]
+ else:
+ crossZoneName = GameWorld.GetCrossZoneName()
+ crossZoneList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZonePK", {"CrossZoneName":crossZoneName}, True)
+ if not crossZoneList:
return
gameWorld = GameWorld.GetGameWorld()
- seasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % zoneID)
- seasonState = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonState % zoneID)
- matchState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
- seasonInfo = {"ZoneID":zoneID, "SeasonID":seasonID, "SeasonState":seasonState, "MatchState":matchState}
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKSeasonInfo, seasonInfo, [serverGroupID])
+ for zoneIpyData in crossZoneList:
+ zoneID = zoneIpyData.GetZoneID()
+ seasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % zoneID)
+ seasonState = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonState % zoneID)
+ matchState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
+ seasonInfo = {"ZoneID":zoneID, "SeasonID":seasonID, "SeasonState":seasonState, "MatchState":matchState}
+ serverGroupIDList = [serverGroupID] if serverGroupID else zoneIpyData.GetServerGroupIDList()
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKSeasonInfo, seasonInfo, serverGroupIDList)
+
return
-def GetCrossPKServerGroupZoneID(serverGroupID):
+def GetCrossPKServerGroupZone(serverGroupID):
## 获取服务器组ID对应的跨服PK所属赛区,返回0代表该服务器没有分配赛区
- ipyDataMgr = IpyGameDataPY.IPY_Data()
- for index in xrange(ipyDataMgr.GetCrossRealmPKZoneCount()):
- zoneIpyData = ipyDataMgr.GetCrossRealmPKZoneByIndex(index)
+ crossZoneName = GameWorld.GetCrossZoneName()
+ crossZoneList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZonePK", {"CrossZoneName":crossZoneName}, True)
+ if not crossZoneList:
+ return
+
+ for zoneIpyData in crossZoneList:
for groupInfo in zoneIpyData.GetServerGroupIDList():
if (isinstance(groupInfo, int) and serverGroupID == groupInfo) \
or (isinstance(groupInfo, tuple) and len(groupInfo) == 2 and groupInfo[0] <= serverGroupID <= groupInfo[1]):
- return zoneIpyData.GetZoneID()
- return 0
+ return zoneIpyData
+ return
-def OnPlayerLogin(curPlayer):
-
- # 本服登录处理
- if not GameWorld.IsCrossServer():
- # 本服没有分配赛区不处理
- if not GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID):
- return
- __OnLoginNotifyPKOverInfo(curPlayer)
-
- # 同步所有赛区赛季信息
- zoneSeasonInfo = ChPyNetSendPack.tagGCCrossRealmPKSeasonInfo()
- zoneSeasonInfo.ZoneList = []
- ipyDataMgr = IpyGameDataPY.IPY_Data()
- for index in xrange(ipyDataMgr.GetCrossRealmPKZoneCount()):
- zoneIpyData = ipyDataMgr.GetCrossRealmPKZoneByIndex(index)
- zoneID = zoneIpyData.GetZoneID()
- zoneInfo = ChPyNetSendPack.tagGCCrossRealmPKZone()
- zoneInfo.ZoneID = zoneID
- zoneInfo.ZoneName = zoneIpyData.GetZoneName().decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
- zoneInfo.ZoneNameLen = len(zoneInfo.ZoneName)
- zoneInfo.SeasonList = []
- seasonList = IpyGameDataPY.GetIpyGameDataList("CrossRealmPKSeason", zoneID)
- seasonList = [] if not seasonList else seasonList
- for seasonIpyData in seasonList:
- seasonInfo = ChPyNetSendPack.tagGCCrossRealmPKSeason()
- seasonInfo.SeasonID = seasonIpyData.GetSeasonID()
- seasonInfo.StartDate = seasonIpyData.GetStartDate()
- seasonInfo.EndDate = seasonIpyData.GetEndDate()
- seasonInfo.EndTime = seasonIpyData.GetEndTime()
- zoneInfo.SeasonList.append(seasonInfo)
- zoneInfo.SeasonCount = len(zoneInfo.SeasonList)
- zoneSeasonInfo.ZoneList.append(zoneInfo)
- zoneSeasonInfo.ZoneCount = len(zoneSeasonInfo.ZoneList)
- NetPackCommon.SendFakePack(curPlayer, zoneSeasonInfo)
-
- # 同步本服赛季状态
- gameWorld = GameWorld.GetGameWorld()
- seasonStatePack = ChPyNetSendPack.tagGCCrossRealmPKSeasonState()
- seasonStatePack.ZoneID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
- seasonStatePack.SeasonID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
- seasonStatePack.SeasonState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
- seasonStatePack.MatchState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
- NetPackCommon.SendFakePack(curPlayer, seasonStatePack)
-
+def OnPlayerLoginCrossServer(curPlayer):
# 跨服登录处理
- else:
- # 比如验证房间ID是否合法
- pass
+
+ mapID = curPlayer.GetMapID()
+ mapIDList = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 4)
+ if mapID not in mapIDList:
+ return
+
+ GameWorld.Log("玩家登录跨服PK地图, mapID=%s" % mapID, curPlayer.GetPlayerID())
+ if not __CheckCanLoginCrossServerPKMap(curPlayer):
+ CrossRealmPlayer.PlayerExitCrossServer(curPlayer)
+ return
return
+
+def OnPlayerLogin(curPlayer):
+ # 本服登录处理
+
+ # 本服没有分配赛区不处理
+ if not GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID):
+ return
+ __OnLoginNotifyPKOverInfo(curPlayer)
+
+ crossZoneName = GameWorld.GetCrossZoneName()
+ crossZoneList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZonePK", {"CrossZoneName":crossZoneName}, True)
+ if not crossZoneList:
+ return
+ # 同步所有赛区赛季信息
+ zoneSeasonInfo = ChPyNetSendPack.tagGCCrossRealmPKSeasonInfo()
+ zoneSeasonInfo.ZoneList = []
+ for zoneIpyData in crossZoneList:
+ zoneID = zoneIpyData.GetZoneID()
+ zoneInfo = ChPyNetSendPack.tagGCCrossRealmPKZone()
+ zoneInfo.ZoneID = zoneID
+ zoneInfo.ZoneName = zoneIpyData.GetZoneName().decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
+ zoneInfo.ZoneNameLen = len(zoneInfo.ZoneName)
+ zoneInfo.SeasonList = []
+ seasonList = IpyGameDataPY.GetIpyGameDataList("CrossRealmPKSeason", crossZoneName, zoneID)
+ seasonList = [] if not seasonList else seasonList
+ for seasonIpyData in seasonList:
+ seasonInfo = ChPyNetSendPack.tagGCCrossRealmPKSeason()
+ seasonInfo.SeasonID = seasonIpyData.GetSeasonID()
+ seasonInfo.StartDate = seasonIpyData.GetStartDate()
+ seasonInfo.EndDate = seasonIpyData.GetEndDate()
+ seasonInfo.EndTime = seasonIpyData.GetEndTime()
+ zoneInfo.SeasonList.append(seasonInfo)
+ zoneInfo.SeasonCount = len(zoneInfo.SeasonList)
+ zoneSeasonInfo.ZoneList.append(zoneInfo)
+ zoneSeasonInfo.ZoneCount = len(zoneSeasonInfo.ZoneList)
+ NetPackCommon.SendFakePack(curPlayer, zoneSeasonInfo)
+
+ # 同步本服赛季状态
+ gameWorld = GameWorld.GetGameWorld()
+ seasonStatePack = ChPyNetSendPack.tagGCCrossRealmPKSeasonState()
+ seasonStatePack.ZoneID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ seasonStatePack.SeasonID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ seasonStatePack.SeasonState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
+ seasonStatePack.MatchState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
+ seasonStatePack.CrossZoneName = GameWorld.GetCrossZoneName()
+ seasonStatePack.CrossZoneNameLen = len(seasonStatePack.CrossZoneName)
+ NetPackCommon.SendFakePack(curPlayer, seasonStatePack)
+
+ return
+
+def __CheckCanLoginCrossServerPKMap(curPlayer):
+ # 检查玩家可否登录跨服PK房间
+
+ playerID = curPlayer.GetPlayerID()
+ vsRoomID = curPlayer.GetVsRoomId()
+ if not vsRoomID:
+ GameWorld.ErrLog("玩家没有对战房间ID,不可进入对战地图! 强制踢出跨服服务器!", playerID)
+ return False
+
+ if vsRoomID not in PyGameData.g_crossPKRoomDict:
+ GameWorld.ErrLog("玩家对战房间ID已经不存在,不可进入对战地图! 强制踢出跨服服务器!vsRoomID=%s" % vsRoomID, playerID)
+ return False
+
+ vsRoom = PyGameData.g_crossPKRoomDict[vsRoomID]
+ if playerID not in vsRoom.roomPlayerIDList:
+ GameWorld.ErrLog("玩家对战房间ID不存在该玩家ID,不可进入对战地图! 强制踢出跨服服务器!vsRoomID=%s,roomPlayerIDList=%s"
+ % (vsRoomID, vsRoom.roomPlayerIDList), playerID)
+ return False
+
+ return True
## 玩家离线处理
def OnLeaveServer(curPlayer):
@@ -767,7 +849,7 @@
# return
vsRoomID = curPlayer.GetVsRoomId()
- if vsRoomID and PlayerControl.GetCrossRealmState(curPlayer) == 1:
+ if vsRoomID and PlayerControl.GetCrossMapID(curPlayer) == ChConfig.Def_FBMapID_CrossRealmPK:
GameWorld.DebugLog("玩家跨服PK状态,不能取消匹配!vsRoomID=%s" % vsRoomID, curPlayer.GetPlayerID())
return
@@ -779,7 +861,8 @@
}
CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKCancel, dataMsg)
PlayerControl.SetVsRoomId(curPlayer, 0)
- GameWorld.Log("发送取消跨服PK匹配到跨服服务器:dataMsg=%s" % str(dataMsg), curPlayer.GetPlayerID())
+ SetIsCrossPKMatching(curPlayer, 0)
+ GameWorld.DebugLog("发送取消跨服PK匹配到跨服服务器:dataMsg=%s" % str(dataMsg), curPlayer.GetPlayerID())
return
def ClientServerMsg_PKMatch(serverGroupID, playerInfoDict, tick):
@@ -801,22 +884,28 @@
job = playerInfoDict["playerJob"] # 职业
playerLV = playerInfoDict["playerLV"] # 职业
maxHP = playerInfoDict["maxHP"] # 职业
+ maxProDef = playerInfoDict["maxProDef"] # 护盾
fightPower = playerInfoDict["fightPower"] # 战斗力
realmLV = playerInfoDict["realmLV"] # 境界
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))
-# CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 1], [serverGroupID])
-# return
-# if playerID in PyGameData.g_crossPKPlayerDict:
-# GameWorld.Log("玩家正在战斗中,无法重复发起匹配!playerID=%s,accID=%s" % (playerID, accID))
-# CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, -2], [serverGroupID])
-# return
+ if playerID in zoneMatchPlayerList:
+ 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))
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, -2], [serverGroupID])
+ return
pkPlayer = CrossPKPlayer()
pkPlayer.accID = accID
@@ -825,6 +914,7 @@
pkPlayer.playerJob = job
pkPlayer.playerLV = playerLV
pkPlayer.maxHP = maxHP
+ pkPlayer.maxProDef = maxProDef
pkPlayer.pkScore = pkScore
pkPlayer.danLV = danLV
pkPlayer.fightPower = fightPower
@@ -835,16 +925,76 @@
pkPlayer.serverGroupID = serverGroupID
pkPlayer.pkZoneID = pkZoneID
pkPlayer.seasonID = seasonID
+
+ # 判断是否匹配机器人
+ matchRobotRate = 0
+ danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
+ if danIpyData:
+ matchRobotRate = danIpyData.GetMatchRobotRate() + danIpyData.GetMatchRobotRateEx() * cLoseCount
+ if matchRobotRate and GameWorld.CanHappen(matchRobotRate, 100):
+ pkPlayer.notifyMatchRobotTick = tick + random.randint(3, 5) * 1000
+ 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, 1], [serverGroupID])
+ return
+
PyGameData.g_crossPKPlayerDict[playerID] = pkPlayer
# 加入赛区匹配列表
zoneMatchPlayerList.append(playerID)
PyGameData.g_crossPKZoneMatchPlayerDict[pkZoneID] = zoneMatchPlayerList
- GameWorld.Log("玩家加入匹配: seasonID=%s,pkZoneID=%s,serverGroupID=%s,accID=%s,playerID=%s,pkScore=%s,fightPower=%s,cWinCount=%s,len(zoneMatchPlayerList)=%s"
- % (seasonID, pkZoneID, serverGroupID, accID, playerID, pkScore, fightPower, cWinCount, len(zoneMatchPlayerList)))
+ GameWorld.DebugLog("玩家加入匹配: seasonID=%s,pkZoneID=%s,serverGroupID=%s,accID=%s,playerID=%s,pkScore=%s,fightPower=%s,cWinCount=%s,cLoseCount=%s,概率=%s,len(zoneMatchPlayerList)=%s"
+ % (seasonID, pkZoneID, serverGroupID, accID, playerID, pkScore, fightPower, cWinCount, cLoseCount, matchRobotRate, len(zoneMatchPlayerList)))
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 1], [serverGroupID])
+ return
+
+def __DelayNotifyMatchRobot(tick):
+ ## 做体验,延迟通知匹配到机器人
+ for playerID, pkPlayer in PyGameData.g_crossPKZoneMatchRobotPlayerDict.items():
+ if pkPlayer.notifyMatchRobotTick == -1:
+ #GameWorld.DebugLog("已通知过玩家匹配到机器人", playerID)
+ continue
+ if tick < pkPlayer.notifyMatchRobotTick:
+ continue
+ pkPlayer.notifyMatchRobotTick = -1
+ serverGroupID = pkPlayer.serverGroupID
+ GameWorld.DebugLog("延迟通知玩家匹配到机器人: serverGroupID=%s" % (serverGroupID), playerID)
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 2], [serverGroupID])
+
+ return
+
+def __DoTimeOutPlayerMatchRobot(matchTickSortList, matchPlayerIDList, tick):
+ ## 超时很久很久的玩家系统匹配机器人
+ if not matchPlayerIDList:
+ return
+
+ matchRobotTimeoutInfo = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKRobot", 1)
+ if len(matchRobotTimeoutInfo) != 2:
+ return
+ matchRobotTick = random.randint(matchRobotTimeoutInfo[0], matchRobotTimeoutInfo[1]) * 1000 # 超时匹配机器人时间tick
+
+ for i, matchPlayer in enumerate(matchTickSortList):
+
+ playerID = matchPlayer.playerID
+ if playerID not in matchPlayerIDList:
+ continue
+
+ if tick - matchPlayer.matchTick < matchRobotTick:
+ #GameWorld.DebugLog(" i=%s,玩家未满足超时匹配机器人时间条件!" % (i))
+ break
+
+ matchPlayerIDList.remove(playerID) # 这个列表为分区对应匹配中的玩家列表 PyGameData.g_crossPKZoneMatchPlayerDict[pkZoneID]
+
+ PyGameData.g_crossPKZoneMatchRobotPlayerDict[playerID] = matchPlayer
+ matchPlayer.notifyMatchRobotTick = -1
+ serverGroupID = matchPlayer.serverGroupID
+ GameWorld.DebugLog("直接通知超时玩家匹配到机器人: serverGroupID=%s" % (serverGroupID), playerID)
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 2], [serverGroupID])
return
def ClientServerMsg_PKCancel(playerInfoDict, tick):
@@ -864,22 +1014,22 @@
vsRoomID = playerInfoDict["vsRoomID"] # 所属对战房间ID
if vsRoomID in PyGameData.g_crossPKRoomDict:
pkRoom = PyGameData.g_crossPKRoomDict[vsRoomID]
- if pkRoom.isMapOpen or pkRoom.readyTick:
+ if pkRoom.mapFBOpenTick or pkRoom.readyTick:
GameWorld.Log("跨服对战房间已经开启了线路,或者双方数据都已传输完毕,不可再取消匹配!vsRoomID=%s" % vsRoomID)
return
- GameWorld.Log("玩家取消匹配: reason=%s,accID=%s,playerID=%s,vsRoomID=%s" % (reason, accID, playerID, vsRoomID))
+ GameWorld.DebugLog("玩家取消匹配: reason=%s,accID=%s,playerID=%s,vsRoomID=%s" % (reason, accID, playerID, vsRoomID))
pkZoneID = 0
if playerID in PyGameData.g_crossPKPlayerDict:
pkPlayer = PyGameData.g_crossPKPlayerDict.pop(playerID)
pkZoneID = pkPlayer.pkZoneID
- GameWorld.Log(" 移除PK玩家: pkZoneID=%s,accID=%s,playerID=%s" % (pkZoneID, accID, playerID))
+ GameWorld.DebugLog(" 移除PK玩家: pkZoneID=%s,accID=%s,playerID=%s" % (pkZoneID, accID, playerID))
zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
if playerID in zoneMatchPlayerList:
zoneMatchPlayerList.remove(playerID)
- GameWorld.Log(" 从匹配队列中删除,匹配队列剩余人数=%s" % (len(zoneMatchPlayerList)))
+ GameWorld.DebugLog(" 从匹配队列中删除,匹配队列剩余人数=%s" % (len(zoneMatchPlayerList)))
#取消所有存在该玩家的房间,子服不一定知道玩家当前最新所属房间ID, 故只能通过遍历删除已经为玩家创建的房间
for roomID, pkRoom in PyGameData.g_crossPKRoomDict.items():
@@ -888,17 +1038,22 @@
for roomPlayerID in pkRoom.roomPlayerIDList:
if roomPlayerID == playerID:
- GameWorld.Log(" 自己不处理: roomID=%s,playerID=%s" % (roomID, playerID))
+ GameWorld.DebugLog(" 自己不处理: roomID=%s,playerID=%s" % (roomID, playerID))
continue
zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
zoneMatchPlayerList.append(roomPlayerID)
PyGameData.g_crossPKZoneMatchPlayerDict[pkZoneID] = zoneMatchPlayerList
- GameWorld.Log(" 将之前匹配的对手重新加入匹配队列: roomID=%s,roomPlayerID=%s,当前匹配人数=%s"
- % (roomID, roomPlayerID, len(zoneMatchPlayerList)))
+ GameWorld.DebugLog(" 将之前匹配的对手重新加入匹配队列: roomID=%s,roomPlayerID=%s,当前匹配人数=%s"
+ % (roomID, roomPlayerID, len(zoneMatchPlayerList)))
PyGameData.g_crossPKRoomDict.pop(roomID)
- GameWorld.Log(" 移除房间: popRoomID=%s" % (roomID))
+ GameWorld.DebugLog(" 移除房间: popRoomID=%s" % (roomID))
+
+ # 记录流向
+ dataDict = {"cancelPlayerID":playerID}
+ dataDict.update(pkRoom.GetDRInfo())
+ DR_CrossReamlPK("CancelRoom", dataDict)
break
return
@@ -916,8 +1071,9 @@
if playerID not in PyGameData.g_crossPKPlayerDict:
GameWorld.ErrLog("玩家跨服对战数据准备OK, 但找不到该对战玩家信息!vsRoomID=%s,playerID=%s" % (vsRoomID, playerID))
return
- #pkPlayer = PyGameData.g_crossPKPlayerDict[playerID]
-
+ pkPlayer = PyGameData.g_crossPKPlayerDict[playerID]
+ pkPlayer.prepareOKTick = tick
+
if vsRoomID not in PyGameData.g_crossPKRoomDict:
GameWorld.ErrLog("玩家跨服对战数据准备OK, 但找不到该对战房间(%s)!可能对手已取消!" % vsRoomID)
return
@@ -930,7 +1086,7 @@
if playerID not in vsRoom.readyPlayerIDList:
vsRoom.readyPlayerIDList.append(playerID)
- GameWorld.Log("玩家跨服PK准备完毕: accID=%s,playerID=%s,vsRoomID=%s" % (accID, playerID, vsRoomID))
+ GameWorld.DebugLog("玩家跨服PK准备完毕: accID=%s,playerID=%s,vsRoomID=%s" % (accID, playerID, vsRoomID))
return
def __ReadyOKRoomPlayerProcess(tick):
@@ -952,31 +1108,73 @@
isAllReady = True
roomGroupIDList = []
readyMemberDict = {} # 已准备好的玩家信息
- for roomPlayerID in vsRoom.roomPlayerIDList:
+ for num, roomPlayerID in enumerate(vsRoom.roomPlayerIDList, 1):
if roomPlayerID not in vsRoom.readyPlayerIDList or roomPlayerID not in PyGameData.g_crossPKPlayerDict:
isAllReady = False
break
roomPlayer = PyGameData.g_crossPKPlayerDict[roomPlayerID]
pkZoneID = roomPlayer.pkZoneID
roomGroupIDList.append(roomPlayer.serverGroupID)
- readyMemberDict[roomPlayerID] = {"ServerGroupID":roomPlayer.serverGroupID, "Name":roomPlayer.playerName,
- "Job":roomPlayer.playerJob, "LV":roomPlayer.playerLV, "MaxHP":roomPlayer.maxHP}
+ readyMemberDict[roomPlayerID] = {"ServerGroupID":roomPlayer.serverGroupID, "Name":roomPlayer.playerName, "Number":num,
+ "Job":roomPlayer.playerJob, "LV":roomPlayer.playerLV, "MaxHP":roomPlayer.maxHP, "MaxProDef":roomPlayer.maxProDef}
if not isAllReady:
continue
vsRoom.roomState = ShareDefine.Def_VsRoom_State_PrepareFight
vsRoom.readyTick = tick
- GameWorld.Log(" 准备好的房间: pkZoneID=%s,roomID=%s,mapID=%s,readyMemberDict=%s" % (pkZoneID, roomID, vsRoom.mapID, str(readyMemberDict)))
+ GameWorld.DebugLog(" 准备好的房间: pkZoneID=%s,roomID=%s,mapID=%s,readyMemberDict=%s" % (pkZoneID, roomID, vsRoom.mapID, str(readyMemberDict)))
sendReadyOKRoomList.append([roomID, readyMemberDict])
serverGroupIDList += roomGroupIDList
# 将已准备好的房间广播到子服
if sendReadyOKRoomList:
- GameWorld.Log(" 已准备好的对战房间数: %s" % len(sendReadyOKRoomList))
+ GameWorld.DebugLog(" 已准备好的对战房间数: %s" % len(sendReadyOKRoomList))
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKReadyOKRoomList, sendReadyOKRoomList, serverGroupIDList)
return
+#
+#def TestAddMatch(tick, addCount, maxDanLV=None, isClear=False):
+# if isClear:
+# PyGameData.g_crossPKPlayerDict = {}
+# PyGameData.g_crossPKZoneMatchPlayerDict = {}
+# PyGameData.g_crossPKRoomDict = {}
+# PyGameData.g_crossPKRoomID = 0
+#
+# ipyDataMgr = IpyGameDataPY.IPY_Data()
+# if maxDanLV == None:
+# maxDanLV = ipyDataMgr.GetCrossRealmPKDanCount() - 1
+# crossZoneName = GameWorld.GetCrossZoneName()
+# crossZoneList = IpyGameDataPY.GetIpyGameDataByCondition("CrossZonePK", {"CrossZoneName":crossZoneName}, True)
+# if not crossZoneList:
+# return
+# for zoneIpyData in crossZoneList:
+# pkZoneID = zoneIpyData.GetZoneID()
+#
+# addPlayerList = []
+# zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
+# maxPlayerID = pkZoneID * 1000 if not zoneMatchPlayerList else max(zoneMatchPlayerList)
+# for i in xrange(1, addCount + 1):
+# playerID = maxPlayerID + i
+#
+# pkPlayer = CrossPKPlayer()
+# pkPlayer.playerID = playerID
+# danLV = random.randint(0, maxDanLV)
+# pkPlayer.danLV = danLV
+# pkPlayer.matchTick = tick
+# pkPlayer.pkScore = danLV * 1000 + random.randint(0, 999)
+# pkPlayer.pkZoneID = pkZoneID
+# pkPlayer.seasonID = 1
+#
+# PyGameData.g_crossPKPlayerDict[playerID] = pkPlayer
+# addPlayerList.append([playerID, danLV])
+# # 加入赛区匹配列表
+# zoneMatchPlayerList.append(playerID)
+# PyGameData.g_crossPKZoneMatchPlayerDict[pkZoneID] = zoneMatchPlayerList
+# GameWorld.Log("Add zoneID=%s,addPlayerList=%s" % (pkZoneID, addPlayerList))
+#
+# #GameWorld.Log("PyGameData.g_crossPKPlayerDict=%s" % PyGameData.g_crossPKPlayerDict)
+# return
def OnPKMatchProcess(tick):
## 玩家跨服PK匹配定时处理逻辑
@@ -999,6 +1197,8 @@
return
GameWorld.GetGameWorld().SetDict(processTickKey, tick)
+ # 延迟通知匹配到机器人的
+ __DelayNotifyMatchRobot(tick)
# 处理超时的房间
__DoCheckRoomTimeout(tick)
# 通知已准备好的房间玩家可进入跨服
@@ -1009,12 +1209,15 @@
# 每个赛区单独匹配
for pkZoneID, matchPlayerIDList in PyGameData.g_crossPKZoneMatchPlayerDict.items():
- matchPlayerCount = len(matchPlayerIDList)
- if matchPlayerCount < 2:
- #GameWorld.Log("匹配PK人数不足,不处理!pkZoneID=%s, 总人数:%s" % (pkZoneID, matchPlayerCount))
+ if not matchPlayerIDList:
+ #GameWorld.Log("没有玩家匹配PK,不处理!pkZoneID=%s" % (pkZoneID))
continue
+ matchPlayerCount = len(matchPlayerIDList)
+# if matchPlayerCount < 2:
+# #GameWorld.Log("匹配PK人数不足,不处理!pkZoneID=%s, 总人数:%s" % (pkZoneID, matchPlayerCount))
+# continue
- GameWorld.Log("★★★★★★★★★★开始跨服PK匹配(pkZoneID=%s, 总人数:%s)★★★★★★★★★★" % (pkZoneID, matchPlayerCount))
+ GameWorld.DebugLog("★★★★★★★★★★开始跨服PK匹配(pkZoneID=%s, 总人数:%s)★★★★★★★★★★" % (pkZoneID, matchPlayerCount))
matchPlayerList = []
for matchPlayerID in matchPlayerIDList:
@@ -1037,7 +1240,11 @@
# 给成功匹配的玩家非配对战房间
matchPlayerVSList = matchPlayerVSList[:maxGroupCnt]
__DoSetVSRoom(pkZoneID, matchPlayerVSList, tick)
- GameWorld.Log("==========匹配结束(总匹配队伍:%s)==========" % len(matchPlayerVSList))
+ GameWorld.DebugLog("==========匹配结束(总匹配队伍:%s)==========" % len(matchPlayerVSList))
+ #GameWorld.DebugLog("crossPlayerIDList=%s" % PyGameData.g_crossPKPlayerDict.keys())
+ #GameWorld.DebugLog("matchPlayerIDList=%s" % PyGameData.g_crossPKZoneMatchPlayerDict[pkZoneID])
+
+ __DoTimeOutPlayerMatchRobot(matchTickSortList, matchPlayerIDList, tick)
return
@@ -1045,34 +1252,34 @@
'''匹配超时玩家
匹配中的玩家按积分排序,最后一个默认匹配上一个,第一个默认匹配下一个,其他匹配前后积分差绝对值较小的一个
'''
- GameWorld.Log(" ==优先匹配超时等待玩家==最大等待时间:%s, tick=%s" % (outTimeTick, tick))
- GameWorld.Log(" scoreSortListLen=%s" % len(scoreSortList))
+ GameWorld.DebugLog(" ==优先匹配超时等待玩家==最大等待时间:%s, tick=%s" % (outTimeTick, tick))
+ GameWorld.DebugLog(" scoreSortListLen=%s" % len(scoreSortList))
for i, matchPlayer in enumerate(matchTickSortList):
# 只有一个玩家
if len(scoreSortList) <= 1:
- GameWorld.Log(" 当前玩家数%s<=1,不再匹配!" % len(scoreSortList))
+ #GameWorld.DebugLog(" 当前玩家数%s<=1,不再匹配!" % len(scoreSortList))
break
if tick - matchPlayer.matchTick < outTimeTick:
- GameWorld.Log(" i=%s,玩家未超时,不再匹配!" % (i))
+ #GameWorld.DebugLog(" i=%s,玩家未超时,不再匹配!" % (i))
break
- GameWorld.Log(" i=%s,超时玩家, %s-%s=%s >= outTimeTick(%s)"
- % (i, tick, matchPlayer.matchTick, tick - matchPlayer.matchTick, outTimeTick))
+ GameWorld.DebugLog(" i=%s,超时玩家, %s-%s=%s >= outTimeTick(%s)"
+ % (i, tick, matchPlayer.matchTick, tick - matchPlayer.matchTick, outTimeTick))
# 已经被匹配走了
if matchPlayer not in scoreSortList:
- GameWorld.Log(" 已经被匹配走了!")
+ GameWorld.DebugLog(" 已经被匹配走了!")
continue
outTimeIndex = scoreSortList.index(matchPlayer)
# 最后一个默认匹配上一个
if outTimeIndex == len(scoreSortList) - 1:
vsIndex = outTimeIndex - 1
- GameWorld.Log(" 超时玩家积分排序索引%s,最后一个,默认匹配上一个索引%s!" % (outTimeIndex, vsIndex))
+ GameWorld.DebugLog(" 超时玩家积分排序索引%s,最后一个,默认匹配上一个索引%s!" % (outTimeIndex, vsIndex))
# 第一个默认匹配下一个
elif outTimeIndex == 0:
vsIndex = outTimeIndex + 1
- GameWorld.Log(" 超时玩家积分排序索引%s,第一个,默认匹配下一个索引%s!" % (outTimeIndex, vsIndex))
+ GameWorld.DebugLog(" 超时玩家积分排序索引%s,第一个,默认匹配下一个索引%s!" % (outTimeIndex, vsIndex))
# 其他情况匹配积分较近的一个
else:
preIndex = outTimeIndex - 1
@@ -1082,9 +1289,9 @@
preDiff = abs(prePlayer.pkScore - matchPlayer.pkScore)
nextDiff = abs(matchPlayer.pkScore - nextPlayer.pkScore)
vsIndex = preIndex if preDiff <= nextDiff else nextIndex
- GameWorld.Log(" 超时玩家积分排序索引-积分(%s-%s),上一个(%s-%s),下一个(%s-%s),preDiff=%s,nextDiff=%s,vsIndex=%s"
- % (outTimeIndex, matchPlayer.pkScore, preIndex, prePlayer.pkScore,
- nextIndex, nextPlayer.pkScore, preDiff, nextDiff, vsIndex))
+ GameWorld.DebugLog(" 超时玩家积分排序索引-积分(%s-%s),上一个(%s-%s),下一个(%s-%s),preDiff=%s,nextDiff=%s,vsIndex=%s"
+ % (outTimeIndex, matchPlayer.pkScore, preIndex, prePlayer.pkScore,
+ nextIndex, nextPlayer.pkScore, preDiff, nextDiff, vsIndex))
if outTimeIndex > vsIndex:
scoreSortList.pop(outTimeIndex)
@@ -1104,7 +1311,7 @@
''' 匹配积分分段玩家
匹配中的玩家按段位积分归组,归组后,随机段位顺序,每个段位组中的玩家随机两两PK
'''
- GameWorld.Log(" ==匹配积分分段玩家== maxGroupCnt=%s,scoreSortListLen=%s" % (maxGroupCnt, len(scoreSortList)))
+ GameWorld.DebugLog(" ==匹配积分分段玩家== maxGroupCnt=%s,scoreSortListLen=%s" % (maxGroupCnt, len(scoreSortList)))
danPlayerListDict = {} # 按积分分段列表分散玩家
for matchPlayer in scoreSortList:
danLV = matchPlayer.danLV
@@ -1116,24 +1323,27 @@
danList = danPlayerListDict.keys()
random.shuffle(danList) # 打乱段位顺序
- GameWorld.Log(" 积分分段个数: %s, %s" % (len(danList), danList))
+ GameWorld.DebugLog(" 积分分段个数: %s, %s" % (len(danList), danList))
- # 日志输出分组明细
- for danLV in danList:
- strList = []
- for player in danPlayerListDict[danLV]:
- strList.append((player.playerID, player.pkScore, player.fightPower))
- GameWorld.Log(" 积分段组, danLV=%s, %s" % (danLV, str(strList)))
-
+ # 优先匹配相同段位
doCount = 0
while len(matchPlayerVSList) < maxGroupCnt and doCount < maxGroupCnt:
doCount += 1
isMatchOK = False
+# # 日志输出分组明细
+# GameWorld.DebugLog(" -------------")
+# for danLV in danList:
+# strList = []
+# for player in danPlayerListDict[danLV]:
+# strList.append((player.playerID, player.pkScore, player.fightPower))
+# GameWorld.DebugLog(" 积分段组, danLV=%s, %s" % (danLV, str(strList)))
+# # -------------------------------
+
for danLV in danList:
danPlayerList = danPlayerListDict[danLV]
danPlayerCount = len(danPlayerList)
if danPlayerCount < 2:
- GameWorld.Log(" 段位人数少于2个,此段位本轮轮空!doCount=%s,danLV=%s" % (doCount, danLV))
+ #GameWorld.DebugLog(" 段位人数少于2个,不处理!doCount=%s,danLV=%s" % (doCount, danLV))
continue
vsIndexList = random.sample(xrange(danPlayerCount), 2) # 随机取两个索引对战
@@ -1143,15 +1353,75 @@
matchPlayerVSList.append([aPlayer, bPlayer])
isMatchOK = True
- GameWorld.Log(" 成功匹配玩家: aPlayerID=%s,aScore=%s,aFP=%s VS bPlayerID=%s,bScore=%s,bFP=%s"
- % (aPlayer.playerID, aPlayer.pkScore, aPlayer.fightPower, bPlayer.playerID, bPlayer.pkScore, bPlayer.fightPower))
+ GameWorld.DebugLog(" 成功匹配相同段位玩家: aPlayerID=%s,aDanLV=%s VS bPlayerID=%s,bDanLV=%s" % (aPlayer.playerID, aPlayer.danLV, bPlayer.playerID, bPlayer.danLV))
if len(matchPlayerVSList) >= maxGroupCnt:
- GameWorld.Log(" 已经达到最大匹配数! 已匹配对战数=%s, 不再匹配!doCount=%s" % (len(matchPlayerVSList), doCount))
+ GameWorld.DebugLog(" 已经达到最大匹配数! 已匹配对战数=%s, 不再匹配!doCount=%s" % (len(matchPlayerVSList), doCount))
break
if not isMatchOK:
- GameWorld.Log(" 已经没有满足匹配条件的玩家! 不再匹配!doCount=%s" % (doCount))
+ GameWorld.DebugLog(" 已经没有满足匹配条件的玩家! 不再匹配!doCount=%s" % (doCount))
+ break
+
+ # 不足再匹配范围段位
+ doCount = 0
+ while len(matchPlayerVSList) < maxGroupCnt and doCount < maxGroupCnt:
+ doCount += 1
+ isMatchOK = False
+# # 日志输出分组明细
+# GameWorld.DebugLog(" -------------")
+# for danLV in danList:
+# strList = []
+# for player in danPlayerListDict[danLV]:
+# strList.append((player.playerID, player.pkScore, player.fightPower))
+# GameWorld.DebugLog(" 积分段组, danLV=%s, %s" % (danLV, str(strList)))
+# # -------------------------------
+
+ for danLV in danList:
+ danMatchRange = []
+ danMatchPlayerList = []
+ danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
+ matchDanRange = [] if not danIpyData else danIpyData.GetMatchRange()
+ if matchDanRange and len(matchDanRange) == 2:
+ danMatchRange = range(matchDanRange[0], matchDanRange[1] + 1)
+
+ if danLV not in danMatchRange:
+ danMatchRange.append(danLV)
+
+ for matchDanLV in danMatchRange:
+ if matchDanLV not in danPlayerListDict:
+ continue
+ danMatchPlayerList += danPlayerListDict[matchDanLV]
+
+ #matchPlayerIDList = [matchPlayer.playerID for matchPlayer in danMatchPlayerList]
+ #GameWorld.DebugLog("danLV=%s,danMatchRange=%s,matchPlayerIDList=%s" % (danLV, danMatchRange, matchPlayerIDList))
+ matchPlayerCount = len(danMatchPlayerList)
+ if matchPlayerCount < 2:
+ #GameWorld.DebugLog(" 段位范围人数少于2个,不处理!doCount=%s,danLV=%s,danMatchRange=%s" % (doCount, danLV, danMatchRange))
+ continue
+
+ vsIndexList = random.sample(xrange(matchPlayerCount), 2) # 随机取两个索引对战
+ aPlayer, bPlayer = danMatchPlayerList[vsIndexList[0]], danMatchPlayerList[vsIndexList[1]]
+
+ aDanPlayerList = danPlayerListDict.get(aPlayer.danLV, [])
+ bDanPlayerList = danPlayerListDict.get(bPlayer.danLV, [])
+ if aPlayer in aDanPlayerList and bPlayer in bDanPlayerList:
+ aDanPlayerList.remove(aPlayer)
+ bDanPlayerList.remove(bPlayer)
+ else:
+ continue
+
+ matchPlayerVSList.append([aPlayer, bPlayer])
+ isMatchOK = True
+ GameWorld.DebugLog(" 成功匹配范围段位玩家: aPlayerID=%s,aDanLV=%s VS bPlayerID=%s,bDanLV=%s | danLV=%s,danMatchRange=%s"
+ % (aPlayer.playerID, aPlayer.danLV, bPlayer.playerID, bPlayer.danLV, danLV, danMatchRange))
+
+ if len(matchPlayerVSList) >= maxGroupCnt:
+ GameWorld.DebugLog(" 已经达到最大匹配数! 已匹配对战数=%s, 不再匹配!doCount=%s" % (len(matchPlayerVSList), doCount))
+ break
+
+ if not isMatchOK:
+ GameWorld.DebugLog(" 已经没有满足匹配条件的玩家! 不再匹配! doCount=%s" % (doCount))
break
return
@@ -1167,7 +1437,7 @@
zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
mapIDList = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 4)
- GameWorld.Log("===给配对的玩家开房间(pkZoneID=%s,配对数:%s)===" % (pkZoneID, len(matchPlayerVSList)))
+ GameWorld.DebugLog("===给配对的玩家开房间(pkZoneID=%s,配对数:%s)===" % (pkZoneID, len(matchPlayerVSList)))
for aPlayer, bPlayer in matchPlayerVSList:
if not aPlayer or not bPlayer:
@@ -1195,8 +1465,13 @@
PyGameData.g_crossPKRoomDict[roomID] = newRoom
aServerGroupID, bServerGroupID = aPlayer.serverGroupID, bPlayer.serverGroupID
- GameWorld.Log(" 开房:pkZoneID=%s,mapID=%s,roomID=%s,aPlayerID=%s,bPlayerID=%s" % (pkZoneID, mapID, roomID, aPlayerID, bPlayerID))
+ GameWorld.DebugLog(" 开房:pkZoneID=%s,mapID=%s,roomID=%s,aPlayerID=%s,bPlayerID=%s" % (pkZoneID, mapID, roomID, aPlayerID, bPlayerID))
vsRoomDict[roomID] = [mapID, [[aServerGroupID, aPlayerID], [bServerGroupID, bPlayerID]]]
+
+ # 记录流向
+ dataDict = {"aPlayer":aPlayer.GetDRInfo(), "bPlayer":bPlayer.GetDRInfo()}
+ dataDict.update(newRoom.GetDRInfo())
+ DR_CrossReamlPK("OpenRoom", dataDict)
serverGroupIDList.append(aServerGroupID)
serverGroupIDList.append(bServerGroupID)
@@ -1232,7 +1507,7 @@
serverGroupIDList = []
roomTimeout = IpyGameDataPY.GetFuncCfg("CrossRealmPKCfg", 2) * 1000 # 这个时间尽量长点,目前暂时不确定玩家从准备到进入到地图的时长
for roomID, pkRoom in PyGameData.g_crossPKRoomDict.items():
- if pkRoom.isMapOpen or not pkRoom.readyTick:
+ if pkRoom.mapFBOpenTick or not pkRoom.readyTick:
continue
if tick - pkRoom.readyTick <= roomTimeout:
continue
@@ -1251,25 +1526,28 @@
timeoutRoomDict[roomID] = roomPlayerInfo
PyGameData.g_crossPKRoomDict.pop(roomID)
+ # 记录流向
+ DR_CrossReamlPK("TimeoutRoom", pkRoom.GetDRInfo())
+
# 将超时房间广播到子服
if timeoutRoomDict:
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKTimeoutRoomList, timeoutRoomDict, serverGroupIDList)
return
-def MapServer_CrossPKRoomOpen(msgList):
+def MapServer_CrossPKRoomOpen(msgList, tick):
roomID = msgList[0]
if roomID not in PyGameData.g_crossPKRoomDict:
GameWorld.ErrLog("MapServer_CrossPKRoomOpen => PK房间不存在!roomID=%s" % roomID)
return
pkRoom = PyGameData.g_crossPKRoomDict[roomID]
- pkRoom.isMapOpen = True
+ pkRoom.mapFBOpenTick = tick
GameWorld.Log("MapServer_CrossPKRoomOpen => roomID=%s" % roomID)
return
-def MapServer_MergePKOver(infoList):
+def MapServer_CrossPKOver(infoList, tick):
## 收到MapServer副本跨服PK结果同步
- GameWorld.Log("收到MapServer_跨服PK战斗结果: %s" % str(infoList))
+ GameWorld.DebugLog("收到MapServer_跨服PK战斗结果: %s" % str(infoList))
roomID, winnerID, loserID, roundWinnerIDList, overType = infoList
@@ -1314,8 +1592,8 @@
winnerDanLV, loserDanLV = winner.danLV, loser.danLV
winnerDayScore, loserDayScore = max(0, winnerScore - winner.ondayScore), max(0, loserScore - loser.ondayScore) # 今日已获得积分,正积分
- GameWorld.Log("winnerDayScore=%s,winnerScore=%s,winnerDanLV=%s,cWinCount=%s" % (winnerDayScore, winnerScore, winnerDanLV, cWinCount))
- GameWorld.Log("loserDayScore=%s,loserScore=%s,loserDanLV=%s" % (loserDayScore, loserScore, loserDanLV))
+ GameWorld.DebugLog("winnerDayScore=%s,winnerScore=%s,winnerDanLV=%s,cWinCount=%s" % (winnerDayScore, winnerScore, winnerDanLV, cWinCount))
+ GameWorld.DebugLog("loserDayScore=%s,loserScore=%s,loserDanLV=%s" % (loserDayScore, loserScore, loserDanLV))
winIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", winnerDanLV)
loseIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", loserDanLV)
@@ -1350,8 +1628,8 @@
if loseIpyData and loseIpyData.GetLVUpScore() and loser.pkScore >= loseIpyData.GetLVUpScore():
loser.danLV += 1
- GameWorld.Log("wBaseScore=%s,wExScore=%s,winnerAddScore=%s,updScore=%s,updDanLV=%s,updCWinCount=%s" % (wBaseScore, wExScore, winnerAddScore, winner.pkScore, winner.danLV, winner.cWinCount))
- GameWorld.Log("lBaseScore=%s,lExScore=%s,loserAddScore=%s,updScore=%s,updDanLV=%s,updCWinCount=%s" % (lBaseScore, lExScore, loserAddScore, loser.pkScore, loser.danLV, loser.cWinCount))
+ GameWorld.DebugLog("wBaseScore=%s,wExScore=%s,winnerAddScore=%s,updScore=%s,updDanLV=%s,updCWinCount=%s" % (wBaseScore, wExScore, winnerAddScore, winner.pkScore, winner.danLV, winner.cWinCount))
+ GameWorld.DebugLog("lBaseScore=%s,lExScore=%s,loserAddScore=%s,updScore=%s,updDanLV=%s,updCWinCount=%s" % (lBaseScore, lExScore, loserAddScore, loser.pkScore, loser.danLV, loser.cWinCount))
# 更新排行榜
UpdateCrossPKBillboard(zoneID, seasonID, winner, loser)
@@ -1389,17 +1667,143 @@
overPack.TagNameLen = len(overPack.TagName)
NetPackCommon.SendFakePack(player, overPack)
- GameWorld.Log("同步玩家PK结果: serverGroupID=%s,roomID=%s,addScore=%s,pkScore=%s,danLV=%s,cWinCount=%s,tagPlayerID=%s"
- % (serverGroupID, roomID, addScore, pkScore, danLV, cWinCount, tagPlayerID), playerID)
+ GameWorld.DebugLog("同步玩家PK结果: serverGroupID=%s,roomID=%s,addScore=%s,pkScore=%s,danLV=%s,cWinCount=%s,tagPlayerID=%s"
+ % (serverGroupID, roomID, addScore, pkScore, danLV, cWinCount, tagPlayerID), playerID)
serverGroupIDList = [winner.serverGroupID, loser.serverGroupID]
- GameWorld.Log("同步子服战斗结果: seasonID=%s,timeStr=%s,roomID=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s"
- % (seasonID, timeStr, roomID, overType, winnerID, roundWinnerIDList))
+ 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 = {"roundWinnerIDList":roundWinnerIDList, "overType":overType, "winner":winner.GetDRInfo(), "loser":loser.GetDRInfo()}
+ dataDict.update(vsRoom.GetDRInfo())
+ 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)
+ if playerID in PyGameData.g_crossPKPlayerDict:
+ PyGameData.g_crossPKPlayerDict.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
+ winnerID = winner.playerID if winner else 0
+ 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 GameWorld.IsCrossServer():
+ return
+
+ dbZoneID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ dbSeasonID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ dbSeasonState = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
+ GameWorld.Log("OnGameServerInitOK dbZoneID=%s,dbSeasonID=%s,dbSeasonState=%s" % (dbZoneID, dbSeasonID, dbSeasonState))
+
+ gameWorld = GameWorld.GetGameWorld()
+ zoneID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ if not zoneID:
+ gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID, dbZoneID)
+ gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID, dbSeasonID)
+ gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState, dbSeasonState)
+ GameWorld.Log(" 服务器启动取DB值设置本服赛区赛季信息: ")
+
+ return
def OnMapServerInitOK():
# 通知地图服务器状态
@@ -1432,7 +1836,12 @@
GameWorld.Log(" zoneID=%s,seasonID=%s,seasonState=%s,matchState=%s" % (zoneID, seasonID, seasonState, matchState))
if not zoneID:
return
-
+ if not seasonID:
+ dbSeasonID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ if dbSeasonID:
+ GameWorld.ErrLog(" 已经有分配赛季ID的暂定不能被置为0! dbSeasonID=%s" % dbSeasonID)
+ return
+
gameWorld = GameWorld.GetGameWorld()
curSeasonState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
@@ -1441,8 +1850,23 @@
gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState, seasonState)
gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK, matchState)
+ # 强制覆盖存DB
+ dbZoneID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ dbSeasonID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ dbSeasonState = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
+ GameWorld.Log(" before dbZoneID=%s,dbSeasonID=%s,dbSeasonState=%s" % (dbZoneID, dbSeasonID, dbSeasonState))
+
+ PlayerDBGSEvent.SetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID, zoneID)
+ PlayerDBGSEvent.SetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID, seasonID)
+ PlayerDBGSEvent.SetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState, seasonState)
+ dbZoneID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ dbSeasonID = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ dbSeasonState = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
+ GameWorld.Log(" update dbZoneID=%s,dbSeasonID=%s,dbSeasonState=%s" % (dbZoneID, dbSeasonID, dbSeasonState))
+
if curSeasonState == 1 and seasonState == 2:
- PlayerControl.WorldNotify(0, "NotifySeasonOver")
+ pass
+ #PlayerControl.WorldNotify(0, "NotifySeasonOver")
# 通知地图服务器状态
GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID, zoneID)
@@ -1456,6 +1880,8 @@
seasonStatePack.SeasonID = seasonID
seasonStatePack.SeasonState = seasonState
seasonStatePack.MatchState = matchState
+ seasonStatePack.CrossZoneName = GameWorld.GetCrossZoneName()
+ seasonStatePack.CrossZoneNameLen = len(seasonStatePack.CrossZoneName)
playerManager = GameWorld.GetPlayerManager()
for i in xrange(playerManager.GetPlayerCount()):
curPlayer = playerManager.GetPlayerByIndex(i)
@@ -1471,28 +1897,44 @@
if not curPlayer:
return
- if result == -2:
- PlayerControl.NotifyCode(curPlayer, "InCrossPKing")
+ if not result:
return
+ if result == -2:
+ PlayerControl.NotifyCode(curPlayer, "CrossMatching17")
+ return
+
+ startMatchPack = ChPyNetSendPack.tagGCCrossRealmPKStartMatch()
+
if result == 1:
- NetPackCommon.SendFakePack(curPlayer, ChPyNetSendPack.tagGCCrossRealmPKStartMatch())
+ SetIsCrossPKMatching(curPlayer, 1)
+ startMatchPack.IsRobot = 0
+ elif result == 2:
+ startMatchPack.IsRobot = 1
+ NetPackCommon.SendFakePack(curPlayer, startMatchPack)
return
+
+## 跨服匹配状态
+def SetIsCrossPKMatching(curPlayer, isMatching):
+ curPlayer.SetDict(ChConfig.Def_PlayerKey_IsCrossPKMatching, isMatching)
+ sysMsg = str(isMatching)
+ curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKMatching", sysMsg, len(sysMsg))
+ return
+def GetIsCrossPKMatching(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_IsCrossPKMatching)
def CrossServerMsg_PKMatchResult(vsRoomDict):
## 跨服PK匹配结果
curServerGroupID = GameWorld.GetServerGroupID()
- actionType = ShareDefine.Def_MergeAction_MergePK
mapPosList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKMatch", 5)
- GameWorld.Log("=== 收到PK匹配结果处理 === curServerGroupID=%s" % curServerGroupID)
+ GameWorld.DebugLog("=== 收到PK匹配结果处理 === curServerGroupID=%s" % curServerGroupID)
if not mapPosList:
GameWorld.ErrLog("没有配置对战地图进入坐标!")
return
for roomID, roomInfo in vsRoomDict.items():
mapID, playerList = roomInfo
- GameWorld.Log(" roomID=%s,playerList=%s" % (roomID, playerList))
+ GameWorld.DebugLog(" roomID=%s,playerList=%s" % (roomID, playerList))
for i, playerInfo in enumerate(playerList):
serverGroupID, playerID = playerInfo
if serverGroupID != curServerGroupID:
@@ -1508,7 +1950,7 @@
PlayerControl.SetVsRoomId(player, roomID, True)
# 通知地图玩家匹配成功, 上传数据, 准备进入跨服服务器
posX, posY = mapPosList[i] if len(mapPosList) > i else mapPosList[0]
- CrossRealmPlayer.SendCrossRealmReg(player, actionType, mapID, mapID, 0, posX, posY)
+ CrossRealmPlayer.SendCrossRealmReg(player, ChConfig.Def_FBMapID_CrossRealmPK, mapID, mapID, 0, posX, posY)
return
@@ -1516,13 +1958,18 @@
## 子服接收玩家已准备好的PK房间信息, 此房间里的玩家可传送进入跨服
curServerGroupID = GameWorld.GetServerGroupID()
- GameWorld.Log("===收到跨服服务器通知已准备好的对战PK房间信息处理=== curServerGroupID=%s" % curServerGroupID)
+ GameWorld.DebugLog("===收到跨服服务器通知已准备好的对战PK房间信息处理=== curServerGroupID=%s" % curServerGroupID)
# serverGroupID, playerName, playerJob
+
+ if not CrossRealmPlayer.IsCrossServerOpen():
+ GameWorld.Log("跨服服务器维护中,不处理!")
+ return
for roomID, readyMemberDict in readyOKRoomList:
for playerID, playerInfo in readyMemberDict.items():
serverGroupID = playerInfo["ServerGroupID"]
playerName = playerInfo["Name"]
+ number = playerInfo["Number"]
if serverGroupID != curServerGroupID:
GameWorld.DebugLog(" 不是本服玩家,不处理!playerID=%s,serverGroupID=%s" % (playerID, serverGroupID))
@@ -1546,29 +1993,30 @@
matchPlayer.Job = readyPlayerInfo["Job"]
matchPlayer.LV = readyPlayerInfo["LV"]
matchPlayer.MaxHP = readyPlayerInfo["MaxHP"]
+ matchPlayer.MaxProDef = readyPlayerInfo["MaxProDef"]
break
- PlayerControl.SetCrossRealmState(player, 1)
+ PlayerControl.SetCrossMapID(player, ChConfig.Def_FBMapID_CrossRealmPK)
+ SetIsCrossPKMatching(player, 0)
# 通知匹配成功,可进入跨服
matchOKPack = ChPyNetSendPack.tagGCCrossRealmPKMatchOK()
matchOKPack.RoomID = roomID
matchOKPack.PlayerName = playerName
matchOKPack.NameLen = len(matchOKPack.PlayerName)
+ matchOKPack.Number = number
matchOKPack.MatchPlayer = [matchPlayer]
matchOKPack.MatchPlayerCount = len(matchOKPack.MatchPlayer)
NetPackCommon.SendFakePack(player, matchOKPack)
- GameWorld.Log(" 通知玩家进入跨服PK对战房间! roomID=%s,playerID=%s,matchPlayerID=%s" % (roomID, playerID, matchPlayer.PlayerID))
+ GameWorld.DebugLog(" 通知玩家进入跨服PK对战房间! roomID=%s,playerID=%s,matchPlayerID=%s" % (roomID, playerID, matchPlayer.PlayerID))
- # 到这里默认认为一定会有结果的,所以本服直接增加次数
- #player.MapServer_QueryPlayerResult(0, 0, 'MergePKAddCnt', "", 0)
return
def CrossServerMsg_PKTimeoutRoomList(timeoutRoomDict):
## 子服接收已超时的PK房间信息, 此房间里的玩家重置跨服状态
curServerGroupID = GameWorld.GetServerGroupID()
- GameWorld.Log("===收到跨服服务器通知已超时的对战PK房间信息处理=== curServerGroupID=%s" % curServerGroupID)
+ GameWorld.DebugLog("===收到跨服服务器通知已超时的对战PK房间信息处理=== curServerGroupID=%s" % curServerGroupID)
for roomID, roomPlayerInfo in timeoutRoomDict.items():
if not roomPlayerInfo:
@@ -1591,15 +2039,53 @@
GameWorld.DebugLog(" 房间ID不同, playerID=%s" % (playerID))
continue
player.SetDict(ChConfig.Def_PlayerKey_IsLoginToMergeServer, 0)
- PlayerControl.SetCrossRealmState(player, 0)
+ PlayerControl.SetCrossMapID(player, 0)
return
+#跨服竞技场未通知玩家的比赛结果,注意该类只处理数据逻辑,功能相关逻辑不要写在该类,不然重读脚本不会生效
+class CrossPKUnNotifyOverInfoManager(object):
+
+ def __init__(self):
+ self.__unNotifyOverInfoDict = {} # {playerID:tagDBCrossPKUnNotifyOverInfo, ...}
+ return
+
+ def AddUnNotifyOverInfo(self, playerID, overInfoData):
+ self.__unNotifyOverInfoDict[playerID] = overInfoData
+ return
+
+ def GetPlayerUnNotifyOverInfo(self, playerID): return self.__unNotifyOverInfoDict.pop(playerID, None)
+
+ # 保存数据 存数据库和realtimebackup
+ def GetSaveData(self):
+ savaData = ""
+ cntData = ""
+ cnt = 0
+ for overInfoData in self.__unNotifyOverInfoDict.values():
+ cnt += 1
+ savaData += overInfoData.getBuffer()
+
+ GameWorld.Log("SaveDBCrossPKUnNotifyOverInfo cnt :%s" % cnt)
+ return CommFunc.WriteDWORD(cntData, cnt) + savaData
+
+ # 从数据库载入数据
+ def LoadPyGameData(self, datas, pos, dataslen):
+ cnt, pos = CommFunc.ReadDWORD(datas, pos)
+ GameWorld.Log("LoadDBCrossPKUnNotifyOverInfo cnt :%s" % cnt)
+
+ for _ in xrange(cnt):
+ overInfoData = PyGameDataStruct.tagDBCrossPKUnNotifyOverInfo()
+ overInfoData.clear()
+ pos += overInfoData.readData(datas, pos, dataslen)
+ self.__unNotifyOverInfoDict[overInfoData.PlayerID] = overInfoData
+
+ return pos
+
def CrossServerMsg_PKOverInfo(playerOverDict):
## 子服接收跨服PK结果信息
curServerGroupID = GameWorld.GetServerGroupID()
- GameWorld.Log("===收到跨服服务器同步的跨服PK结果=== curServerGroupID=%s" % curServerGroupID)
+ GameWorld.DebugLog("===收到跨服服务器同步的跨服PK结果=== curServerGroupID=%s" % curServerGroupID)
for playerID, overInfo in playerOverDict.items():
roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, \
@@ -1610,26 +2096,74 @@
sendMapOverInfo = [roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState]
player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
+ if not player:
+ CrossRealmPlayer.DoOfflinePlayerExitCrossServer(playerID)
if not player or PlayerControl.GetIsTJG(player):
- GameWorld.Log(" 玩家不在线 或脱机中,先缓存,玩家上线后再同步,playerID=%s" % (playerID))
- PyGameData.g_crossPKUnNotifyOverInfo[playerID] = sendMapOverInfo
+ GameWorld.DebugLog(" 玩家不在线 或脱机中,先缓存,玩家上线后再同步,playerID=%s" % (playerID))
+ overInfoData = PyGameDataStruct.tagDBCrossPKUnNotifyOverInfo()
+ overInfoData.clear()
+ overInfoData.ZoneID = zoneID
+ overInfoData.SeasonID = seasonID
+ overInfoData.RoomID = roomID
+ overInfoData.TimeStr = timeStr
+ overInfoData.OverType = overType
+ overInfoData.PlayerID = playerID
+ overInfoData.WinnerID = winnerID
+ overInfoData.RoundWinnerInfo = str(roundWinnerIDList)
+ overInfoData.RoundWinnerLen = len(overInfoData.RoundWinnerInfo)
+ overInfoData.PKScore = pkScore
+ overInfoData.DanLV = danLV
+ overInfoData.CWinCount = cWinCount
+ overInfoData.AddScore = addScore
+ overInfoData.TagPlayerID = tagPlayerID
+ overInfoData.TagPlayerName = tagPlayerName
+ PyDataManager.GetCrossPKUnNotifyOverInfoManager().AddUnNotifyOverInfo(playerID, overInfoData)
continue
+ PlayerControl.SetVsRoomId(player, 0)
sysMsg = str(sendMapOverInfo)
player.MapServer_QueryPlayerResult(0, 0, "CrossPKOverInfo", sysMsg, len(sysMsg))
- GameWorld.Log("通知地图跨服PK结算: roomID=%s,zoneID=%s,seasonID=%s,timeStr=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s, pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,notifyState=%s,mapID=%s"
- % (roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState, player.GetMapID()), playerID)
+ GameWorld.DebugLog("通知地图跨服PK结算: roomID=%s,zoneID=%s,seasonID=%s,timeStr=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s, pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,notifyState=%s,mapID=%s"
+ % (roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState, player.GetMapID()), playerID)
return
def __OnLoginNotifyPKOverInfo(curPlayer):
playerID = curPlayer.GetPlayerID()
- if playerID not in PyGameData.g_crossPKUnNotifyOverInfo:
+ overInfoData = PyDataManager.GetCrossPKUnNotifyOverInfoManager().GetPlayerUnNotifyOverInfo(playerID)
+ if not overInfoData:
return
- overInfo = PyGameData.g_crossPKUnNotifyOverInfo.pop(playerID)
- PlayerControl.SetCrossRealmState(curPlayer, 0)
- sysMsg = str(overInfo)
+ PlayerControl.SetCrossMapID(curPlayer, 0)
+ PlayerControl.SetVsRoomId(curPlayer, 0)
+
+ zoneID = overInfoData.ZoneID
+ seasonID = overInfoData.SeasonID
+ roomID = overInfoData.RoomID
+ timeStr = overInfoData.TimeStr
+ overType = overInfoData.OverType
+ #playerID = overInfoData.PlayerID
+ winnerID = overInfoData.WinnerID
+ roundWinnerIDList = []
+ try:
+ roundWinnerIDList = eval(overInfoData.RoundWinnerInfo)
+ except:
+ GameWorld.ErrLog("__OnLoginNotifyPKOverInfo roundWinnerIDList eval error! RoundWinnerInfo=%s" % overInfoData.RoundWinnerInfo, playerID)
+ pkScore = overInfoData.PKScore
+ danLV = overInfoData.DanLV
+ cWinCount = overInfoData.CWinCount
+ addScore = overInfoData.AddScore
+ tagPlayerID = overInfoData.TagPlayerID
+ tagPlayerName = overInfoData.TagPlayerName
+ notifyState = 0 # 登录才通知的默认未通知
+ sendMapOverInfo = [roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState]
+ sysMsg = str(sendMapOverInfo)
curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKOverInfo", sysMsg, len(sysMsg))
- GameWorld.Log("玩家上线通知地图未结算的跨服PK结算: mapID=%s,overInfo=%s" % (curPlayer.GetMapID(), overInfo), playerID)
+ GameWorld.DebugLog("玩家上线通知地图未结算的跨服PK结算: roomID=%s,zoneID=%s,seasonID=%s,timeStr=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s, pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,notifyState=%s,mapID=%s"
+ % (roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState, curPlayer.GetMapID()), playerID)
return
+def DR_CrossReamlPK(eventName, dataDict={}):
+ drDataDict = {}
+ drDataDict.update(dataDict)
+ DataRecordPack.SendEventPack("CrossPK_%s" % eventName, drDataDict)
+ return
--
Gitblit v1.8.0