From b61d2dfe79f9d3ef67a0561a0b640f888df32a58 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 31 十二月 2024 15:07:16 +0800
Subject: [PATCH] 10350 【后端】【越南】【英文】【BT】【砍树】跨服竞技场优化
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameDataStruct.py | 665 +++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py | 2
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py | 12
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py | 10
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py | 74
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py | 10
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py | 3
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py | 74
ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/PlayerMirror.py | 144 +
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/PlayerMirror.py | 6
ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py | 16
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py | 1933 +++-------------------
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py | 3
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_CrossRealmPK.py | 595 ------
ServerPython/CoreServerGroup/GameServer/Script/ChConfig.py | 3
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py | 1
ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py | 26
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py | 10
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py | 11
ServerPython/CoreServerGroup/GameServer/PyNetPack.ini | 11
ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py | 648 +++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/MirrorAttack.py | 3
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py | 26
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerQuery.py | 18
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/CrossPK.py | 38
ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/BillboardDataCross.py | 5
ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py | 12
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py | 49
ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py | 16
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py | 213 ++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py | 175 +
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py | 22
/dev/null | 50
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldProcess.py | 2
ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py | 10
ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py | 99
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py | 3
37 files changed, 2,303 insertions(+), 2,695 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini b/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini
index ea1a468..6e9965f 100644
--- a/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini
+++ b/ServerPython/CoreServerGroup/GameServer/PyNetPack.ini
@@ -442,17 +442,6 @@
PacketSubCMD_4=0x25
PacketCallFunc_4=OnChampionshipOfficialLeave
-[CrossRealmPK]
-ScriptName = GameWorldLogic\CrossRealmPK.py
-Writer = hxp
-Releaser = hxp
-RegType = 0
-RegisterPackCount = 1
-
-PacketCMD_1=0xC0
-PacketSubCMD_1=0x01
-PacketCallFunc_1=OnViewCrossPKBillboard
-
[CrossRealmPlayer]
ScriptName = Player\CrossRealmPlayer.py
Writer = hxp
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChConfig.py b/ServerPython/CoreServerGroup/GameServer/Script/ChConfig.py
index d8df2d6..f88cc45 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChConfig.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChConfig.py
@@ -668,7 +668,6 @@
Def_PlayerKey_CrossRegisterMap = "CrossRegisterMap" #跨服注册活动地图, dataMapID
Def_PlayerKey_MergeRegisterRoomID = "MergeRegisterRoomID" #当前上传数据的roomID
Def_PlayerKey_IsLoginToMergeServer = "IsLoginToMergeServer" #是否要登陆跨服服务器
-Def_PlayerKey_IsCrossPKMatching = "IsCrossPKMatching" #是否跨服匹配中
Def_PlayerKey_PlayerFromPID = "PlayerFromPID" #pid
@@ -681,8 +680,6 @@
Def_ForbiddenTalk = "ForbiddenTalk" # 禁言
Def_TalkTick = "ForbiddenTalk" # 聊天间隔
-
-Def_PlayerKey_ViewCrossPKBillboardTick = "ViewCrossPKBillboardTick_%s_%s" #查询PK排行榜tick,参数(zoneID, seasonID)
#主城地图、缥缈宗
Def_FBMapID_MainCity = 10010
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index 20e03e0..c74e612 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -23226,7 +23226,7 @@
_fields_ = [
("Cmd", c_ubyte),
("SubCmd", c_ubyte),
- ("Type", c_ubyte), # 0-取消匹配; 1-进行匹配
+ ("Type", c_ubyte), # 0-查询匹配;1-刷新匹配
]
def __init__(self):
@@ -23279,6 +23279,7 @@
("Cmd", c_ubyte),
("SubCmd", c_ubyte),
("IsWin", c_ubyte), #是否获胜
+ ("TagPlayerID", c_int), #目标玩家ID
]
def __init__(self):
@@ -23296,6 +23297,7 @@
self.Cmd = 0xC1
self.SubCmd = 0x08
self.IsWin = 0
+ self.TagPlayerID = 0
return
def GetLength(self):
@@ -23308,12 +23310,14 @@
DumpString = '''// C1 08 跨服PK挑战机器人结算 //tagCMCrossRealmPKRobotOver:
Cmd:%s,
SubCmd:%s,
- IsWin:%d
+ IsWin:%d,
+ TagPlayerID:%d
'''\
%(
self.Cmd,
self.SubCmd,
- self.IsWin
+ self.IsWin,
+ self.TagPlayerID
)
return DumpString
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index c02243e..4158f76 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -17741,11 +17741,11 @@
PlayerName = "" #(String PlayerName)// 跨服名字
Job = 0 #(BYTE Job)
LV = 0 #(WORD LV)
+ RealmLV = 0 #(WORD RealmLV)//境界
Face = 0 #(DWORD Face)//基本脸型
FacePic = 0 #(DWORD FacePic)//头像框
- MaxHP = 0 #(DWORD MaxHP)// 默认满血,求余亿部分
- MaxHPEx = 0 #(DWORD MaxHPEx)// 默认满血,整除亿部分
- MaxProDef = 0 #(DWORD MaxProDef)// 最大护盾
+ FightPower = 0 #(DWORD FightPower)//战力,求余亿部分
+ FightPowerEx = 0 #(DWORD FightPowerEx)//战力,整除亿部分
data = None
def __init__(self):
@@ -17759,11 +17759,11 @@
self.PlayerName,_pos = CommFunc.ReadString(_lpData, _pos,self.NameLen)
self.Job,_pos = CommFunc.ReadBYTE(_lpData, _pos)
self.LV,_pos = CommFunc.ReadWORD(_lpData, _pos)
+ self.RealmLV,_pos = CommFunc.ReadWORD(_lpData, _pos)
self.Face,_pos = CommFunc.ReadDWORD(_lpData, _pos)
self.FacePic,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.MaxHP,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.MaxHPEx,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.MaxProDef,_pos = CommFunc.ReadDWORD(_lpData, _pos)
+ self.FightPower,_pos = CommFunc.ReadDWORD(_lpData, _pos)
+ self.FightPowerEx,_pos = CommFunc.ReadDWORD(_lpData, _pos)
return _pos
def Clear(self):
@@ -17772,11 +17772,11 @@
self.PlayerName = ""
self.Job = 0
self.LV = 0
+ self.RealmLV = 0
self.Face = 0
self.FacePic = 0
- self.MaxHP = 0
- self.MaxHPEx = 0
- self.MaxProDef = 0
+ self.FightPower = 0
+ self.FightPowerEx = 0
return
def GetLength(self):
@@ -17786,7 +17786,7 @@
length += len(self.PlayerName)
length += 1
length += 2
- length += 4
+ length += 2
length += 4
length += 4
length += 4
@@ -17801,11 +17801,11 @@
data = CommFunc.WriteString(data, self.NameLen, self.PlayerName)
data = CommFunc.WriteBYTE(data, self.Job)
data = CommFunc.WriteWORD(data, self.LV)
+ data = CommFunc.WriteWORD(data, self.RealmLV)
data = CommFunc.WriteDWORD(data, self.Face)
data = CommFunc.WriteDWORD(data, self.FacePic)
- data = CommFunc.WriteDWORD(data, self.MaxHP)
- data = CommFunc.WriteDWORD(data, self.MaxHPEx)
- data = CommFunc.WriteDWORD(data, self.MaxProDef)
+ data = CommFunc.WriteDWORD(data, self.FightPower)
+ data = CommFunc.WriteDWORD(data, self.FightPowerEx)
return data
def OutputString(self):
@@ -17815,11 +17815,11 @@
PlayerName:%s,
Job:%d,
LV:%d,
+ RealmLV:%d,
Face:%d,
FacePic:%d,
- MaxHP:%d,
- MaxHPEx:%d,
- MaxProDef:%d
+ FightPower:%d,
+ FightPowerEx:%d
'''\
%(
self.PlayerID,
@@ -17827,21 +17827,17 @@
self.PlayerName,
self.Job,
self.LV,
+ self.RealmLV,
self.Face,
self.FacePic,
- self.MaxHP,
- self.MaxHPEx,
- self.MaxProDef
+ self.FightPower,
+ self.FightPowerEx
)
return DumpString
class tagGCCrossRealmPKMatchOK(Structure):
Head = tagHead()
- RoomID = 0 #(WORD RoomID)// 房间ID
- NameLen = 0 #(BYTE NameLen)
- PlayerName = "" #(String PlayerName)// 跨服名字
- Number = 0 #(BYTE Number)// 位置编号;1-左,2-右
MatchPlayerCount = 0 #(BYTE MatchPlayerCount)
MatchPlayer = list() #(vector<tagGCCrossRealmPKMatchPlayer> MatchPlayer)// 匹配到的玩家
data = None
@@ -17855,10 +17851,6 @@
def ReadData(self, _lpData, _pos=0, _Len=0):
self.Clear()
_pos = self.Head.ReadData(_lpData, _pos)
- self.RoomID,_pos = CommFunc.ReadWORD(_lpData, _pos)
- self.NameLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
- self.PlayerName,_pos = CommFunc.ReadString(_lpData, _pos,self.NameLen)
- self.Number,_pos = CommFunc.ReadBYTE(_lpData, _pos)
self.MatchPlayerCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
for i in range(self.MatchPlayerCount):
temMatchPlayer = tagGCCrossRealmPKMatchPlayer()
@@ -17871,10 +17863,6 @@
self.Head.Clear()
self.Head.Cmd = 0xC0
self.Head.SubCmd = 0x01
- self.RoomID = 0
- self.NameLen = 0
- self.PlayerName = ""
- self.Number = 0
self.MatchPlayerCount = 0
self.MatchPlayer = list()
return
@@ -17882,10 +17870,6 @@
def GetLength(self):
length = 0
length += self.Head.GetLength()
- length += 2
- length += 1
- length += len(self.PlayerName)
- length += 1
length += 1
for i in range(self.MatchPlayerCount):
length += self.MatchPlayer[i].GetLength()
@@ -17895,10 +17879,6 @@
def GetBuffer(self):
data = ''
data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
- data = CommFunc.WriteWORD(data, self.RoomID)
- data = CommFunc.WriteBYTE(data, self.NameLen)
- data = CommFunc.WriteString(data, self.NameLen, self.PlayerName)
- data = CommFunc.WriteBYTE(data, self.Number)
data = CommFunc.WriteBYTE(data, self.MatchPlayerCount)
for i in range(self.MatchPlayerCount):
data = CommFunc.WriteString(data, self.MatchPlayer[i].GetLength(), self.MatchPlayer[i].GetBuffer())
@@ -17907,19 +17887,11 @@
def OutputString(self):
DumpString = '''
Head:%s,
- RoomID:%d,
- NameLen:%d,
- PlayerName:%s,
- Number:%d,
MatchPlayerCount:%d,
MatchPlayer:%s
'''\
%(
self.Head.OutputString(),
- self.RoomID,
- self.NameLen,
- self.PlayerName,
- self.Number,
self.MatchPlayerCount,
"..."
)
@@ -57002,6 +56974,7 @@
("DayWinCount", c_ubyte), # 当日已胜利次数
("DayBuyCount", c_ubyte), # 当日已购买次数
("DayItemAddCount", c_ubyte), # 当日物品增加次数
+ ("DayRefreshCount", c_ushort), # 今日已刷新匹配次数
]
def __init__(self):
@@ -57027,6 +57000,7 @@
self.DayWinCount = 0
self.DayBuyCount = 0
self.DayItemAddCount = 0
+ self.DayRefreshCount = 0
return
def GetLength(self):
@@ -57047,7 +57021,8 @@
DayPKCount:%d,
DayWinCount:%d,
DayBuyCount:%d,
- DayItemAddCount:%d
+ DayItemAddCount:%d,
+ DayRefreshCount:%d
'''\
%(
self.Cmd,
@@ -57060,7 +57035,8 @@
self.DayPKCount,
self.DayWinCount,
self.DayBuyCount,
- self.DayItemAddCount
+ self.DayItemAddCount,
+ self.DayRefreshCount
)
return DumpString
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/BillboardDataCross.py b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/BillboardDataCross.py
index 79a3ece..e7133d7 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/BillboardDataCross.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/BillboardDataCross.py
@@ -30,6 +30,7 @@
GameWorld.DebugAnswer(curPlayer, "运营活动榜类型:158-boss凭证,160-凭证仙盟,162-仙匣,163-古宝,164-骑宠")
GameWorld.DebugAnswer(curPlayer, "古神战场榜类型:151-参与榜,152-召集榜,153-积分榜")
GameWorld.DebugAnswer(curPlayer, "逐鹿万界榜类型:156-单场榜,157-周榜")
+ GameWorld.DebugAnswer(curPlayer, "跨服竞技场榜单:165,分组值1-分区,分组值2-赛季,value2-段位")
GameWorld.DebugAnswer(curPlayer, "注:如果没有特殊说明,分组值1为分区ID,分组2为0")
return
@@ -97,8 +98,8 @@
FakeName = "假名字".decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
for i in xrange(count):
- dataPlayerID = curDataCount + 1 + i
- dataPlayerName = "%s%s" % (FakeName, i)
+ dataPlayerID = 1000 + curDataCount + 1 + i
+ dataPlayerName = "%s%s" % (FakeName, dataPlayerID)
dataCmpValue1 = max(0, cmpValue1 - i)
dataCmpValue2 = max(0, cmpValue2 - i)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/PlayerMirror.py b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/PlayerMirror.py
new file mode 100644
index 0000000..f4d9a4b
--- /dev/null
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GM/Commands/PlayerMirror.py
@@ -0,0 +1,144 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#-------------------------------------------------------------------------------
+#
+##@package GM.Commands.PlayerMirror
+#
+# @todo:镜像数据
+# @author hxp
+# @date 2024-12-26
+# @version 1.0
+#
+# 详细描述: 镜像数据
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2024-12-26 17:00"""
+#-------------------------------------------------------------------------------
+
+import ChConfig
+import ShareDefine
+import PyDataManager
+import PlayerPackData
+import ReadChConfig
+import GameWorld
+
+import base64
+import random
+
+## 执行逻辑
+# @param curPlayer 当前玩家
+# @param gmList []
+# @return None
+def OnExec(curPlayer, gmList):
+ if not gmList:
+ return
+ value = gmList[0]
+ if value == "a":
+ __addFackPackData(gmList[1:])
+ elif value == "d":
+ __delFackPackData()
+ elif value == "p":
+ __printPackData(gmList[1:])
+ return
+
+def OnGetMergeParam(curPlayer):
+ return []
+
+def OnMergeServerExec(gmList, tick):
+ ## 跨服执行命令
+ value = gmList[0]
+ if value == "a":
+ __addFackPackData(gmList[1:])
+ elif value == "d":
+ __delFackPackData()
+ elif value == "p":
+ __printPackData(gmList[1:])
+ return
+
+def __addFackPackData(gmList):
+ ## 添加假的打包数据,一般用于开发测试功能用
+ FakeName = "假名字".decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ #GameWorld.DebugAnswer(curPlayer, "添加镜像: PlayerMirror a 个数 [起始ID 战力 区服ID 模版key]")
+ addCount = gmList[0] if len(gmList) > 0 else 1
+ startID = gmList[1] if len(gmList) > 1 else 1
+ fightPower = gmList[2] if len(gmList) > 2 else 0
+ serverID = gmList[3] if len(gmList) > 3 else 0
+ packDataTempKey = gmList[4] if len(gmList) > 4 else ""
+
+ jobFackPackDataDict = ReadChConfig.GetEvalChConfig("FackPackData")
+
+ addOKCount = 0
+ for index in range(addCount):
+ fackID = startID + index
+ if packDataMgr.IsPlayerIn(fackID):
+ continue
+
+ job = random.randint(1, 2)
+ tempKey = packDataTempKey if packDataTempKey else "job%s" % job
+ if tempKey not in jobFackPackDataDict:
+ GameWorld.DebugAnswer(None, "配置FackPackData.txt没有该模版key:%s" % tempKey)
+ return
+ packDataTeam = jobFackPackDataDict[tempKey]
+ packDataTeamBuff = base64.b64decode(packDataTeam)
+
+ tempDBPlayer = PlayerPackData.GetDBPlayerByPackData(packDataTeam)
+ tempDBPlayer.PlayerID = fackID
+ tempDBPlayer.PlayerName = "%s%s" % (FakeName, fackID)
+ curServerID = serverID if serverID else fackID / 100
+ if not curServerID:
+ curServerID = 9999
+ tempDBPlayer.AccID = "fack%s@test@s%s" % (fackID, curServerID)
+ # 没有指定模版,则随机数据
+ if not packDataTempKey:
+ tempDBPlayer.Job = job
+ tempDBPlayer.LV = random.randint(tempDBPlayer.LV, tempDBPlayer.LV + 2)
+ tempDBPlayer.OfficialRank = random.randint(tempDBPlayer.OfficialRank, tempDBPlayer.OfficialRank + 2)
+
+ curFightPower = fightPower if fightPower else (tempDBPlayer.FightPowerEx * ChConfig.Def_PerPointValue + tempDBPlayer.FightPower)
+ curFightPower += index
+ tempDBPlayer.FightPower = curFightPower % ChConfig.Def_PerPointValue
+ tempDBPlayer.FightPowerEx = curFightPower / ChConfig.Def_PerPointValue
+
+ updBuff = tempDBPlayer.getBuffer() + packDataTeamBuff[tempDBPlayer.getLength():]
+ updPackData = base64.b64encode(updBuff)
+ packDataMgr.UpdPlayerPackData(fackID, updPackData)
+ addOKCount += 1
+
+ packDataMgr.Sort()
+
+ GameWorld.DebugAnswer(None, "添加假玩家打包数据数:%s,总:%s" % (addOKCount, packDataMgr.GetCount()))
+ return
+
+def __delFackPackData():
+
+ delCount = 0
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ for index in range(packDataMgr.GetCount())[::-1]:
+ packObj = packDataMgr.At(index)
+ if packObj.playerID >= 10000:
+ continue
+ packDataMgr.DelPlayerPackData(packObj.playerID)
+ delCount += 1
+
+ GameWorld.DebugAnswer(None, "删除假玩家打包数据数:%s,剩:%s" % (delCount, packDataMgr.GetCount()))
+ return
+
+def __printPackData(gmList):
+ startIndex = gmList[0] if len(gmList) > 0 else 0
+ printCount = gmList[1] if len(gmList) > 1 else 100
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ packDataMgr.Sort()
+ dataCount = packDataMgr.GetCount()
+ GameWorld.DebugLog("=== 打包数据总数: dataCount=%s,startIndex=%s" % (dataCount, startIndex))
+ for index in range(startIndex, startIndex + printCount):
+ if index >= dataCount:
+ break
+ packObj = packDataMgr.At(index)
+ playerID = packObj.playerID
+ fightPower = packObj.fightPower
+ serverID = packObj.serverID
+ GameWorld.DebugLog("index=%s,playerID=%s,serverID=%s,fightPower=%s,%s" % (index, playerID, serverID, fightPower, packObj.GetBaseDict()))
+ GameWorld.DebugAnswer(None, "输出完毕详见GameServer日志!总:%s" % (dataCount))
+ return
+
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
index 3edd9c9..d7ad0ea 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorld.py
@@ -1240,14 +1240,26 @@
# if not GetGameWorld().GetDebugLevel():
# return
#===========================================================================
+ if IsCrossServer():
+ DebugAnswerCross(0, 0, text)
+ return
if isLog:
DebugLog(text)
text = text.decode(ShareDefine.Def_Game_Character_Encoding).encode(GetCharacterEncoding())
- curPlayer.DebugAnswer(text)
+ if curPlayer:
+ curPlayer.DebugAnswer(text)
return
def CrossServerMsg_DebugAnswer(msgData):
playerID, text = msgData
+ if not playerID:
+ playerManager = GetPlayerManager()
+ for i in xrange(playerManager.GetActivePlayerCount()):
+ player = playerManager.GetActivePlayerAt(i)
+ if player == None:
+ continue
+ player.DebugAnswer(text)
+ return
curPlayer = GetPlayerManager().FindPlayerByID(playerID)
if not curPlayer:
return
@@ -1260,7 +1272,7 @@
import CrossRealmMsg
dataMsg = [playerID, text]
- serverGroupIDList = [serverGroupID]
+ serverGroupIDList = [serverGroupID] if serverGroupID else []
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_DebugAnswer, dataMsg, serverGroupIDList)
return
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
index 71537ac..8d2a68e 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossBillboard.py
@@ -17,12 +17,14 @@
import CommFunc
import ShareDefine
+import IpyGameDataPY
import CrossRealmMsg
import PyGameDataStruct
import ChPyNetSendPack
import DataRecordPack
import NetPackCommon
import PyDataManager
+import CrossRealmPK
import GameWorld
import operator
@@ -110,7 +112,6 @@
self.__billboardType = billboardType
self.__groupValue1 = groupValue1
self.__groupValue2 = groupValue2
- self.__maxCount = ShareDefine.CrossBillboard_MaxDataCount.get(billboardType, 100)
self.__crossServerDataVer = 0 # 主服榜单数据版本
self.__clientServerDataVer = 0 # 子服榜单数据版本
self.__billboardList = [] # [tagDBCrossBillboard, ...]
@@ -268,10 +269,17 @@
return
def GetCount(self): return len(self.__billboardList)
- def GetMaxCount(self): return self.__maxCount
+ def GetMaxCount(self):
+ maxCountDict = IpyGameDataPY.GetFuncEvalCfg("CrossBillboardSet", 1, {})
+ return maxCountDict.get(self.__billboardType, 100)
- def At(self, i): return self.__billboardList[i]
- def IsFull(self): return len(self.__billboardList) >= self.__maxCount
+ def At(self, i):
+ billData = self.__billboardList[i]
+ if not billData and False:
+ billData = PyGameDataStruct.tagDBCrossBillboard() # 不会执行到,只为了.出代码提示
+ return billData
+
+ def IsFull(self): return len(self.__billboardList) >= self.GetMaxCount()
def UpdCrossServerDataVer(self, version=None):
## 更新跨服榜单数据版本号,用于跨服主服、子服验证数据版本,同步榜单数据用
@@ -466,8 +474,21 @@
GameWorld.DebugLog("玩家请求查看跨服排行榜: billboardType=%s,groupValue1=%s,groupValue2=%s" % (billboardType, groupValue1, groupValue2))
# 请求查询跨服服务器
- dataMsg = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2,
- "QueryData":{"EventName":"View", "PlayerID":playerID, "StartIndex":startIndex, "WatchCnt":watchCnt, "WatchID":watchID}}
+ dataMsg = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2, "PlayerID":playerID,
+ "QueryType":"View", "QueryData":{"StartIndex":startIndex, "WatchCnt":watchCnt, "WatchID":watchID}}
+ CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_QueryBillboard, dataMsg)
+ return
+
+def OnQueryPlayerBillboardRank(playerID, funcName, funcData, billboardType, groupValue1, groupValue2=0, tagPlayerID=0):
+ ## 查询玩家ID排名
+ if GameWorld.IsCrossServer():
+ return
+ if billboardType not in ShareDefine.CrossBillboardTypeList:
+ return
+ if not tagPlayerID:
+ tagPlayerID = playerID # 默认查自己
+ dataMsg = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2, "PlayerID":playerID,
+ "QueryType":"Ranking", "QueryData":{"PlayerID":tagPlayerID, "funcName":funcName, "funcData":funcData}}
CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_QueryBillboard, dataMsg)
return
@@ -476,11 +497,13 @@
billboardType = msgData["BillboardType"]
groupValue1 = msgData["GroupValue1"]
groupValue2 = msgData["GroupValue2"]
+ playerID = msgData.get("PlayerID", 0) # 发起的玩家ID
+ queryType = msgData.get("QueryType", "") # 原数据返回子服
queryData = msgData.get("QueryData", {}) # 原数据返回子服
- SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, [serverGroupID], queryData)
+ SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, [serverGroupID], playerID, queryType, queryData)
return
-def SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, serverGroupIDList=None, queryData=None):
+def SyncCrossBillboardToClientServer(billboardType, groupValue1, groupValue2, serverGroupIDList=None, playerID=0, queryType="", queryData=None):
## 同步跨服榜单到子服
if not GameWorld.IsCrossServer():
return
@@ -492,9 +515,17 @@
billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
billboardObj.DoDelaySort()
idOrderDict = billboardObj.GetIDOrderDict()
- crossServerDataVer = billboardObj.GetCrossServerDataVer()
- msgData = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2,
- "QueryData":queryData, "CrossServerDataVer":crossServerDataVer}
+ msgData = {"BillboardType":billboardType, "GroupValue1":groupValue1, "GroupValue2":groupValue2, "PlayerID":playerID,
+ "QueryType":queryType, "QueryData":queryData}
+
+ # 查询名次
+ if queryType == "Ranking":
+ tagPlayerID = queryData.get("PlayerID", 0)
+ if not tagPlayerID:
+ return
+ queryData["OrderIndex"] = idOrderDict.get(tagPlayerID, 0) - 1 # -1-未上榜,0-第一名
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_SyncBillboard, msgData, serverGroupIDList)
+ return
# 有查询数据时才同步榜单数据列表,否则只同步数据版本号
if queryData:
@@ -560,38 +591,30 @@
billboardType = msgData["BillboardType"]
groupValue1 = msgData["GroupValue1"]
groupValue2 = msgData["GroupValue2"]
- crossServerDataVer = msgData["CrossServerDataVer"]
- syncBillboardList = msgData.get("BillboardDataList")
- GameWorld.DebugLog("收到跨服服务器同步的排行榜信息: billboardType=%s,groupValue1=%s,groupValue2=%s,crossServerDataVer=%s"
- % (billboardType, groupValue1, groupValue2, crossServerDataVer))
-
- #billboardMgr = PyDataManager.GetCrossBillboardManager()
- #billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
- #billboardObj.UpdClientServerBillboard(crossServerDataVer, syncBillboardList)
-
- queryData = msgData.get("QueryData")
- if not queryData:
+ playerID = msgData.get("PlayerID", 0) # 发起的玩家ID
+ queryType = msgData.get("QueryType", "")
+ queryData = msgData.get("QueryData", {})
+ GameWorld.DebugLog("收到跨服服务器同步的排行榜信息: billboardType=%s,groupValue1=%s,groupValue2=%s,queryType=%s"
+ % (billboardType, groupValue1, groupValue2, queryType), playerID)
+ if not queryType or not queryData:
return
- eventName = queryData.get("EventName")
- #eventData = queryData.get("EventData")
- queryPlayerID = queryData.get("PlayerID", 0)
- if not eventName or not queryPlayerID:
- return
-
- queryPlayer = GameWorld.GetPlayerManager().FindPlayerByID(queryPlayerID)
- if not queryPlayer:
- return
-
- if eventName == "View":
+ if queryType == "View":
+ queryPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
+ if not queryPlayer:
+ return
watchID = queryData.get("WatchID", 0)
+ syncBillboardList = msgData.get("BillboardDataList")
SyncCrossBillboardToPlayer(queryPlayer, billboardType, groupValue1, groupValue2, syncBillboardList, watchID)
- #else:
- # idOrderDict = billboardObj.GetIDOrderDict()
- # order = idOrderDict.get(queryPlayerID, 0)
- # sysMsg = str([billboardType, groupValue1, groupValue2, eventName, eventData, order])
- # queryPlayer.MapServer_QueryPlayerResult(0, 0, "CrossBillboardOrder", sysMsg, len(sysMsg))
+ elif queryType == "Ranking":
+ funcName = queryData.get("funcName", "")
+ funcData = queryData.get("funcData", {})
+ #tagPlayerID = queryData.get("PlayerID", 0)
+ orderIndex = queryData.get("OrderIndex", 0)
+ if funcName == "QueryCrossPKSeasonOrder":
+ CrossRealmPK.OnQueryCrossPKSeasonOrderRet(playerID, funcData, orderIndex)
+
return
def SyncCrossBillboardToPlayer(curPlayer, billboardType, groupValue1, groupValue2, billboardList, watchID):
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
index 11a38e3..6ab4977 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmMsg.py
@@ -87,14 +87,8 @@
if msgType == ShareDefine.ClientServerMsg_PKMatch:
CrossRealmPK.ClientServerMsg_PKMatch(serverGroupID, msgData, tick)
- elif msgType == ShareDefine.ClientServerMsg_PKRobotOver:
- CrossRealmPK.ClientServerMsg_PKRobotOver(serverGroupID, msgData, tick)
-
- elif msgType == ShareDefine.ClientServerMsg_PKCancel:
- CrossRealmPK.ClientServerMsg_PKCancel(msgData, tick)
-
- elif msgType == ShareDefine.ClientServerMsg_PKPrepareOK:
- CrossRealmPK.ClientServerMsg_PKPrepareOK(msgData, tick)
+ elif msgType == ShareDefine.ClientServerMsg_PKOver:
+ CrossRealmPK.ClientServerMsg_PKOver(serverGroupID, msgData, tick)
elif msgType == ShareDefine.ClientServerMsg_PKBillboard:
CrossRealmPK.ClientServerMsg_PKBillboard(serverGroupID, msgData)
@@ -383,23 +377,11 @@
elif msgType == ShareDefine.CrossServerMsg_PKMatchReqRet:
CrossRealmPK.CrossServerMsg_PKMatchReqRet(msgData)
- elif msgType == ShareDefine.CrossServerMsg_PKMatchResult:
- CrossRealmPK.CrossServerMsg_PKMatchResult(msgData)
-
- elif msgType == ShareDefine.CrossServerMsg_PKReadyOKRoomList:
- CrossRealmPK.CrossServerMsg_PKReadyOKRoomList(msgData)
-
- elif msgType == ShareDefine.CrossServerMsg_PKTimeoutRoomList:
- CrossRealmPK.CrossServerMsg_PKTimeoutRoomList(msgData)
-
elif msgType == ShareDefine.CrossServerMsg_PKOverInfo:
CrossRealmPK.CrossServerMsg_PKOverInfo(msgData)
elif msgType == ShareDefine.CrossServerMsg_PKSeasonInfo:
CrossRealmPK.CrossServerMsg_PKSeasonInfo(msgData)
-
- elif msgType == ShareDefine.CrossServerMsg_PKSyncBillboard:
- CrossRealmPK.CrossServerMsg_PKSyncBillboard(msgData)
elif msgType == ShareDefine.CrossServerMsg_LuckyCloudBuyLottery:
CrossLuckyCloudBuy.CrossServerMsg_LuckyCloudBuyLottery(msgData)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
index 40adc1f..67b2687 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/CrossRealmPK.py
@@ -20,9 +20,9 @@
import CrossRealmMsg
import DataRecordPack
import ChPyNetSendPack
-import CrossRealmPlayer
import PyGameDataStruct
import PlayerDBGSEvent
+import CrossBillboard
import PyDataManager
import NetPackCommon
import IpyGameDataPY
@@ -35,60 +35,7 @@
import operator
import random
import time
-
-class CrossPKPlayer():
- ## 跨服PK玩家类
-
- def __init__(self):
- self.accID = ""
- self.playerID = 0
- self.playerName = ""
- self.playerJob = 0
- self.playerLV = 0
- self.face = 0
- self.facePic = 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房间类
-
- def __init__(self):
- self.pkZoneID = 0
- self.seasonID = 0
- self.roomID = 0
- self.mapID = 0
- self.openTick = 0 # 开房时间
- self.readyTick = 0 # 玩家都准备好的时间
- self.roomState = ShareDefine.Def_VsRoom_State_WaitPlayer # 默认状态
- self.roomPlayerIDList = [] # 对战玩家ID列表
- self.readyPlayerIDList = [] # 已经准备好的玩家ID列表
- 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):
@@ -146,52 +93,34 @@
if (zoneID, seasonID) not in self.__UnSortZoneSeasonTimeDict:
self.__UnSortZoneSeasonTimeDict[(zoneID, seasonID)] = GameWorld.GetGameWorld().GetTick()
return
-
- ## ==================================== 子服的榜单数据管理 =====================================
- def UpdClientServerPKBillboard(self, zoneID, seasonID, syncBillboardList, isFinalBillboardData):
- ## 先直接清除本服数据,然后直接覆盖更新
- billboardList = self.GetCrossPKBillboardInfo(zoneID, seasonID)[0]
- billboardList = billboardList[:len(syncBillboardList)] # 直接用本服以后的排行数据实例clear后覆盖更新,不足的创建新实例
- orderDict = {} # 排行信息重新更新
- for i, syncData in enumerate(syncBillboardList):
- playerID, playerName, job, face, facePic, fightPower, realmLV, pkScore, danLV, billTime, order = syncData
- if i < len(billboardList):
- billboardData = billboardList[i]
- billboardData.clear()
- else:
- billboardData = PyGameDataStruct.tagDBCrossPKBillboard()
- billboardList.append(billboardData)
- billboardData.ZoneID = zoneID
- billboardData.SeasonID = seasonID
- billboardData.PlayerID = playerID
- billboardData.PlayerName = playerName
- billboardData.Job = job
- billboardData.Face = face
- billboardData.FacePic = facePic
- billboardData.FightPower = fightPower
- billboardData.RealmLV = realmLV
- billboardData.PKScore = pkScore
- billboardData.DanLV = danLV
- billboardData.Time = billTime
- orderDict[playerID] = order
-
- listAttrName = self.__ZoneSeasonDataList % (zoneID, seasonID)
- orderDictAttrName = self.__ZoneSeasonPlayerOrderDict % (zoneID, seasonID)
- setattr(self, listAttrName, billboardList)
- setattr(self, orderDictAttrName, orderDict)
- dbIsFinalData = PlayerDBGSEvent.GetDBGSTrig_ByKey(self.DBKEY_CrossPKFinalBillboardData % (zoneID, seasonID))
- isFinalBillboardData = 1 if isFinalBillboardData else 0
- if dbIsFinalData != isFinalBillboardData:
- PlayerDBGSEvent.SetDBGSTrig_ByKey(self.DBKEY_CrossPKFinalBillboardData % (zoneID, seasonID), isFinalBillboardData)
- GameWorld.Log("更新子服榜单数据是否是最终榜单数据!zoneID=%s,seasonID=%s,isFinalBillboardData=%s"
- % (zoneID, seasonID, isFinalBillboardData))
- return billboardList, orderDict
-
- def IsFinalBillboardData(self, zoneID, seasonID):
- ## 子服的赛区赛季榜单数据是否最终榜单数据
- return PlayerDBGSEvent.GetDBGSTrig_ByKey(self.DBKEY_CrossPKFinalBillboardData % (zoneID, seasonID))
-
## ===========================================================================================
+
+ def CopyToCrossBillboard(self):
+ toBillboardType = ShareDefine.Def_CBT_CrossRealmPK
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ for zoneID, seasonID in self.__ZoneSeasonList:
+ groupValue1, groupValue2 = zoneID, seasonID
+ toBillboardObj = billboardMgr.GetCrossBillboard(toBillboardType, groupValue1, groupValue2)
+ billboardList = self.GetCrossPKBillboardInfo(zoneID, seasonID)[0]
+ GameWorld.Log("CopyToCrossBillboard: zoneID=%s,seasonID=%s,%s" % (zoneID, seasonID, len(billboardList)))
+ for billboardData in billboardList:
+ tobillboardData = PyGameDataStruct.tagDBCrossBillboard()
+ tobillboardData.GroupValue1 = groupValue1
+ tobillboardData.GroupValue2 = groupValue2
+ tobillboardData.BillboardType = toBillboardType
+ tobillboardData.ID = billboardData.PlayerID
+ tobillboardData.Name1 = billboardData.PlayerName
+ tobillboardData.Type2 = billboardData.Job
+ tobillboardData.Value1 = billboardData.RealmLV
+ tobillboardData.Value2 = billboardData.DanLV
+ tobillboardData.Value3 = billboardData.Face
+ tobillboardData.Value4 = billboardData.FacePic
+ tobillboardData.CmpValue = billboardData.PKScore
+ tobillboardData.CmpValue3 = billboardData.Time
+ toBillboardObj.AddBillboardData(tobillboardData)
+
+ self.__ZoneSeasonList = []
+ return
# 保存数据 存数据库和realtimebackup
def GetSaveData(self):
@@ -228,318 +157,31 @@
billboardList = self.GetCrossPKBillboardInfo(zoneID, seasonID, True)[0]
GameWorld.Log(" zoneID=%s, seasonID=%s, count=%s" % (zoneID, seasonID, len(billboardList)))
+ self.CopyToCrossBillboard()
return pos
-def UpdateCrossPKBillboard(zoneID, seasonID, winner, loser, syncClientServer=False):
- ## 更新跨服PK排行榜,跨服服务器结算调用,子服不调用
-
- curZoneSeasonID = GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % zoneID)
- if curZoneSeasonID != seasonID:
- GameWorld.ErrLog("不是当前赛季,不更新排行榜! zoneID=%s,seasonID=%s,curZoneSeasonID=%s" % (zoneID, seasonID, curZoneSeasonID))
- return
- billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])
- if not billboardCfg or len(billboardCfg) != 2:
- GameWorld.ErrLog("跨服竞技场排行榜配置错误!")
- return
- maxCount, danLVLimit = billboardCfg
- if maxCount <= 0:
- return
- maxCount = min(2000, maxCount)
- upBillboardList = []
- 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
-
- crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
- billboardList, orderDict = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID)
-
- isUpd = False
- curTime = int(time.time())
- billboardTime = max(0, GameWorld.ChangeTimeStrToNum("2080-01-01 00:00:00") - curTime) # 因为先上榜排前面,所以时间记录值得反减,倒序排
- for pkPlayer in upBillboardList:
- playerID = pkPlayer.playerID
- if playerID in orderDict:
- order = orderDict[playerID]
- billboardData = billboardList[order - 1]
- GameWorld.DebugLog(" 已经在榜单上!playerID=%s,order=%s" % (playerID, order), playerID)
- else:
- if len(billboardList) < maxCount:
- newBillboardData = PyGameDataStruct.tagDBCrossPKBillboard()
- billboardList.append(newBillboardData)
- order = len(billboardList)
- GameWorld.DebugLog(" 添加新上榜榜单!playerID=%s,order=%s" % (playerID, order), playerID)
- else:
- lastBillboardData = billboardList[-1]
- # 分数如果超过最后一个,则顶掉最后一个
- if lastBillboardData.PKScore >= pkPlayer.pkScore:
- GameWorld.DebugLog(" PK积分不超过最后一名玩家,无法上榜! pkScore=%s <= lastPKScore=%s"
- % (pkPlayer.pkScore, lastBillboardData.PKScore), playerID)
- continue
- order = orderDict.pop(lastBillboardData.PlayerID, len(billboardList))
- GameWorld.DebugLog(" 顶掉最后一个榜单!playerID=%s,lastPlayer=%s,lastScore=%s,order=%s"
- % (playerID, lastBillboardData.PlayerID, lastBillboardData.PKScore, order))
- newBillboardData = PyGameDataStruct.tagDBCrossPKBillboard()
- billboardList[-1] = newBillboardData
- billboardData = newBillboardData
- orderDict[playerID] = order
-
- isUpd = True
- # 更新值
- billboardData.ZoneID = zoneID
- billboardData.SeasonID = seasonID
- billboardData.PlayerID = playerID
- billboardData.PlayerName = pkPlayer.playerName
- billboardData.Job = pkPlayer.playerJob
- billboardData.Face = pkPlayer.face
- billboardData.FacePic = pkPlayer.facePic
- billboardData.FightPower = pkPlayer.fightPower
- billboardData.RealmLV = pkPlayer.realmLV
- billboardData.PKScore = pkPlayer.pkScore
- billboardData.DanLV = pkPlayer.danLV
- billboardData.Time = billboardTime
- GameWorld.DebugLog(" 更新PK积分排行榜: playerID=%s,pkScore=%s,order=%s" % (playerID, billboardData.PKScore, order), playerID)
-
- # 战斗结算更新榜单先不排序,只设置需要排序
- if isUpd:
- crossPKBillboardMgr.SetNeedSort(zoneID, seasonID)
-
- # 如果匹配已经结束,且没有战斗中的房间了,则处理本阶段匹配总结算
- matchState = GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
- if not matchState and not PyGameData.g_crossPKRoomDict:
- GameWorld.Log("匹配已结束,且当前没有PK中的房间了!主动广播子服最新榜单! ")
- syncClientServer = True
- if syncClientServer:
- crossZoneName = GameWorld.GetCrossZoneName()
- zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID)
- if zoneIpyData:
- serverGroupIDList = zoneIpyData.GetServerGroupIDList()
- SyncPKSyncBillboardToClientServer(zoneID, seasonID, serverGroupIDList)
-
- return True
-
-#// C0 01 查看跨服竞技场赛季排行榜 #tagCGViewCrossPKBillboard
-#
-#struct tagCGViewCrossPKBillboard
-#{
-# tagHead Head;
-# BYTE ZoneID; // 赛区ID
-# BYTE SeasonID; // 赛季ID
-#};
-def OnViewCrossPKBillboard(index, clientData, tick):
- ''' 赛区赛季榜单同步规则,这里以多台跨服服务器为考虑
- 每台跨服服务器单独管理自己关联的子服赛区榜单
- 每日匹配结束结算时间点主动同步所有子服本台跨服服务器的所有赛区当前赛季榜单,这样能确保所有子服的赛区榜单是最新的
- 匹配期间,子服设置同步CD,如果有玩家查询,则每1分钟可向跨服服务器同步当前赛区赛季最新榜单信息,同步后发送玩家
- 非匹配期间,只要子服有数据则可直接发送给玩家,没有的话向跨服服务器同步后再发送玩家
- 历史赛季,因为每日跨服服务器都有主动广播,所以历史赛季只要子服有数据则可直接发送给玩家,没有的话向跨服服务器同步后再发送玩家
- 赛季结束 或 历史赛季 只要不是最终榜单数据的,则需主动向跨服服务器请求同步数据后再发送玩家
- 不同跨服服务器赛区的话由跨服服务器之间自己同步数据,子服只管向自己所属跨服服务器同步数据即可
-
- 跨服服务器与跨服服务器之间的赛区榜单同步,同步规则类似子服与跨服服务器,相互之间做好数据同步即可
- 数据同步后再同步各自所有子服,确保子服也是最新的,可考虑匹配结算结束同步一次即可
- 这样玩家查看其它跨服服务器赛区数据可能会延迟一次匹配阶段结算的时间,比如两个小时,这个等以后需要多台跨服服务器时再讨论
- '''
- curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
- if GameWorld.IsCrossServer():
- return
- playerID = curPlayer.GetPlayerID()
- zoneID, seasonID = clientData.ZoneID, clientData.SeasonID
- tickKey = ChConfig.Def_PlayerKey_ViewCrossPKBillboardTick % (zoneID, seasonID)
- if tick - curPlayer.GetDictByKey(tickKey) < 60000:
- GameWorld.DebugLog("玩家查询跨服PK排行榜CD中: zoneID=%s, seasonID=%s" % (zoneID, seasonID), playerID)
- return
- curPlayer.SetDict(tickKey, tick)
- gameWorld = GameWorld.GetGameWorld()
- serverZoneID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
-
- crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
- billboardList = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID)[0]
- isFinalBillboardData = crossPKBillboardMgr.IsFinalBillboardData(zoneID, seasonID)
-
- GameWorld.DebugLog("玩家请求查看跨服PK排行榜: zoneID=%s,seasonID=%s,serverZoneID=%s,isFinalBillboardData=%s"
- % (zoneID, seasonID, serverZoneID, isFinalBillboardData))
-
- # 本服赛区
- if zoneID == serverZoneID:
- curSeasonID = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
- seasonState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
-
- # 其他赛区
- else:
- serverTime = GameWorld.GetServerTime()
- curSeasonID = 0
- seasonState = 0
- crossZoneName = GameWorld.GetCrossZoneName()
- seasonList = IpyGameDataPY.GetIpyGameDataList("CrossRealmPKSeason", crossZoneName, zoneID)
- seasonList = [] if not seasonList else seasonList
- for seasonIpyData in seasonList:
- startDateStr = seasonIpyData.GetStartDate()
- endDateStr = seasonIpyData.GetEndDate()
- endTimeStr = seasonIpyData.GetEndTime()
-
- startDateTime = datetime.datetime.strptime("%s 00:00:00" % (startDateStr), ChConfig.TYPE_Time_Format)
- endDateTime = datetime.datetime.strptime("%s %s:00" % (endDateStr, endTimeStr), ChConfig.TYPE_Time_Format)
- if serverTime < startDateTime:
- break
- if serverTime <= endDateTime:
- curSeasonID = seasonIpyData.GetSeasonID()
- seasonState = 1
- else:
- break
-
- # 查询当前进行中的赛季
- if seasonID == curSeasonID:
- matchState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
- # 非匹配中的
- if not matchState:
- # 最终数据 or 赛季进行中 直接同步
- if isFinalBillboardData or (seasonState == 1 and billboardList):
- SyncCrossPKBillboard(curPlayer, zoneID, seasonID, billboardList)
- return
-
- # 正在匹配中的,验证本服数据同步CD,暂定1分钟同步一次
- else:
- syncTickKey = ChConfig.Def_WorldKey_CrossPKBillboardSyncTick % (zoneID, seasonID)
- if matchState and billboardList and tick - gameWorld.GetDictByKey(syncTickKey) < 60000:
- SyncCrossPKBillboard(curPlayer, zoneID, seasonID, billboardList)
- return
- gameWorld.SetDict(syncTickKey, tick)
-
- # 查询历史赛季的
- else:
- # 如果是最终数据则直接同步
- if isFinalBillboardData and billboardList:
- SyncCrossPKBillboard(curPlayer, zoneID, seasonID, billboardList)
- return
-
- # 请求查询跨服服务器
- dataMsg = {"ZoneID":zoneID, "SeasonID":seasonID, "ExData":{"EventName":"View", "PlayerID":playerID}}
- CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKBillboard, dataMsg)
- return
-
def MapServer_QueryCrossPKSeasonOrder(curPlayer, msgList):
## 地图服务器查询玩家赛区赛季PK榜排名
playerID = curPlayer.GetPlayerID()
zoneID, seasonID, eventName, eventData = msgList
- crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
- billboardList, orderDict = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID) # 子服的数据一定是排完序同步过来的,所以这里就不需要再排序了
- if not billboardList:
- # 本服没榜单数据,查询跨服服务器
- # 请求查询跨服服务器
- dataMsg = {"ZoneID":zoneID, "SeasonID":seasonID, "ExData":{"EventName":eventName, "PlayerID":playerID, "EventData":eventData}}
- CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKBillboard, dataMsg)
- return
-
- order = orderDict.get(playerID, 0)
- sysMsg = str([zoneID, seasonID, eventName, eventData, order])
- curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKSeasonOrder", sysMsg, len(sysMsg))
+ funcData = {"zoneID":zoneID, "seasonID":seasonID, "eventName":eventName, "eventData":eventData}
+ CrossBillboard.OnQueryPlayerBillboardRank(playerID, "QueryCrossPKSeasonOrder", funcData, ShareDefine.Def_CBT_CrossRealmPK, zoneID, seasonID)
return
-def ClientServerMsg_PKBillboard(serverGroupID, msgData):
- ## 收到子服请求查询PK排行榜信息
- if "GMSetCrossPK" in msgData:
- _GMSetCrossPK(serverGroupID, msgData)
- return
- zoneID = msgData["ZoneID"]
- seasonID = msgData["SeasonID"]
- exData = msgData.get("ExData", {}) # 原数据返回子服
- SyncPKSyncBillboardToClientServer(zoneID, seasonID, [serverGroupID], exData)
- return
-
-def SyncPKSyncBillboardToClientServer(zoneID, seasonID, serverGroupIDList, exData={}):
- ## 同步赛区赛季榜单到子服
- crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
- billboardList, orderDict = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID, True) # 同步子服前需触发排序
- isFinalBillboardData = False # 是否最终的榜单数据
- gameWorld = GameWorld.GetGameWorld()
- curZoneSeasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % zoneID)
- if seasonID < curZoneSeasonID:
- isFinalBillboardData = True # 历史赛季在跨服服务器中的一定是最终榜单数据
- elif seasonID == curZoneSeasonID:
- seasonState = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonState % zoneID)
- if seasonState == 2:
- isFinalBillboardData = True # 当前赛季已经是赛季结算状态的了,代表是最终榜单数据
-
- syncBillboardList = []
- for billboardData in billboardList:
- playerID = billboardData.PlayerID
- playerName = billboardData.PlayerName
- job = billboardData.Job
- face = billboardData.Face
- facePic = billboardData.FacePic
- fightPower = billboardData.FightPower
- realmLV = billboardData.RealmLV
- pkScore = billboardData.PKScore
- danLV = billboardData.DanLV
- billTime = billboardData.Time
- order = orderDict.get(playerID, 0)
- syncBillboardList.append([playerID, playerName, job, face, facePic, fightPower, realmLV, pkScore, danLV, billTime, order])
-
- syncInfo = [zoneID, seasonID, syncBillboardList, exData, isFinalBillboardData]
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKSyncBillboard, syncInfo, serverGroupIDList)
- return
-
-def CrossServerMsg_PKSyncBillboard(syncInfo):
- ## 收到跨服服务器同步的排行榜信息
- zoneID, seasonID, syncBillboardList, exData, isFinalBillboardData = syncInfo
- 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)
- if not exData:
- return
- eventName = exData.get("EventName")
- eventData = exData.get("EventData")
- queryPlayerID = exData.get("PlayerID", 0)
- if not eventName or not queryPlayerID:
- return
-
- queryPlayer = GameWorld.GetPlayerManager().FindPlayerByID(queryPlayerID)
+def OnQueryCrossPKSeasonOrderRet(playerID, funcData, orderIndex):
+ ## 查询排名返回
+ queryPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
if not queryPlayer:
return
-
- if eventName == "View":
- SyncCrossPKBillboard(queryPlayer, zoneID, seasonID, billboardList)
- else:
- order = orderDict.get(queryPlayerID, 0)
- sysMsg = str([zoneID, seasonID, eventName, eventData, order])
- queryPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKSeasonOrder", sysMsg, len(sysMsg))
-
+ zoneID = funcData["zoneID"]
+ seasonID = funcData["seasonID"]
+ eventName = funcData["eventName"]
+ eventData = funcData["eventData"]
+ order = orderIndex + 1
+ sysMsg = str([zoneID, seasonID, eventName, eventData, order])
+ queryPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKSeasonOrder", sysMsg, len(sysMsg))
return
-def SyncCrossPKBillboard(curPlayer, zoneID, seasonID, billboardList):
- ## 同步给玩家跨服PK榜单
- billboardInfo = ChPyNetSendPack.tagGCCrossRealmPKBillboardInfo()
- billboardInfo.ZoneID = zoneID
- billboardInfo.SeasonID = seasonID
- billboardInfo.PKBillboardList = []
- for billboardData in billboardList:
- billboardInfoData = ChPyNetSendPack.tagGCCrossRealmPKBillboardData()
- billboardInfoData.PlayerID = billboardData.PlayerID
- billboardInfoData.PlayerName = billboardData.PlayerName
- billboardInfoData.NameLen = len(billboardInfoData.PlayerName)
- billboardInfoData.Job = billboardData.Job
- billboardInfoData.Face = billboardData.Face
- billboardInfoData.FacePic = billboardData.FacePic
- billboardInfoData.FightPower = billboardData.FightPower
- billboardInfoData.RealmLV = billboardData.RealmLV
- billboardInfoData.PKScore = billboardData.PKScore
- billboardInfoData.DanLV = billboardData.DanLV
- billboardInfo.PKBillboardList.append(billboardInfoData)
- billboardInfo.Count = len(billboardInfo.PKBillboardList)
- NetPackCommon.SendFakePack(curPlayer, billboardInfo)
- return
-
################################################################################
def __GetCrossPKZoneSeasonTimeInfo():
@@ -661,9 +303,9 @@
GameWorld.Log("跨服PK赛季状态变更: zoneID=%s,seasonID=%s,seasonState=%s" % (zoneID, seasonID, seasonState))
serverGroupIDList = zoneIpyData.GetServerGroupIDList()
- # 赛季总结算,为确保子服榜单的实时性,这里需再同步子服最终榜单信息,需在同步赛季状态之前同步
+ # 赛季结束
if seasonState == 2:
- SyncPKSyncBillboardToClientServer(zoneID, seasonID, serverGroupIDList)
+ PyGameData.g_crossPKMatchDict = {}
# 广播当前赛区的所有子服跨服PK赛季状态变更
matchState = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % ShareDefine.DailyActionID_CrossReamPK)
@@ -681,15 +323,9 @@
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 = {}
- PyGameData.g_crossPKTodayPKRecordInfo = {}
- PyGameData.g_crossPKBesureMatchRobotInfo = {}
GameWorld.Log("跨服PK匹配状态开启,重置相关匹配数据!")
crossZoneName = GameWorld.GetCrossZoneName()
@@ -752,21 +388,6 @@
return zoneIpyData
return
-def OnPlayerLoginCrossServer(curPlayer):
- # 跨服登录处理
-
- 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):
# 本服登录处理
@@ -816,1012 +437,238 @@
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):
- # 发送取消匹配
- SendCancelCrossRealmPKMatch(curPlayer, "PlayerDisconnect")
- return
-
def IsCrossRealmPKMatchState():
## 跨服PK匹配赛是否开启
return GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState \
% ShareDefine.DailyActionID_CrossReamPK) == ChConfig.Def_Action_Open
-def SendCancelCrossRealmPKMatch(curPlayer, reason):
- ## 发送取消匹配
-
- # 跨服服务器不处理
- if GameWorld.IsCrossServer():
- return
-
- # 非活动中不处理
- if not IsCrossRealmPKMatchState():
- return
-
-# # 如果是要登陆到跨服服务器的,不发送取消
-# if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_IsLoginToMergeServer):
-# GameWorld.DebugLog("本次离线为要登陆跨服服务器的自动离线行为,不发送取消匹配!", curPlayer.GetPlayerID())
-# curPlayer.SetDict(ChConfig.Def_PlayerKey_IsLoginToMergeServer, 0)
-# return
-
- vsRoomID = curPlayer.GetVsRoomId()
- if vsRoomID and PlayerControl.GetCrossMapID(curPlayer) == ChConfig.Def_FBMapID_CrossRealmPK:
- GameWorld.DebugLog("玩家跨服PK状态,不能取消匹配!vsRoomID=%s" % vsRoomID, curPlayer.GetPlayerID())
- return
-
- dataMsg = {"accID":curPlayer.GetAccID(), # 账号
- "playerID":curPlayer.GetPlayerID(), # 玩家ID
- "playerName":curPlayer.GetName(), # 跨服子服玩家名
- "reason":reason, # 取消原因
- "vsRoomID":vsRoomID, # 对战房间ID
- }
- CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKCancel, dataMsg)
- PlayerControl.SetVsRoomId(curPlayer, 0)
- SetIsCrossPKMatching(curPlayer, 0)
- GameWorld.DebugLog("发送取消跨服PK匹配到跨服服务器:dataMsg=%s" % str(dataMsg), curPlayer.GetPlayerID())
- return
-
def ClientServerMsg_PKMatch(serverGroupID, playerInfoDict, tick):
## 请求匹配
-
- if not GameWorld.IsCrossServer():
- GameWorld.ErrLog("非跨服服务器不处理跨服PK匹配请求!")
- return
-
- if not IsCrossRealmPKMatchState():
- GameWorld.Log("跨服匹配PK活动未开启,不允许请求匹配!")
- return
-
seasonID = playerInfoDict["seasonID"] # 赛季ID
- pkZoneID = playerInfoDict["pkZoneID"] # 所属赛区
- accID = playerInfoDict["accID"] # 角色账号
+ zoneID = playerInfoDict["zoneID"] # 所属赛区
+
playerID = playerInfoDict["playerID"] # 角色ID
- playerName = playerInfoDict["playerName"] # 玩家名
- job = playerInfoDict["playerJob"] # 职业
+ fightPower = playerInfoDict["fightPower"]
+ requestType = playerInfoDict.get("requestType", 0)
+
+ isRefresh = requestType == 1
+ OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, isRefresh)
+ return
+
+def ClientServerMsg_PKOver(serverGroupID, playerInfoDict, tick):
+ ## 收到子服同步的PK结算
+
+ playerID = playerInfoDict["playerID"] # 角色ID
+ tagPlayerID = playerInfoDict["tagPlayerID"] # 目标玩家ID
+ isWinner = playerInfoDict["isWinner"] # 是否获胜
+ zoneID = playerInfoDict["pkZoneID"]
+ seasonID = playerInfoDict["seasonID"]
+ playerName = playerInfoDict["playerName"]
+ playerJob = playerInfoDict["playerJob"]
face = playerInfoDict["face"]
facePic = playerInfoDict["facePic"]
- playerLV = playerInfoDict["playerLV"] # 职业
- maxHP = playerInfoDict["maxHP"] # 职业
- maxProDef = playerInfoDict["maxProDef"] # 护盾
- fightPower = min(playerInfoDict["fightPower"], ChConfig.Def_UpperLimit_DWord) # 战斗力,暂无用,限制不超过20E
- realmLV = playerInfoDict["realmLV"] # 境界
- pkScore = playerInfoDict["pkScore"] # 当前积分
- danLV = playerInfoDict["danLV"] # 当前段位
- cWinCount = playerInfoDict["cWinCount"] # 连胜次数
- cLoseCount = playerInfoDict["cLoseCount"] # 连败次数
- ondayScore = playerInfoDict["ondayScore"] # 过天时的积分
+ realmLV = playerInfoDict["realmLV"]
+ fightPower = playerInfoDict["fightPower"]
+ pkScore = playerInfoDict["pkScore"]
+ danLV = playerInfoDict["danLV"]
+ cWinCount = playerInfoDict["cWinCount"]
- if playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict:
- GameWorld.Log("玩家已匹配机器人,无法重复发起匹配! playerID=%s,accID=%s" % (playerID, accID))
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, 2], [serverGroupID])
+ if playerID not in PyGameData.g_crossPKMatchDict:
+ GameWorld.ErrLog("玩家匹配,无法结算跨服PK奖励! tagPlayerID=%s,isWinner=%s,pkScore=%s,cWinCount=%s"
+ % (tagPlayerID, isWinner, pkScore, cWinCount), playerID)
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])
+ matchIDList = PyGameData.g_crossPKMatchDict[playerID]
+ if tagPlayerID not in matchIDList:
+ GameWorld.ErrLog("目标玩家ID不在玩家匹配列表里,无法结算跨服PK奖励! tagPlayerID=%s not in %s ,isWinner=%s,pkScore=%s,cWinCount=%s"
+ % (tagPlayerID, matchIDList, isWinner, pkScore, cWinCount), playerID)
return
- if playerID in PyGameData.g_crossPKPlayerDict:
- GameWorld.Log("玩家正在战斗中,无法重复发起匹配! playerID=%s,accID=%s" % (playerID, accID))
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, [playerID, -2], [serverGroupID])
- return
+ matchIndex = matchIDList.index(tagPlayerID)
- pkPlayer = CrossPKPlayer()
- pkPlayer.accID = accID
- pkPlayer.playerID = playerID
- pkPlayer.playerName = playerName
- pkPlayer.playerJob = job
- pkPlayer.playerLV = playerLV
- pkPlayer.face = face
- pkPlayer.facePic = facePic
- pkPlayer.maxHP = maxHP
- pkPlayer.maxProDef = maxProDef
- pkPlayer.pkScore = pkScore
- pkPlayer.danLV = danLV
- pkPlayer.fightPower = fightPower
- pkPlayer.realmLV = realmLV
- pkPlayer.matchTick = tick
- pkPlayer.cWinCount = cWinCount
- pkPlayer.ondayScore = ondayScore
- pkPlayer.serverGroupID = serverGroupID
- pkPlayer.pkZoneID = pkZoneID
- pkPlayer.seasonID = seasonID
-
- # 判断是否匹配机器人
- matchRobotRate = 0
- danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
- if danIpyData:
- matchRobotRate = danIpyData.GetMatchRobotRate() + danIpyData.GetMatchRobotRateEx() * cLoseCount
-
- # 判断是否必定匹配机器人: 连输X局必定连续匹配机器人Y局
- cLoseCount = 0
- todayPKRecordList = PyGameData.g_crossPKTodayPKRecordInfo.get(playerID, [])
- for pkRecord in todayPKRecordList[::-1]:
- _, winnerID = pkRecord
- if playerID == winnerID:
- break
- cLoseCount += 1
- cLoseBesureMatchRobot, besureMatchRobotCount = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKRobot", 2)
- if cLoseCount >= cLoseBesureMatchRobot:
- PyGameData.g_crossPKBesureMatchRobotInfo[playerID] = besureMatchRobotCount
- GameWorld.DebugLog("连输X局必定连续匹配机器人Y局! playerID=%s,cLoseCount(%s) >= X(%s),Y(%s)"
- % (playerID, cLoseCount, cLoseBesureMatchRobot, besureMatchRobotCount))
-
- matchRobotMaxRate = 100
-
- # 还有必定匹配机器人次数
- nowBesureMatchRobotCount = PyGameData.g_crossPKBesureMatchRobotInfo.get(playerID, 0)
- if nowBesureMatchRobotCount > 0:
- matchRobotRate = matchRobotMaxRate
- PyGameData.g_crossPKBesureMatchRobotInfo[playerID] = nowBesureMatchRobotCount - 1
- GameWorld.DebugLog("玩家必定匹配机器人! playerID=%s,nowBesureMatchRobotCount=%s" % (playerID, nowBesureMatchRobotCount))
-
- if matchRobotRate and GameWorld.CanHappen(matchRobotRate, matchRobotMaxRate):
- 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.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 matchPlayer in 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):
- ## 取消匹配
-
- if not GameWorld.IsCrossServer():
- GameWorld.ErrLog("非跨服服务器不处理取消跨服PK匹配!")
- return
-
- # 非活动中不处理
- if not IsCrossRealmPKMatchState():
- return
-
- accID = playerInfoDict["accID"] # 角色账号
- playerID = playerInfoDict["playerID"] # 玩家ID
- reason = playerInfoDict["reason"] # 取消原因
- vsRoomID = playerInfoDict["vsRoomID"] # 所属对战房间ID
- if vsRoomID in PyGameData.g_crossPKRoomDict:
- pkRoom = PyGameData.g_crossPKRoomDict[vsRoomID]
- if pkRoom.mapFBOpenTick or pkRoom.readyTick:
- GameWorld.Log("跨服对战房间已经开启了线路,或者双方数据都已传输完毕,不可再取消匹配!vsRoomID=%s" % vsRoomID)
- return
-
- 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.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.DebugLog(" 从匹配队列中删除,匹配队列剩余人数=%s" % (len(zoneMatchPlayerList)))
-
- #取消所有存在该玩家的房间,子服不一定知道玩家当前最新所属房间ID, 故只能通过遍历删除已经为玩家创建的房间
- for roomID, pkRoom in PyGameData.g_crossPKRoomDict.items():
- if playerID not in pkRoom.roomPlayerIDList:
- continue
-
- for roomPlayerID in pkRoom.roomPlayerIDList:
- if roomPlayerID == 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.DebugLog(" 将之前匹配的对手重新加入匹配队列: roomID=%s,roomPlayerID=%s,当前匹配人数=%s"
- % (roomID, roomPlayerID, len(zoneMatchPlayerList)))
-
- PyGameData.g_crossPKRoomDict.pop(roomID)
- GameWorld.DebugLog(" 移除房间: popRoomID=%s" % (roomID))
-
- # 记录流向
- dataDict = {"cancelPlayerID":playerID}
- dataDict.update(pkRoom.GetDRInfo())
- DR_CrossReamlPK("CancelRoom", dataDict)
- break
-
- if playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict:
- PyGameData.g_crossPKZoneMatchRobotPlayerDict.pop(playerID)
- GameWorld.DebugLog(" 从匹配机器人队列中移除!")
- return
-
-def ClientServerMsg_PKPrepareOK(playerInfoDict, tick):
- ## 玩家跨服对战数据准备OK
-
- if not GameWorld.IsCrossServer():
- GameWorld.ErrLog("非跨服服务器不处理取消跨服PK匹配!")
- return
-
- accID = playerInfoDict["accID"] # 玩家账号
- playerID = playerInfoDict["playerID"] # 玩家ID
- vsRoomID = playerInfoDict["vsRoomID"] # 所属对战房间ID
- if playerID not in PyGameData.g_crossPKPlayerDict:
- GameWorld.ErrLog("玩家跨服对战数据准备OK, 但找不到该对战玩家信息!vsRoomID=%s,playerID=%s" % (vsRoomID, playerID))
- return
- pkPlayer = PyGameData.g_crossPKPlayerDict[playerID]
- pkPlayer.prepareOKTick = tick
-
- if vsRoomID not in PyGameData.g_crossPKRoomDict:
- GameWorld.ErrLog("玩家跨服对战数据准备OK, 但找不到该对战房间(%s)!可能对手已取消!" % vsRoomID)
- return
- vsRoom = PyGameData.g_crossPKRoomDict[vsRoomID]
-
- if vsRoom.roomState != ShareDefine.Def_VsRoom_State_WaitPlayer:
- GameWorld.ErrLog("玩家跨服对战数据准备OK, 但房间状态非等待状态, state=%s!" % vsRoom.roomState)
- return
-
- if playerID not in vsRoom.readyPlayerIDList:
- vsRoom.readyPlayerIDList.append(playerID)
-
- GameWorld.DebugLog("玩家跨服PK准备完毕: accID=%s,playerID=%s,vsRoomID=%s" % (accID, playerID, vsRoomID))
- return
-
-def __ReadyOKRoomPlayerProcess(tick):
- ## 玩家跨服PK已准备好的房间处理
-
- #GameWorld.Log("===已准备好的对战房间处理===")
- serverGroupIDList = []
- sendReadyOKRoomList = []
- for roomID, vsRoom in PyGameData.g_crossPKRoomDict.items():
-
- # 非等待状态的房间不处理
- if vsRoom.roomState != ShareDefine.Def_VsRoom_State_WaitPlayer:
- continue
-
- if not vsRoom.roomPlayerIDList:
- continue
-
- pkZoneID = 0
- isAllReady = True
- roomGroupIDList = []
- readyMemberDict = {} # 已准备好的玩家信息
- 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, "Number":num,
- "Job":roomPlayer.playerJob, "Face":roomPlayer.face, "FacePic":roomPlayer.facePic, "LV":roomPlayer.playerLV, "MaxHP":roomPlayer.maxHP, "MaxProDef":roomPlayer.maxProDef}
-
- if not isAllReady:
- continue
- vsRoom.roomState = ShareDefine.Def_VsRoom_State_PrepareFight
- vsRoom.readyTick = tick
- 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.DebugLog(" 已准备好的对战房间数: %s" % len(sendReadyOKRoomList))
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKReadyOKRoomList, sendReadyOKRoomList, serverGroupIDList)
-
- return
-#
-#def TestAddMatch(addCount, maxDanLV=None, isClear=False):
-# tick = GameWorld.GetGameWorld().GetTick()
-# 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匹配定时处理逻辑
-
- # 非跨服服务器不处理跨服PK匹配逻辑
- if not GameWorld.IsCrossServer():
- return
-
- if not IsCrossRealmPKMatchState():
- return
-
- # 定时更新排行榜
- crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
- crossPKBillboardMgr.PKBillboardSortByTime(tick)
-
- processTick = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 1) * 1000
- processTickKey = "PKMatchLastTick"
- lastProcessTick = GameWorld.GetGameWorld().GetDictByKey(processTickKey)
- if tick - lastProcessTick < processTick:
- return
- GameWorld.GetGameWorld().SetDict(processTickKey, tick)
-
- # 延迟通知匹配到机器人的
- __DelayNotifyMatchRobot(tick)
- # 处理超时的房间
- __DoCheckRoomTimeout(tick)
- # 通知已准备好的房间玩家可进入跨服
- __ReadyOKRoomPlayerProcess(tick)
-
- maxGroupCnt = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 2)
- outTimeTick = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 3) * 1000
-
- # 每个赛区单独匹配
- for pkZoneID, matchPlayerIDList in PyGameData.g_crossPKZoneMatchPlayerDict.items():
- 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.DebugLog("★★★★★★★★★★开始跨服PK匹配(pkZoneID=%s, 总人数:%s)★★★★★★★★★★" % (pkZoneID, matchPlayerCount))
-
- matchPlayerList = []
- for matchPlayerID in matchPlayerIDList:
- if matchPlayerID not in PyGameData.g_crossPKPlayerDict:
- continue
- matchPlayerList.append(PyGameData.g_crossPKPlayerDict[matchPlayerID])
- # 按匹配时间、积分升序排序
- matchTickSortList = sorted(matchPlayerList, key=operator.attrgetter("matchTick"))
- #scoreSortList = sorted(matchPlayerList, key=operator.attrgetter("pkScore")) # 新匹配规则暂时用不到积分排序的
-
- matchPlayerVSList = [] # 成功匹配玩家对战列表
-
- # 优先匹配等待超时玩家
- __DoMatchPlayer(matchTickSortList, matchPlayerVSList, maxGroupCnt, tick, outTimeTick)
-
- if len(matchPlayerVSList) < maxGroupCnt:
- # 再按积分段匹配玩家
- __DoMatchPlayer(matchTickSortList, matchPlayerVSList, maxGroupCnt, tick)
-
- # 给成功匹配的玩家非配对战房间
- matchPlayerVSList = matchPlayerVSList[:maxGroupCnt]
- __DoSetVSRoom(pkZoneID, matchPlayerVSList, tick)
- 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
-
-def __DoMatchPlayer(matchTickSortList, matchPlayerVSList, maxGroupCnt, tick, outTimeTick=0):
- ''' 匹配玩家
- @param matchTickSortList: 按匹配时间升序排序后的匹配玩家列表
- @param maxGroupCnt: 最大匹配组数
- @param matchPlayerVSList: 已经匹配的PK组列表
- @param outTimeTick: 超时tick设定,0为匹配非超时玩家
- '''
-
- matchPlayerCount = 0
- danPlayerListDict = {}
- for matchPlayer in matchTickSortList:
- if outTimeTick and tick - matchPlayer.matchTick < outTimeTick:
- # 未超时,不再匹配,因为只有一个玩家
- break
- danLV = matchPlayer.danLV
- danPlayerList = danPlayerListDict.get(danLV, [])
- danPlayerList.append(matchPlayer)
- danPlayerListDict[danLV] = danPlayerList
- matchPlayerCount += 1
-
- if outTimeTick:
- GameWorld.DebugLog(" ==优先匹配超时等待玩家==最大等待时间:%s, matchPlayerCount=%s" % (outTimeTick, matchPlayerCount))
- else:
- GameWorld.DebugLog(" ==常规段位玩家== maxGroupCnt=%s,matchPlayerCount=%s" % (maxGroupCnt, matchPlayerCount))
-
- if matchPlayerCount < 2:
- #GameWorld.DebugLog(" 匹配玩家不足!不处理!matchPlayerCount=%s" % matchPlayerCount)
- return
-
- danList = danPlayerListDict.keys()
- random.shuffle(danList) # 打乱段位处理顺序
-
- matchProtectRound = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch2", 1) # 几局内不能匹配到同一个玩家
- matchDanDiffList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKMatch2", 2) # 初始匹配段位差|超时匹配段位差
- matchDanDiff = matchDanDiffList[1] if outTimeTick else matchDanDiffList[0]
-
- #GameWorld.DebugLog(" 匹配玩家数=%s,同对手匹配保护局数=%s,匹配段位差=%s,danList=%s"
- # % (matchPlayerCount, matchProtectRound, matchDanDiff, danList))
-
- for danLV in danList:
- danPlayerList = danPlayerListDict[danLV]
- lowDanPlayerList, highDanPlayerList = [], [] # 相对danLV的高低段位玩家需要分开处理,如果一起处理的话可能导致匹配到不应该匹配到的段位
- for vsDanLV in xrange(max(0, danLV - matchDanDiff), danLV + matchDanDiff + 1):
- if danLV == vsDanLV:
- continue
- if vsDanLV not in danPlayerListDict:
- continue
- if vsDanLV < danLV:
- lowDanPlayerList += danPlayerListDict[vsDanLV]
- else:
- highDanPlayerList += danPlayerListDict[vsDanLV]
-
- #GameWorld.DebugLog(" danLV=%s,danPlayerCount=%s,lowPlayerCount=%s,highPlayerCount=%s"
- # % (danLV, len(danPlayerList), len(lowDanPlayerList), len(highDanPlayerList)))
-
- # 非超时的,优先匹配同段位玩家
- if not outTimeTick:
- __MatchDanPlayerList(matchTickSortList, matchPlayerVSList, danPlayerList, danPlayerListDict, matchProtectRound, maxGroupCnt)
-
- # 分别匹配低段位、高段位
- __MatchDanPlayerList(matchTickSortList, matchPlayerVSList, danPlayerList + lowDanPlayerList, danPlayerListDict, matchProtectRound, maxGroupCnt)
- __MatchDanPlayerList(matchTickSortList, matchPlayerVSList, danPlayerList + highDanPlayerList, danPlayerListDict, matchProtectRound, maxGroupCnt)
-
- return
-
-def __MatchDanPlayerList(matchTickSortList, matchPlayerVSList, matchPlayerList, danPlayerListDict, matchProtectRound, maxGroupCnt):
- ## 执行匹配段位玩家列表
-
- matchPlayerCount = len(matchPlayerList)
- if matchPlayerCount < 2:
- return
- random.shuffle(matchPlayerList) # 打乱匹配顺序,相当于随机两两分组,然后下面直接按顺序处理即可
- #GameWorld.DebugLog(" 总未匹配人数=%s,已匹配组数=%s,待匹配人数=%s" % (len(matchTickSortList), len(matchPlayerVSList), len(matchPlayerList)))
- #for i, mPlayer in enumerate(matchPlayerList):
- # GameWorld.DebugLog(" i=%s,playerID=%s,danLV=%s" % (i, mPlayer.playerID, mPlayer.danLV))
- #maxGroupCnt = 99999 # 测试批量匹配用
-
- nextIndex = 0
- doCount = matchPlayerCount
- # 至少需要两个 且 未达到最大成功匹配组数 且 限制最大可循环次数大于0
- while nextIndex < len(matchPlayerList) - 1 and len(matchPlayerVSList) < maxGroupCnt and doCount > 0:
- doCount -= 1
- i = nextIndex
- aPlayer = matchPlayerList[i]
- nextIndex += 1
-
- aPlayerID = aPlayer.playerID
- aDanLV = aPlayer.danLV
- #if maxGroupCnt == 99999 and random.randint(1, 10) > 5:
- # GameWorld.DebugLog(" i=%s,aPlayerID=%s,aDanLV=%s 测试随机不匹配" % (i, aPlayerID, aDanLV))
- # continue
- if aPlayer not in matchTickSortList:
- #GameWorld.DebugLog(" i=%s,aPlayerID=%s,aDanLV=%s 已经被匹配走了" % (i, aPlayerID, aDanLV))
- continue
- aTodayPKRecordList = PyGameData.g_crossPKTodayPKRecordInfo.get(aPlayerID, [])
- aMatchProtectPlayerIDList = [pkRecord[0] for pkRecord in aTodayPKRecordList[:-matchProtectRound - 1:-1]] # 最近X局匹配的玩家ID
- #GameWorld.DebugLog(" i=%s,aPlayerID=%s,aMatchProtectPlayerIDList=%s" % (i, aPlayerID, aMatchProtectPlayerIDList))
-
- isMatchOK = False
- for j, bPlayer in enumerate(matchPlayerList[nextIndex:], nextIndex):
- bPlayerID = bPlayer.playerID
- bDanLV = bPlayer.danLV
- #if maxGroupCnt == 99999 and random.randint(1, 10) > 5:
- # GameWorld.DebugLog(" j=%s,bPlayerID=%s,bDanLV=%s 测试随机不匹配" % (j, bPlayerID, bDanLV))
- # continue
- if bPlayer not in matchTickSortList:
- #GameWorld.DebugLog(" j=%s,bPlayerID=%s,bDanLV=%s 已经被匹配走了" % (j, bPlayerID, bDanLV))
- continue
- if bPlayerID in aMatchProtectPlayerIDList:
- GameWorld.DebugLog(" j=%s,bPlayerID=%s,bDanLV=%s %s局内不匹配同对手! bPlayerID=%s in aMatchProtectPlayerIDList=%s"
- % (j, bPlayerID, bDanLV, matchProtectRound, bPlayerID, aMatchProtectPlayerIDList))
- continue
-
- bTodayPKRecordList = PyGameData.g_crossPKTodayPKRecordInfo.get(bPlayerID, [])
- bMatchProtectPlayerIDList = [pkRecord[0] for pkRecord in bTodayPKRecordList[:-matchProtectRound - 1:-1]] # 最近X局匹配的玩家ID
- if aPlayerID in bMatchProtectPlayerIDList:
- GameWorld.DebugLog(" j=%s,bPlayerID=%s,bDanLV=%s %s局内不匹配同对手! aPlayerID=%s in bMatchProtectPlayerIDList=%s"
- % (j, bPlayerID, bDanLV, matchProtectRound, aPlayerID, bMatchProtectPlayerIDList))
- continue
-
- matchTickSortList.remove(aPlayer)
- matchTickSortList.remove(bPlayer)
-
- matchPlayerList.remove(aPlayer)
- matchPlayerList.remove(bPlayer)
-
- aDanPlayerList = danPlayerListDict.get(aDanLV, [])
- if aPlayer in aDanPlayerList:
- aDanPlayerList.remove(aPlayer)
- bDanPlayerList = danPlayerListDict.get(bDanLV, [])
- if bPlayer in bDanPlayerList:
- bDanPlayerList.remove(bPlayer)
-
- # 加入成功匹配列表
- isMatchOK = True
- matchPlayerVSList.append([aPlayer, bPlayer])
- GameWorld.DebugLog(" i=%s,j=%s,aPlayerID=%s(danLV:%s) VS bPlayerID=%s(danLV:%s) 匹配成功!"
- % (i, j, aPlayerID, aDanLV, bPlayerID, bDanLV))
- break
-
- if isMatchOK:
- nextIndex -= 1
-
- return
-
-def __DoSetVSRoom(pkZoneID, matchPlayerVSList, tick):
- ## 设置对战房间
-
- if not matchPlayerVSList:
- return
-
- vsRoomDict = {}
- serverGroupIDList = []
- zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(pkZoneID, [])
-
- mapIDList = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch", 4)
- GameWorld.DebugLog("===给配对的玩家开房间(pkZoneID=%s,配对数:%s)===" % (pkZoneID, len(matchPlayerVSList)))
- for aPlayer, bPlayer in matchPlayerVSList:
-
- if not aPlayer or not bPlayer:
- continue
-
- aPlayerID = aPlayer.playerID
- bPlayerID = bPlayer.playerID
- if aPlayerID not in PyGameData.g_crossPKPlayerDict or bPlayerID not in PyGameData.g_crossPKPlayerDict:
- GameWorld.ErrLog("玩家匹配数据异常!aPlayerID=%s,bPlayerID=%s" % (aPlayerID, bPlayerID))
- continue
-
- roomID = __GetNewRoomID()
- if not roomID:
- GameWorld.ErrLog("无法创建房间!该房间已经存在!PyGameData.g_crossPKRoomID=%s" % PyGameData.g_crossPKRoomID)
- continue
- mapID = random.choice(mapIDList)
-
- newRoom = CrossPKRoom()
- newRoom.pkZoneID = pkZoneID
- newRoom.seasonID = aPlayer.seasonID # 因为匹在一起的玩家一定是同一赛区同一赛季的,所以随便取一个玩家的赛季ID信息即可
- newRoom.roomID = roomID
- newRoom.mapID = mapID
- newRoom.openTick = tick
- newRoom.roomPlayerIDList = [aPlayerID, bPlayerID]
- PyGameData.g_crossPKRoomDict[roomID] = newRoom
-
- aServerGroupID, bServerGroupID = aPlayer.serverGroupID, bPlayer.serverGroupID
- 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)
-
- # 移除匹配队列
- if aPlayerID in zoneMatchPlayerList:
- zoneMatchPlayerList.remove(aPlayerID)
- if bPlayerID in zoneMatchPlayerList:
- zoneMatchPlayerList.remove(bPlayerID)
- PyGameData.g_crossPKZoneMatchPlayerDict[pkZoneID] = zoneMatchPlayerList
-
- # 将匹配结果广播到子服
- if vsRoomDict:
- CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchResult, vsRoomDict, serverGroupIDList)
-
- return
-
-def __GetNewRoomID():
- ## 获取新房间ID, 房间号直接自增,一定不会重复,除非自增一轮后房间ID还没有释放
- for _ in xrange(100):
- newRoomID = PyGameData.g_crossPKRoomID + 1
- if newRoomID > 65530:
- newRoomID = 1
- PyGameData.g_crossPKRoomID = newRoomID
- if newRoomID not in PyGameData.g_crossPKRoomDict:
- return newRoomID
- return 0
-
-def __DoCheckRoomTimeout(tick):
- ## 处理超时的房间
-
- timeoutRoomDict = {}
- serverGroupIDList = []
- roomTimeout = IpyGameDataPY.GetFuncCfg("CrossRealmPKCfg", 2) * 1000 # 这个时间尽量长点,目前暂时不确定玩家从准备到进入到地图的时长
- for roomID, pkRoom in PyGameData.g_crossPKRoomDict.items():
- if pkRoom.mapFBOpenTick or not pkRoom.readyTick:
- continue
- if tick - pkRoom.readyTick <= roomTimeout:
- continue
- pkZoneID = pkRoom.pkZoneID
- GameWorld.Log("PK房间等待玩家进来超时,没有玩家进来,关闭该房间!pkZoneID=%s,roomID=%s,openTick=%s,readyTick=%s,tick=%s"
- % (pkZoneID, roomID, pkRoom.openTick, pkRoom.readyTick, tick))
- roomPlayerInfo = []
- for roomPlayerID in pkRoom.roomPlayerIDList:
- pkPlayer = PyGameData.g_crossPKPlayerDict.pop(roomPlayerID, None)
- if not pkPlayer:
- continue
- serverGroupID = pkPlayer.serverGroupID
- GameWorld.Log(" 移除玩家,玩家需重新手动匹配,serverGroupID=%s,roomPlayerID=%s" % (serverGroupID, roomPlayerID))
- serverGroupIDList.append(serverGroupID)
- roomPlayerInfo.append([serverGroupID, roomPlayerID])
- 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, 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.mapFBOpenTick = tick
- GameWorld.Log("MapServer_CrossPKRoomOpen => roomID=%s" % roomID)
- return
-
-def MapServer_CrossPKOver(infoList, tick):
- ## 收到MapServer副本跨服PK结果同步
-
- GameWorld.DebugLog("收到MapServer_跨服PK战斗结果: %s" % str(infoList))
-
- roomID, winnerID, loserID, roundWinnerIDList, overType = infoList
-
- if roomID not in PyGameData.g_crossPKRoomDict:
- GameWorld.ErrLog("跨服PK房间数据不存在!roomID=%s" % roomID)
- return
- vsRoom = PyGameData.g_crossPKRoomDict.pop(roomID)
- #vsRoom = PyGameData.g_crossPKRoomDict[roomID]
- roomPlayerIDList = vsRoom.roomPlayerIDList
- if not winnerID and not loserID:
- GameWorld.ErrLog("地图没有结算跨服PK胜负玩家,随机玩家获胜!")
- if not roomPlayerIDList or len(roomPlayerIDList) != 2:
- return
- winnerID, loserID = roomPlayerIDList
- elif not loserID:
- for roomPlayerID in roomPlayerIDList:
- if roomPlayerID != winnerID:
- loserID = roomPlayerID
- break
-
- if winnerID not in roomPlayerIDList or loserID not in roomPlayerIDList:
- GameWorld.ErrLog("跨服PK房间及玩家不匹配,不结算!roomID=%s,winnerID=%s,loserID=%s,roomPlayerIDList=%s"
- % (roomID, winnerID, loserID, vsRoom.roomPlayerIDList))
- return
-
- if winnerID not in PyGameData.g_crossPKPlayerDict:
- GameWorld.ErrLog("跨服PK房间获取不到玩家PK数据, roomID=%s,winnerID=%s" % (roomID, winnerID))
- return
- if loserID not in PyGameData.g_crossPKPlayerDict:
- GameWorld.ErrLog("跨服PK房间获取不到玩家PK数据, roomID=%s,loserID=%s" % (roomID, loserID))
- return
-
- winner = PyGameData.g_crossPKPlayerDict.pop(winnerID)
- loser = PyGameData.g_crossPKPlayerDict.pop(loserID)
- #winner = PyGameData.g_crossPKPlayerDict[winnerID]
- #loser = PyGameData.g_crossPKPlayerDict[loserID]
- zoneID = vsRoom.pkZoneID
- seasonID = vsRoom.seasonID
-
- cWinCount = winner.cWinCount
- winnerScore, loserScore = winner.pkScore, loser.pkScore
- winnerDanLV, loserDanLV = winner.danLV, loser.danLV
- winnerDayScore, loserDayScore = max(0, winnerScore - winner.ondayScore), max(0, loserScore - loser.ondayScore) # 今日已获得积分,正积分
-
- 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)
- if not winIpyData or not loseIpyData:
- GameWorld.ErrLog("跨服PK房间段位数据异常! roomID=%s,winnerDanLV=%s,loserDanLV=%s" % (roomID, winnerDanLV, loserDanLV))
-
- 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
-
- winnerAddScore = wBaseScore + wExScore
- loserAddScore = lBaseScore + lExScore
-
- dayMaxScore = IpyGameDataPY.GetFuncCfg("CrossRealmPKScore", 1) # 每日获得积分上限,0为不限制
- if dayMaxScore:
- if winnerAddScore > 0:
- winnerAddScore = min(dayMaxScore - winnerDayScore, winnerAddScore)
- if loserAddScore > 0:
- loserAddScore = min(dayMaxScore - loserDayScore, loserAddScore)
-
- winner.pkScore += winnerAddScore
- loser.pkScore += loserAddScore
-
- winner.cWinCount += 1
- loser.cWinCount = 0
-
- if winIpyData and winIpyData.GetLVUpScore() and winner.pkScore >= winIpyData.GetLVUpScore():
- winner.danLV += 1
-
- if loseIpyData and loseIpyData.GetLVUpScore() and loser.pkScore >= loseIpyData.GetLVUpScore():
- loser.danLV += 1
-
- 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)
-
- # 更新今日PK记录
- if winnerID not in PyGameData.g_crossPKTodayPKRecordInfo:
- PyGameData.g_crossPKTodayPKRecordInfo[winnerID] = []
- winnerPKRecordList = PyGameData.g_crossPKTodayPKRecordInfo[winnerID]
- winnerPKRecordList.append([loserID, winnerID])
-
- if loserID not in PyGameData.g_crossPKTodayPKRecordInfo:
- PyGameData.g_crossPKTodayPKRecordInfo[loserID] = []
- loserPKRecordList = PyGameData.g_crossPKTodayPKRecordInfo[loserID]
- loserPKRecordList.append([winnerID, winnerID])
- #GameWorld.DebugLog("PyGameData.g_crossPKTodayPKRecordInfo=%s" % PyGameData.g_crossPKTodayPKRecordInfo)
-
- timeStr = GameWorld.GetCurrentDataTimeStr()
- playerOverDict = {}
- # 通知客户端战斗结果
- for playerID in [winnerID, loserID]:
- if playerID == winnerID:
- serverGroupID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName = \
- winner.serverGroupID, winner.pkScore, winner.danLV, winner.cWinCount, winnerAddScore, loser.playerID, loser.playerName
- else:
- serverGroupID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName = \
- loser.serverGroupID, loser.pkScore, loser.danLV, loser.cWinCount, loserAddScore, winner.playerID, winner.playerName
-
- player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
- notifyState = True if player else False
-
- playerOverDict[playerID] = [roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList] \
- + [serverGroupID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState]
- if not player:
- continue
-
- overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
- overPack.TimeStr = timeStr
- overPack.OverType = overType
- overPack.WinnerID = winnerID
- overPack.RoundWinnerID = roundWinnerIDList
- overPack.RoundCount = len(overPack.RoundWinnerID)
- overPack.AddScore = addScore
- overPack.Score = pkScore
- overPack.DanLV = danLV
- overPack.CWinCnt = cWinCount
- overPack.TagName = tagPlayerName
- overPack.TagNameLen = len(overPack.TagName)
- NetPackCommon.SendFakePack(player, overPack)
-
- 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.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)
-
+ addScore = IpyGameDataPY.GetFuncCfg("CrossRealmPKScore2", 2) # 默认失败积分
if isWinner:
- winner, loser = pkPlayer, None
+ baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKScore2", 1)
+ baseScore = baseScoreList[matchIndex] if len(baseScoreList) > matchIndex else 0
+ wExScore = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKScore2", 3)) # 胜方附加分
+ addScore = baseScore + wExScore
+ cWinCount += 1
else:
- winner, loser = None, pkPlayer
+ cWinCount = 0
- # 更新排行榜
- UpdateCrossPKBillboard(zoneID, seasonID, winner, loser)
+ updScore = pkScore + addScore
+ pkDanIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
+ if pkDanIpyData and pkDanIpyData.GetLVUpScore() and updScore >= pkDanIpyData.GetLVUpScore():
+ danLV += 1
+
+ GameWorld.Log("结算跨服PK奖励: tagPlayerID=%s,isWinner=%s,pkScore=%s,cWinCount=%s,addScore=%s,updScore=%s,danLV=%s"
+ % (tagPlayerID, isWinner, pkScore, cWinCount, addScore, updScore, danLV), playerID)
- # PK机器人默认结果数据
- overType = 0
- roundWinnerIDList = []
- notifyState = False
- winnerID = winner.playerID if winner else 0
- tagPlayerID = 0
- tagPlayerName = ""
+ # 更新榜单
+ groupValue1, groupValue2 = zoneID, seasonID
+ name2, type2 = "", playerJob
+ value1, value2 = realmLV, danLV
+ cmpValue = updScore
+ CrossBillboard.UpdCrossBillboard(ShareDefine.Def_CBT_CrossRealmPK, groupValue1, playerID, playerName, name2, type2,
+ value1, value2, cmpValue, groupValue2=groupValue2, value3=face, value4=facePic)
+ # 通知子服
+ pkScore = updScore
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ tagPackObj = packDataMgr.GetPlayerPackObj(tagPlayerID)
+ tagPlayerName = tagPackObj.playerName if tagPackObj else ""
+ winnerID = playerID if isWinner else tagPlayerID
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))
- # 同步子服
+ playerOverDict[playerID] = [zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName]
+ serverGroupIDList = [serverGroupID]
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKOverInfo, playerOverDict, serverGroupIDList)
- if playerID not in PyGameData.g_crossPKTodayPKRecordInfo:
- PyGameData.g_crossPKTodayPKRecordInfo[playerID] = []
- pkRecordList = PyGameData.g_crossPKTodayPKRecordInfo[playerID]
- pkRecordList.append([0, winnerID])
- #GameWorld.DebugLog("PyGameData.g_crossPKTodayPKRecordInfo=%s" % PyGameData.g_crossPKTodayPKRecordInfo)
-
- # 记录流向
- dataDict = {"zoneID":zoneID, "seasonID":seasonID, "pkPlayer":pkPlayer.GetDRInfo()}
- DR_CrossReamlPK("PKOverRobot", dataDict)
+ # 系统重新刷新匹配
+ OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, True)
return
-def _GMSetCrossPK(serverGroupID, msgData):
- ## 收到子服GM同步的设置跨服PK数据
+def OnRefreshPKMatch(zoneID, seasonID, playerID, fightPower, serverGroupID, isRefresh):
+ # 刷新匹配数据
+ # @param isRefresh: 是否强制重新刷新
- if not GameWorld.IsCrossServer():
- GameWorld.ErrLog("GMSetCrossPK非跨服服务器不处理该跨服GM请求!")
+ if isRefresh or playerID not in PyGameData.g_crossPKMatchDict:
+ # 执行匹配逻辑
+ matchIDList = __DoPKMatch(zoneID, seasonID, playerID, fightPower)
+ if matchIDList: # 有新结果才替换
+ PyGameData.g_crossPKMatchDict[playerID] = matchIDList
+
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ matchIDList = PyGameData.g_crossPKMatchDict.get(playerID, [])
+ matchInfoDict = {}
+ for matchID in matchIDList:
+ packObj = packDataMgr.GetPlayerPackObj(matchID)
+ if not packObj:
+ continue
+ matchInfoDict[matchID] = packObj.GetBaseDict()
+
+ dataMsg = {"playerID":playerID, "matchIDList":matchIDList, "matchInfoDict":matchInfoDict}
+ CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PKMatchReqRet, dataMsg, [serverGroupID])
+ return
+
+def __DoPKMatch(zoneID, seasonID, playerID, fightPower):
+ ## 执行匹配
+
+ if not IsCrossRealmPKMatchState():
+ GameWorld.DebugLog("非匹配阶段,不允许刷新匹配! zoneID=%s,seasonID=%s" % (zoneID, seasonID), playerID)
return
+
+ matchCount = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch3", 1)
+ rankRange = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatch3", 2) # 名次范围段
+ totalRange = rankRange * matchCount # 总匹配名次范围
+
+ matchIDList = [] # 匹配ID结果列表
+
+ billboardType = ShareDefine.Def_CBT_CrossRealmPK
+ groupValue1, groupValue2 = zoneID, seasonID
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
+ billDataCount = billboardObj.GetCount()
+ playerBillIndex = billboardObj.IndexOfByID(playerID)
+
+ GameWorld.DebugLog("===执行匹配: zoneID=%s,seasonID=%s,playerID=%s,fightPower=%s,playerBillIndex=%s,matchCount=%s"
+ % (zoneID, seasonID, playerID, fightPower, playerBillIndex, matchCount), playerID)
+ if playerBillIndex <= 0:
+ playerBillIndex = billDataCount
+ GameWorld.DebugLog("玩家未上积分榜,视为排在榜上最后一名之后! playerBillIndex=%s" % playerBillIndex, playerID)
+ billStartIndex = max(0, playerBillIndex - totalRange / 2) # 以自己的排名为中心索引
+ billLoopIndexList = range(billStartIndex, billStartIndex + totalRange + 1)
+ if playerBillIndex in billLoopIndexList:
+ billLoopIndexList.remove(playerBillIndex) # 移除自己
+ loopBillPlayerIDList = []
+ for index in billLoopIndexList:
+ if index >= billDataCount:
+ break
+ billData = billboardObj.At(index)
+ loopBillPlayerIDList.append(int(billData.ID))
+ GameWorld.DebugLog("积分榜可匹配的排名玩家ID列表: %s,%s" % (len(loopBillPlayerIDList), loopBillPlayerIDList), playerID)
+ randPackPlayerIDList = None # 可随机匹配的打包数据战力排名玩家ID列表
+
+ for matchIndex in range(matchCount):
+ GameWorld.DebugLog("匹配第%s个: matchIndex=%s,playerBillIndex=%s,billLoopIndexList=%s" % (matchIndex + 1, matchIndex, playerBillIndex, billLoopIndexList), playerID)
+ matchID = 0
+ randIDList = []
+ # 1. 优先赛季积分排行榜
+ if billDataCount:
+ __addRandMatchID(playerID, matchIndex, rankRange, randIDList, matchIDList, loopBillPlayerIDList, 1)
+
+ # 有需要用到战力匹配的,加载一次
+ if not randIDList and randPackPlayerIDList == None:
+ zonePackPlayerIDList = __getZonePackPlayerIDList(zoneID, playerID)
+ playerPackIndex = -1
+ randPackPlayerIDList = []
+ if playerID in zonePackPlayerIDList:
+ playerPackIndex = zonePackPlayerIDList.index(playerID)
+ startIndex = max(0, playerPackIndex - totalRange / 2) # 以自己的排名为中心索引
+ randPackPlayerIDList = [int(packID) for packID in zonePackPlayerIDList[startIndex:totalRange + 1]] # 因为包含自己,所以加1
+ if playerID in randPackPlayerIDList:
+ randPackPlayerIDList.remove(playerID) # 移除自己
+ GameWorld.DebugLog(" 赛区战力榜玩家排名: playerPackIndex=%s,%s,%s" % (playerPackIndex, len(zonePackPlayerIDList), zonePackPlayerIDList), playerID)
+ GameWorld.DebugLog(" 赛区战力榜随机玩家: %s,%s" % (len(randPackPlayerIDList), randPackPlayerIDList), playerID)
+
+ # 2. 该范围段没有的话匹配打包数据战力榜
+ if not randIDList and randPackPlayerIDList:
+ __addRandMatchID(playerID, matchIndex, rankRange, randIDList, matchIDList, randPackPlayerIDList, 2)
+
+ if randIDList:
+ matchID = random.choice(randIDList)
+
+ # 3. 最终还没有,直接机器人
+ if not matchID:
+ matchID = matchIndex + 1 # 机器人ID固定为 matchIndex + 1
+ matchIDList.append(matchID)
+ GameWorld.DebugLog(" 本段随机匹配结果: matchIndex=%s,matchID=%s,randIDList=%s,matchIDList=%s" % (matchIndex, matchID, randIDList, matchIDList), playerID)
+
+ GameWorld.DebugLog("最终匹配结果: matchIDList=%s" % str(matchIDList), playerID)
+ return matchIDList
+
+def __addRandMatchID(playerID, matchIndex, rankRange, randIDList, matchIDList, loopPlayerIDList, sign):
+ ## 根据所有可循环玩家ID列表,添加对应匹配轮次可随机匹配的玩家
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ indexStart = matchIndex * rankRange
+ indexEnd = indexStart + rankRange - 1
+ loopIDCount = len(loopPlayerIDList)
+ if sign == 1:
+ GameWorld.DebugLog(" 匹配赛区积分榜: matchIndex=%s,loopIndex=%s~%s,loopIDCount=%s" % (matchIndex, indexStart, indexEnd, loopIDCount), playerID)
+ else:
+ GameWorld.DebugLog(" 匹配赛区战力榜: matchIndex=%s,loopIndex=%s~%s,loopIDCount=%s" % (matchIndex, indexStart, indexEnd, loopIDCount), playerID)
+ for index in range(indexStart, indexEnd + 1):
+ if index >= loopIDCount:
+ break
+ dataID = loopPlayerIDList[index]
+ if not dataID or dataID == playerID or dataID in randIDList:
+ GameWorld.DebugLog(" 不可匹配空或自己或已添加: dataID=%s,randIDList=%s" % (dataID, randIDList), playerID)
+ continue
+ if dataID in matchIDList:
+ GameWorld.DebugLog(" 不可添加已匹配过玩家: dataID=%s,randIDList=%s,matchIDList=%s" % (dataID, randIDList, matchIDList), playerID)
+ continue
+ if not packDataMgr.IsPlayerIn(dataID):
+ GameWorld.DebugLog(" 不匹配无打包数据玩家: dataID=%s,randIDList=%s" % (dataID, randIDList), playerID)
+ continue
+ randIDList.append(dataID)
+ GameWorld.DebugLog(" 添加可以随机匹配玩家: dataID=%s,randIDList=%s" % (dataID, randIDList), playerID)
+
+ return
+
+def __getZonePackPlayerIDList(zoneID, playerID):
+ ## 获取分区打包数据玩家ID列表
+ crossZoneName = GameWorld.GetCrossZoneName()
+ zoneIpyData = IpyGameDataPY.GetIpyGameData("CrossZonePK", crossZoneName, zoneID)
+ if zoneIpyData:
+ packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
+ packDataMgr.Sort()
+ serverIDList = zoneIpyData.GetServerGroupIDList()
+ zonePackPlayerIDList = packDataMgr.GetPlayerIDListByServerIDInfo(zoneIpyData.GetServerGroupIDList())
+ GameWorld.DebugLog(" 获得赛区活跃打包数据玩家: zoneID=%s,serverIDList=%s,%s,%s"
+ % (zoneID, serverIDList, len(zonePackPlayerIDList), zonePackPlayerIDList), playerID)
+ return zonePackPlayerIDList
+ return []
+
+def ClientServerMsg_PKBillboard(serverGroupID, msgData):
+ ## 收到子服GM同步的设置跨服PK数据
zoneID = msgData["ZoneID"]
seasonID = msgData["SeasonID"]
@@ -1833,45 +680,21 @@
playerJob = playerInfoDict["playerJob"]
face = playerInfoDict.get("face", 0)
facePic = playerInfoDict.get("facePic", 0)
- fightPower = playerInfoDict["fightPower"]
realmLV = playerInfoDict["realmLV"]
pkScore = playerInfoDict["pkScore"]
danLV = playerInfoDict["danLV"]
cWinCount = playerInfoDict["cWinCount"]
- ondayScore = playerInfoDict["ondayScore"]
-
- zoneMatchPlayerList = PyGameData.g_crossPKZoneMatchPlayerDict.get(zoneID, [])
- if playerID in zoneMatchPlayerList or playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict or playerID in PyGameData.g_crossPKZoneMatchRobotPlayerDict:
- GameWorld.ErrLog("GMSetCrossPK玩家正在匹配中,无法设置该GM请求数据! playerID=%s,accID=%s" % (playerID, accID))
- return
-
- pkPlayer = CrossPKPlayer()
- pkPlayer.accID = accID
- pkPlayer.playerID = playerID
- pkPlayer.playerName = playerName
- pkPlayer.playerJob = playerJob
- pkPlayer.face = face
- pkPlayer.facePic = facePic
- pkPlayer.pkScore = pkScore
- pkPlayer.danLV = danLV
- pkPlayer.fightPower = fightPower
- pkPlayer.realmLV = realmLV
- pkPlayer.cWinCount = cWinCount
- pkPlayer.ondayScore = ondayScore
- pkPlayer.serverGroupID = serverGroupID
- pkPlayer.pkZoneID = zoneID
- pkPlayer.seasonID = seasonID
# 更新排行榜
- isOK = UpdateCrossPKBillboard(zoneID, seasonID, pkPlayer, None, True)
- GameWorld.Log("GMSetCrossPK设置跨服PK榜单玩家数据成功: isOK=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s,accID=%s"
+ groupValue1, groupValue2 = zoneID, seasonID
+ name2, type2 = "", playerJob
+ value1, value2 = realmLV, danLV
+ cmpValue = pkScore
+ isOK = CrossBillboard.UpdCrossBillboard(ShareDefine.Def_CBT_CrossRealmPK, groupValue1, playerID, playerName, name2, type2,
+ value1, value2, cmpValue, groupValue2=groupValue2, value3=face, value4=facePic)
+ GameWorld.Log("GM设置跨服PK榜单玩家数据: isOK=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s,accID=%s"
% (isOK, zoneID, seasonID, pkScore, danLV, cWinCount, accID), playerID)
-
- # 记录流向
- dataDict = {"zoneID":zoneID, "seasonID":seasonID, "pkPlayer":pkPlayer.GetDRInfo()}
- DR_CrossReamlPK("GMSet", dataDict)
return
-
##================================== 以下是子服逻辑 ==========================================
def OnGameServerInitOK():
@@ -1981,160 +804,38 @@
def CrossServerMsg_PKMatchReqRet(retInfo):
## 跨服PK匹配请求结果
- playerID, result = retInfo
+ playerID = retInfo["playerID"]
+ matchIDList = retInfo["matchIDList"]
+ matchInfoDict = retInfo["matchInfoDict"]
+
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
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)
- startMatchPack.IsRobot = 0
- elif result == 2:
- SetIsCrossPKMatching(curPlayer, 0)
- startMatchPack.IsRobot = 1
-
- NetPackCommon.SendFakePack(curPlayer, startMatchPack)
+ matchOKPack = ChPyNetSendPack.tagGCCrossRealmPKMatchOK()
+ matchOKPack.MatchPlayer = []
+ for matchID in matchIDList:
+ matchPlayer = ChPyNetSendPack.tagGCCrossRealmPKMatchPlayer()
+ if matchID not in matchInfoDict:
+ matchPlayer.PlayerID = matchID
+ matchOKPack.MatchPlayer.append(matchPlayer)
+ continue
+ matchInfo = matchInfoDict[matchID]
+ matchPlayer.PlayerID = matchInfo["playerID"]
+ matchPlayer.PlayerName = matchInfo["playerName"]
+ matchPlayer.NameLen = len(matchPlayer.PlayerName)
+ matchPlayer.Job = matchInfo["job"]
+ matchPlayer.LV = matchInfo["lv"]
+ matchPlayer.RealmLV = matchInfo["realmLV"]
+ matchPlayer.Face = matchInfo["face"]
+ matchPlayer.FacePic = matchInfo["facePic"]
+ matchPlayer.FightPower = matchInfo["fightPower"] % ChConfig.Def_PerPointValue
+ matchPlayer.FightPowerEx = matchInfo["fightPower"] / ChConfig.Def_PerPointValue
+ matchOKPack.MatchPlayer.append(matchPlayer)
+ matchOKPack.MatchPlayerCount = len(matchOKPack.MatchPlayer)
+ NetPackCommon.SendFakePack(curPlayer, matchOKPack)
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()
- mapPosList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKMatch", 5)
- GameWorld.DebugLog("=== 收到PK匹配结果处理 === curServerGroupID=%s" % curServerGroupID)
- if not mapPosList:
- GameWorld.ErrLog("没有配置对战地图进入坐标!")
- return
-
- for roomID, roomInfo in vsRoomDict.items():
- mapID, playerList = roomInfo
- GameWorld.DebugLog(" roomID=%s,playerList=%s" % (roomID, playerList))
- for i, playerInfo in enumerate(playerList):
- serverGroupID, playerID = playerInfo
- if serverGroupID != curServerGroupID:
- GameWorld.DebugLog(" 不是本服玩家,不处理!playerID=%s,serverGroupID=%s" % (playerID, serverGroupID))
- continue
- player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
- if not player:
- GameWorld.DebugLog(" 玩家不在线, playerID=%s" % (playerID))
- continue
- if PlayerControl.GetIsTJG(player):
- GameWorld.DebugLog(" 玩家脱机中, playerID=%s" % (playerID))
- continue
- PlayerControl.SetVsRoomId(player, roomID, True)
- # 通知地图玩家匹配成功, 上传数据, 准备进入跨服服务器
- posX, posY = mapPosList[i] if len(mapPosList) > i else mapPosList[0]
- CrossRealmPlayer.SendCrossRealmReg(player, ChConfig.Def_FBMapID_CrossRealmPK, mapID, mapID, 0, posX, posY)
-
- return
-
-def CrossServerMsg_PKReadyOKRoomList(readyOKRoomList):
- ## 子服接收玩家已准备好的PK房间信息, 此房间里的玩家可传送进入跨服
-
- curServerGroupID = GameWorld.GetServerGroupID()
- 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))
- continue
-
- player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
- if not player:
- GameWorld.DebugLog(" 玩家不在线 , playerID=%s" % (playerID))
- continue
- if PlayerControl.GetIsTJG(player):
- GameWorld.DebugLog(" 玩家脱机中, playerID=%s" % (playerID))
- continue
- player.SetDict(ChConfig.Def_PlayerKey_IsLoginToMergeServer, 1)
-
- matchPlayer = ChPyNetSendPack.tagGCCrossRealmPKMatchPlayer()
- for readyPlayerID, readyPlayerInfo in readyMemberDict.items():
- if readyPlayerID != playerID:
- matchPlayer.PlayerID = readyPlayerID
- matchPlayer.PlayerName = readyPlayerInfo["Name"]
- matchPlayer.NameLen = len(matchPlayer.PlayerName)
- matchPlayer.Job = readyPlayerInfo["Job"]
- matchPlayer.LV = readyPlayerInfo["LV"]
- matchPlayer.Face = readyPlayerInfo["Face"]
- matchPlayer.FacePic = readyPlayerInfo["FacePic"]
- matchPlayer.MaxHP = readyPlayerInfo["MaxHP"] % ShareDefine.Def_PerPointValue
- matchPlayer.MaxHPEx = readyPlayerInfo["MaxHP"] / ShareDefine.Def_PerPointValue
- matchPlayer.MaxProDef = readyPlayerInfo["MaxProDef"]
- break
-
- 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.DebugLog(" 通知玩家进入跨服PK对战房间! roomID=%s,playerID=%s,matchPlayerID=%s" % (roomID, playerID, matchPlayer.PlayerID))
-
- return
-
-def CrossServerMsg_PKTimeoutRoomList(timeoutRoomDict):
- ## 子服接收已超时的PK房间信息, 此房间里的玩家重置跨服状态
-
- curServerGroupID = GameWorld.GetServerGroupID()
- GameWorld.DebugLog("===收到跨服服务器通知已超时的对战PK房间信息处理=== curServerGroupID=%s" % curServerGroupID)
-
- for roomID, roomPlayerInfo in timeoutRoomDict.items():
- if not roomPlayerInfo:
- continue
- serverGroupID, playerID = roomPlayerInfo
-
- if serverGroupID != curServerGroupID:
- GameWorld.DebugLog(" 不是本服玩家,不处理!playerID=%s,serverGroupID=%s" % (playerID, serverGroupID))
- continue
-
- player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
- if not player:
- GameWorld.DebugLog(" 玩家不在线 , playerID=%s" % (playerID))
- continue
- if PlayerControl.GetIsTJG(player):
- GameWorld.DebugLog(" 玩家脱机中, playerID=%s" % (playerID))
- continue
- playerVSRoomID = player.GetVsRoomId()
- if playerVSRoomID and playerVSRoomID != roomID:
- GameWorld.DebugLog(" 房间ID不同, playerID=%s" % (playerID))
- continue
- player.SetDict(ChConfig.Def_PlayerKey_IsLoginToMergeServer, 0)
- PlayerControl.SetCrossMapID(player, 0)
-
- return
#跨服竞技场未通知玩家的比赛结果,注意该类只处理数据逻辑,功能相关逻辑不要写在该类,不然重读脚本不会生效
class CrossPKUnNotifyOverInfoManager(object):
@@ -2181,28 +882,24 @@
GameWorld.DebugLog("===收到跨服服务器同步的跨服PK结果=== curServerGroupID=%s" % curServerGroupID)
for playerID, overInfo in playerOverDict.items():
- roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, \
- serverGroupID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState = overInfo
- if serverGroupID != curServerGroupID:
- GameWorld.DebugLog(" 不是本服玩家,不处理!playerID=%s,serverGroupID=%s" % (playerID, serverGroupID))
+ zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName = overInfo
+ if not PlayerControl.GetDBPlayerAccIDByID(playerID):
+ GameWorld.DebugLog(" 不是本服玩家,不处理! playerID=%s" % (playerID))
continue
- 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.DebugLog(" 玩家不在线 或脱机中,先缓存,玩家上线后再同步,playerID=%s" % (playerID))
overInfoData = PyGameDataStruct.tagDBCrossPKUnNotifyOverInfo()
overInfoData.clear()
overInfoData.ZoneID = zoneID
overInfoData.SeasonID = seasonID
- overInfoData.RoomID = roomID
+ overInfoData.RoomID = 0
overInfoData.TimeStr = timeStr
- overInfoData.OverType = overType
+ overInfoData.OverType = 0
overInfoData.PlayerID = playerID
overInfoData.WinnerID = winnerID
- overInfoData.RoundWinnerInfo = str(roundWinnerIDList)
+ overInfoData.RoundWinnerInfo = str([])
overInfoData.RoundWinnerLen = len(overInfoData.RoundWinnerInfo)
overInfoData.PKScore = pkScore
overInfoData.DanLV = danLV
@@ -2213,11 +910,10 @@
PyDataManager.GetCrossPKUnNotifyOverInfoManager().AddUnNotifyOverInfo(playerID, overInfoData)
continue
- PlayerControl.SetVsRoomId(player, 0)
- sysMsg = str(sendMapOverInfo)
+ sysMsg = str(overInfo)
player.MapServer_QueryPlayerResult(0, 0, "CrossPKOverInfo", sysMsg, len(sysMsg))
- 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)
+ GameWorld.DebugLog("通知地图跨服PK结算: zoneID=%s,seasonID=%s,timeStr=%s,winnerID=%s, pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,mapID=%s"
+ % (zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID, player.GetMapID()), playerID)
return
def __OnLoginNotifyPKOverInfo(curPlayer):
@@ -2225,33 +921,20 @@
overInfoData = PyDataManager.GetCrossPKUnNotifyOverInfoManager().GetPlayerUnNotifyOverInfo(playerID)
if not overInfoData:
return
- 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)
+ sysMsg = str([zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName])
curPlayer.MapServer_QueryPlayerResult(0, 0, "CrossPKOverInfo", sysMsg, len(sysMsg))
- 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)
+ GameWorld.DebugLog("玩家上线通知地图未结算的跨服PK结算: zoneID=%s,seasonID=%s,timeStr=%s,winnerID=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,mapID=%s"
+ % (zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID, curPlayer.GetMapID()), playerID)
return
def DR_CrossReamlPK(eventName, dataDict={}):
@@ -2259,31 +942,3 @@
drDataDict.update(dataDict)
DataRecordPack.SendEventPack("CrossPK_%s" % eventName, drDataDict)
return
-
-def IsCrossRealmPKPlayer(playerID, checkPreSeason=False, checkAllSeason=False):
- ## 仅跨服服务器判断用
- # @param checkPreSeason: 检查上一赛季
- # @param checkAllSeason: 检查所有赛季
-
- # 默认取分区1的赛季作为当前赛季,所有分区赛季ID相同,且递增
- gameWorld = GameWorld.GetGameWorld()
- nowSeasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % 1)
- preSeasonID = nowSeasonID - 1
- crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()
- crossZoneName = GameWorld.GetCrossZoneName()
- ipyDataMgr = IpyGameDataPY.IPY_Data()
- for index in range(ipyDataMgr.GetCrossRealmPKSeasonCount()):
- seasonIpyData = ipyDataMgr.GetCrossRealmPKSeasonByIndex(index)
- if crossZoneName != seasonIpyData.GetCrossZoneName():
- continue
- zoneID = seasonIpyData.GetZoneID()
- seasonID = seasonIpyData.GetSeasonID()
- if checkAllSeason or seasonID == nowSeasonID or (checkPreSeason and seasonID == preSeasonID):
- pass
- else:
- continue
- _, orderDict = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, seasonID)
- if orderDict and playerID in orderDict:
- return True
-
- return False
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldProcess.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldProcess.py
index d20a603..a566574 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldProcess.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldProcess.py
@@ -316,8 +316,6 @@
PlayerFamily.OnLeaderImpeachTick(tick)
#跨服玩家
CrossRealmPlayer.OnCrossProcess(tick)
- #跨服PK匹配
- CrossRealmPK.OnPKMatchProcess(tick)
GameWorldBoss.DoCheckWorldBossReborn(tick)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
index 16a2c76..6b8a544 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/ChPlayer.py
@@ -179,8 +179,6 @@
''' 玩家登录需要处理的内容,本服及跨服服务器分开
'''
if GameWorld.IsCrossServer():
- #跨服PK
- CrossRealmPK.OnPlayerLoginCrossServer(curPlayer)
#协助
PlayerAssist.OnPlayerLoginCrossServer(curPlayer)
return
@@ -641,9 +639,6 @@
PlayerFB.OnPlayerDisconnectCrossServer(curPlayer)
return
- #跨服匹配PK
- CrossRealmPK.OnLeaveServer(curPlayer)
-
#组队玩家离线
PlayerTeam.DoPlayerLogOffTeamLogic(curPlayer, tick)
#家族玩家离线
@@ -709,11 +704,8 @@
# 上线
if isOnline:
- # 需要管理跨服在线状态时,默认需要同步缓存信息
- syncStateInfo = {"playerID":playerID, "ViewCacheCross":1}
- packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
- if playerID in packDataMgr.playerPackDataDict:
- syncStateInfo["PackDataCross"] = 1
+ # 需要管理跨服在线状态时,默认需要同步缓存信息、打包数据信息
+ syncStateInfo = {"playerID":playerID, "ViewCacheCross":1, "PackDataCross":1}
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PlayerPackDataState, syncStateInfo, [serverGroupID])
GameXiangong.OnPlayerLogin_CrossLogic(serverGroupID, serverID, playerID)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
index 9a0007d..7dbf112 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/CrossRealmPlayer.py
@@ -241,21 +241,7 @@
# 跨服PK上传数据完毕,通知跨服服务器,准备完毕
if registerMap == ChConfig.Def_FBMapID_CrossRealmPK:
- regVSRoomID = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MergeRegisterRoomID)
- vsRoomID = curPlayer.GetVsRoomId()
-
- if regVSRoomID != vsRoomID:
- GameWorld.Log("上传跨服服务器的 regVSRoomID=%s 与玩家当前的 roomID=%s 不同!不发送准备完毕!"
- % (regVSRoomID, vsRoomID), playerID)
- return
-
- dataMsg = {
- "accID":curPlayer.GetAccID(), # 角色账号ID
- "playerID":playerID, # 角色ID
- "vsRoomID":vsRoomID, # 所属对战房间ID
- }
- CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKPrepareOK, dataMsg)
- GameWorld.Log("通知跨服服务器, 玩家匹配PK准备完毕!%s" % str(dataMsg), playerID)
+ pass
# 其他的,在上传数据完毕后,使用通用的通知可进入跨服
else:
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py
index 8ec303d..56ab2e5 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerPackData.py
@@ -33,6 +33,7 @@
import PyDataManager
import PlayerViewCache
import PyGameDataStruct
+import CrossChampionship
import CrossRealmMsg
import PlayerControl
import ShareDefine
@@ -40,7 +41,68 @@
import ChConfig
import time
+import base64
+TempDBPlayer = PyGameDataStruct.tagDBPlayer()
+
+def GetDBPlayerByPackData(packData):
+ ## 根据 curPlayer.GetPackData() 打包返回的数据获取DBPlayer数据
+ TempDBPlayer.clear()
+ if packData:
+ TempDBPlayer.readData(base64.b64decode(packData))
+ return TempDBPlayer
+
+class PlayerPackDataObj():
+
+ def __init__(self):
+ self.dbPlayerPackData = None
+ self.playerID = 0
+ self.playerName = ""
+ self.accID = ""
+ self.lv = 0
+ self.job = 0
+ self.realmLV = 0
+ self.face = 0
+ self.facePic = 0
+ self.fightPower = 0
+ self.serverID = 0
+ return
+
+ def GetBaseDict(self):
+ return {"playerID":self.playerID, "playerName":self.playerName, "lv":self.lv, "job":self.job,
+ "realmLV":self.realmLV, "face":self.face, "facePic":self.facePic, "fightPower":self.fightPower}
+
+ def UpdPackData(self, packData):
+ if not packData:
+ return
+ if not self.dbPlayerPackData:
+ self.dbPlayerPackData = PyGameDataStruct.tagDBPlayerPackData()
+ self.dbPlayerPackData.PlayerID = self.playerID
+ self.dbPlayerPackData.PackData = packData
+ self.dbPlayerPackData.PackDataSize = len(self.dbPlayerPackData.PackData)
+ self.dbPlayerPackData.UpdTime = int(time.time())
+ self.Unpack()
+ return
+
+ def Unpack(self):
+ if not self.dbPlayerPackData:
+ return
+ dbPlayer = GetDBPlayerByPackData(self.dbPlayerPackData.PackData)
+ self.playerID = dbPlayer.PlayerID
+ self.accID = dbPlayer.AccID
+ self.playerName = dbPlayer.PlayerName
+ self.lv = dbPlayer.LV
+ self.job = dbPlayer.Job
+ self.realmLV = dbPlayer.OfficialRank
+ self.face = dbPlayer.Face
+ self.facePic = dbPlayer.FacePic
+ self.fightPower = dbPlayer.FightPowerEx * ChConfig.Def_PerPointValue + dbPlayer.FightPower
+ self.serverID = GameWorld.GetAccIDServerID(self.accID)
+ return
+
+ def GetPackData(self): return self.dbPlayerPackData.PackData if self.dbPlayerPackData else ""
+ def GetUpdTime(self): return self.dbPlayerPackData.UpdTime if self.dbPlayerPackData else 0
+
class DBPlayerPackDataManager():
## 玩家打包数据管理
@@ -49,26 +111,92 @@
return
def Clear(self):
- self.playerPackDataDict = {} # {playerID:tagDBPlayerPackData, ...}
+ self.__packDataList = [] # [PlayerPackDataObj, ...]
+ self.__idIndexDict = {} # {playerID:index, ...}
+ self.__needSort = False
+ self.__serverIDRangePlayerIDDict = {} # {serverIDRangeTuple:[playerID, ...], ....}
return
def GetPlayerPackObj(self, playerID, isAddNew=False):
packDataObj = None
- if playerID in self.playerPackDataDict:
- packDataObj = self.playerPackDataDict[playerID]
- elif isAddNew:
- packDataObj = PyGameDataStruct.tagDBPlayerPackData()
- packDataObj.PlayerID = playerID
- self.playerPackDataDict[playerID] = packDataObj
+ self.__refreshIDIndex()
+ if playerID in self.__idIndexDict:
+ index = self.__idIndexDict[playerID]
+ if index < len(self.__packDataList):
+ packDataObj = self.__packDataList[index]
+
+ if not packDataObj and isAddNew:
+ packDataObj = PlayerPackDataObj()
+ packDataObj.playerID = playerID
+ self.__packDataList.append(packDataObj)
+ self.__idIndexDict[playerID] = len(self.__packDataList) - 1
+ self.__needSort = True
+
return packDataObj
+
+ def GetPlayerIDListByServerIDInfo(self, serverIDList):
+ ## 根据服务器ID列表信息获取对应服务器ID范围的玩家ID战力排序列表
+ self.Sort()
+ key = tuple(serverIDList)
+ if key not in self.__serverIDRangePlayerIDDict:
+ playerIDList = []
+ for dataObj in self.__packDataList:
+ playerID = dataObj.playerID
+ serverID = dataObj.serverID
+ for idInfo in serverIDList:
+ if (isinstance(idInfo, int) and serverID == idInfo) \
+ or ((isinstance(idInfo, tuple) or isinstance(idInfo, list)) \
+ and len(idInfo) == 2 and idInfo[0] <= serverID <= idInfo[1]):
+ playerIDList.append(playerID)
+ GameWorld.DebugLog("重新加载区服打包玩家ID列表: %s, %s, %s" % (key, len(playerIDList), playerIDList))
+ self.__serverIDRangePlayerIDDict[key] = playerIDList
+ return self.__serverIDRangePlayerIDDict[key]
+
+ def IsPlayerIn(self, playerID):
+ self.__refreshIDIndex()
+ return playerID in self.__idIndexDict
+
+ def __refreshIDIndex(self):
+ if not self.__idIndexDict:
+ self.__idIndexDict = {}
+ for index, dataObj in enumerate(self.__packDataList):
+ self.__idIndexDict[dataObj.playerID] = index
+ return self.__idIndexDict
def UpdPlayerPackData(self, playerID, packData):
if not packData:
return
packObj = self.GetPlayerPackObj(playerID, True)
- packObj.UpdTime = int(time.time())
- packObj.PackData = packData
- packObj.PackDataSize = len(packObj.PackData)
+ packObj.UpdPackData(packData)
+ self.__needSort = True
+ return packObj
+
+ def DelPlayerPackData(self, playerID):
+ self.__refreshIDIndex()
+ index = self.__idIndexDict.pop(playerID, -1)
+ if index >= 0 and index < len(self.__packDataList):
+ self.__packDataList.pop(index)
+ for playerIDList in self.__serverIDRangePlayerIDDict.values():
+ if playerID in playerIDList:
+ playerIDList.remove(playerID)
+ return
+
+ def GetCount(self): return len(self.__packDataList)
+ def At(self, index):
+ dataObj = self.__packDataList[index]
+ if not dataObj and False:
+ dataObj = PlayerPackDataObj() # 不会执行到,只为了.出代码提示
+ return dataObj
+
+ def Sort(self):
+ ## 默认按战力倒序排
+ if not self.__needSort:
+ return
+ self.__needSort = False
+ self.__packDataList.sort(key=lambda d: (d.fightPower), reverse=True)
+ self.__idIndexDict = {}
+ self.__serverIDRangePlayerIDDict = {}
+ self.__refreshIDIndex()
return
# 保存数据 存数据库和realtimebackup
@@ -77,9 +205,12 @@
cntData = ""
cnt = 0
- for dbData in self.playerPackDataDict.values():
+ for index in xrange(self.GetCount()):
+ dataObj = self.At(index)
+ if not dataObj.dbPlayerPackData:
+ continue
cnt += 1
- savaData += dbData.getBuffer()
+ savaData += dataObj.dbPlayerPackData.getBuffer()
GameWorld.Log("Save DBPlayerPackData count :%s len=%s" % (cnt, len(savaData)))
return CommFunc.WriteDWORD(cntData, cnt) + savaData
@@ -94,9 +225,13 @@
for _ in xrange(cnt):
dbData = PyGameDataStruct.tagDBPlayerPackData()
pos += dbData.readData(datas, pos, dataslen)
+ playerID = dbData.PlayerID
- self.playerPackDataDict[dbData.PlayerID] = dbData
+ packObj = self.GetPlayerPackObj(playerID, True)
+ packObj.dbPlayerPackData = dbData
+ packObj.Unpack()
+ self.Sort()
return pos
def IsSaveDB(packDataObj):
@@ -104,13 +239,39 @@
if not packDataObj:
return False
- # 功能固定需要的
- # ...
+ playerID = packDataObj.playerID
+
+ if CrossChampionship.IsChampionshipPlayer(playerID):
+ return True
+
+ #跨服榜单上的默认保留
+ if GameWorld.IsCrossServer():
+ billboardMgr = PyDataManager.GetCrossBillboardManager()
+ for billboardType in ShareDefine.CrossBillboardTypeList:
+ groupList = billboardMgr.GetBillboardGroupList(billboardType)
+ for billboardType, groupValue1, groupValue2 in groupList:
+ billboardObj = billboardMgr.GetCrossBillboard(billboardType, groupValue1, groupValue2)
+ if billboardObj.FindByID(playerID):
+ return True
+
+ else:
+ pass
+# NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2)
+# #校验玩家是否上排行榜
+# billboardMgr = GameWorld.GetBillboard()
+# for BillBoardType in NeedCheckBillBoardType:
+# curBillboard = billboardMgr.FindBillboard(BillBoardType)
+# if not curBillboard:
+# continue
+# if curBillboard.FindByID(playerID):
+# return True
+
+ # 以上是相关功能需要用到的数据,必定不能删除的
maxDays = 7 # 默认7天
MaxTime = maxDays * 3600 * 24
curTime = int(time.time())
- passTime = curTime - packDataObj.UpdTime
+ passTime = curTime - packDataObj.GetUpdTime()
if passTime < MaxTime:
return True
@@ -120,22 +281,22 @@
## 删除过期
packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
- playerPackDataDict = packDataMgr.playerPackDataDict
- for playerID, packDataObj in playerPackDataDict.items():
+ for index in range(packDataMgr.GetCount())[::-1]: # 可能删数据,倒序遍历
+ packDataObj = packDataMgr.At(index)
if IsSaveDB(packDataObj):
continue
- playerPackDataDict.pop(playerID)
+ packDataMgr.DelPlayerPackData(packDataObj.playerID)
return
def IsPackDataPlayer(playerID):
- return playerID in PyDataManager.GetDBPlayerPackDataManager().playerPackDataDict
+ return PyDataManager.GetDBPlayerPackDataManager().IsPlayerIn(playerID)
def OnPlayerLogin(curPlayer):
## 本服登录逻辑
playerID = curPlayer.GetPlayerID()
packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
- if playerID in packDataMgr.playerPackDataDict:
+ if packDataMgr.IsPlayerIn(playerID):
QueryPlayerResult_PlayerMirror(curPlayer, "PackDataSyncState", {"PackData":1})
return
@@ -148,7 +309,7 @@
pullPlayerIDList = []
packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
for playerID in playerIDList:
- if playerID in packDataMgr.playerPackDataDict:
+ if packDataMgr.IsPlayerIn(playerID):
continue
pullPlayerIDList.append(playerID)
@@ -303,15 +464,13 @@
pullPlayerIDList = msgData["pullPlayerIDList"]
otherServerPlayerIDList = []
- packDataDict = {}
packDataMgr = PyDataManager.GetDBPlayerPackDataManager()
for playerID in pullPlayerIDList:
packObj = packDataMgr.GetPlayerPackObj(playerID)
# 已经有的数据先推送回去
if packObj:
GameWorld.DebugLog("跨服有缓存玩家打包数据,直接推给子服! playerID=%s" % playerID)
- packDataDict[playerID] = packObj.PackData
- dataMsg = {"playerID":playerID, "packData":packObj.PackData, "msgInfo":msgInfo}
+ dataMsg = {"playerID":playerID, "packData":packObj.GetPackData(), "msgInfo":msgInfo}
CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_PushPlayerPackData, dataMsg, [serverGroupID])
else:
otherServerPlayerIDList.append(playerID)
@@ -345,7 +504,7 @@
packObj = packDataMgr.GetPlayerPackObj(playerID)
if packObj:
GameWorld.DebugLog("本服有缓存玩家打包数据,直接推给跨服! playerID=%s" % playerID)
- dataMsg = {"playerID":playerID, "packData":packObj.PackData, "msgInfo":msgInfo}
+ dataMsg = {"playerID":playerID, "packData":packObj.GetPackData(), "msgInfo":msgInfo}
CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PlayerPackData, dataMsg)
else:
DoPullPlayerPackData(playerID, msgInfo)
@@ -421,7 +580,7 @@
for mirrorID in mirrorIDList:
packObj = packDataMgr.GetPlayerPackObj(mirrorID)
if packObj:
- packDataDict[mirrorID] = packObj.PackData
+ packDataDict[mirrorID] = packObj.GetPackData()
continue
pullPlayerIDList.append(mirrorID)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerQuery.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerQuery.py
index d43110f..fd732aa 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerQuery.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerQuery.py
@@ -650,24 +650,6 @@
CrossChampionship.MapServer_CrossChampionshipPKOver(eval(resultName), tick)
return
- #跨服匹配PK战斗结算
- if callName == "CrossPKOver":
- CrossRealmPK.MapServer_CrossPKOver(eval(resultName), tick)
- return
-
- #跨服匹配房间开启
- if callName == "CrossPKRoomOpen":
- CrossRealmPK.MapServer_CrossPKRoomOpen(eval(resultName), tick)
- return
-
- #跨服匹配PK取消匹配
- if callName == "CrossRealmPKCancel":
- curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(srcPlayerID)
- if not curPlayer:
- return
- CrossRealmPK.SendCancelCrossRealmPKMatch(curPlayer, resultName)
- return
-
#跨服PK请求玩家当前排名
if callName == "CrossPKSeasonOrder":
curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(srcPlayerID)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
index fe2a47d..024a33c 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerViewCache.py
@@ -36,7 +36,6 @@
import IpyGameDataPY
import PyDataManager
import CrossRealmMsg
-import CrossRealmPK
import ShareDefine
import PyGameData
import ChPlayer
@@ -95,8 +94,6 @@
if billboardObj.FindByID(playerID):
return True
- if CrossRealmPK.IsCrossRealmPKPlayer(playerID, checkPreSeason=True):
- return True
else:
NeedCheckBillBoardType = IpyGameDataPY.GetFuncEvalCfg("PlayerViewCache", 2)
#校验玩家是否上排行榜
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py b/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
index da18f36..c5dde90 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/PyGameData.py
@@ -126,15 +126,7 @@
g_crossPlayerViewCache = {} # 查看跨服玩家信息 {playerID:[cacheInfo, updTick], ...}
-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,自增创建
-g_crossPKTodayPKRecordInfo = {} # 跨服PK玩家今日PK记录 {playerID:[[tagPlayerID, winnerID], ...]}
-g_crossPKBesureMatchRobotInfo = {} # 跨服PK玩家必定匹配机器人次数信息 {playerID:besureMatchRobotCount, ...}
-
-g_crossPKUnNotifyOverInfo = {} # 跨服PK未同步的结算信息 {player:[overInfo], ...}
+g_crossPKMatchDict = {} # 跨服PK匹配列表 {playerID:[匹配到的玩家ID, ...], ...}
g_unNotifyKillCrossBossDict = {} # 未通知成功的击杀跨服boss {playerID:[killInfo], ...},主要为了防刷(击杀马上下线导致通知不到,然后上线捡东西)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py b/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py
index 7b87bf1..809da18 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py
@@ -15,6 +15,654 @@
from ctypes import (Structure, memset, memmove, sizeof, addressof, create_string_buffer, string_at)
import CommFunc
+#玩家详细信息#tagDBPlayer
+class tagDBPlayer(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PlayerID', ctypes.c_ulong),
+ ('AccID', ctypes.c_char * 65),
+ ('PlayerName', ctypes.c_char * 33),
+ ('AccState', ctypes.c_ubyte),
+ ('IsDeleted', ctypes.c_ubyte),
+ ('GMLevel', ctypes.c_ubyte),
+ ('Sex', ctypes.c_int),
+ ('Hair', ctypes.c_int),
+ ('HairColor', ctypes.c_int),
+ ('Face', ctypes.c_int),
+ ('FacePic', ctypes.c_int),
+ ('Job', ctypes.c_int),
+ ('RoleType', ctypes.c_ulong),
+ ('ReincarnationLv', ctypes.c_ushort),
+ ('LV', ctypes.c_int),
+ ('TotalExp', ctypes.c_ulong),
+ ('FamilyID', ctypes.c_ulong),
+ ('FamilyName', ctypes.c_char * 33),
+ ('Country', ctypes.c_int),
+ ('TeamHornor', ctypes.c_ulong),
+ ('FamilyHornor', ctypes.c_ulong),
+ ('FamilyActiveValue', ctypes.c_ulong),
+ ('LastWeekFamilyActiveValue', ctypes.c_ulong),
+ ('CountryHornor', ctypes.c_ulong),
+ ('CountryLastWeekHornor', ctypes.c_ulong),
+ ('Mate', ctypes.c_ulong),
+ ('Gold', ctypes.c_ulong),
+ ('GoldPaper', ctypes.c_ulong),
+ ('Silver', ctypes.c_ulong),
+ ('SilverPaper', ctypes.c_ulong),
+ ('FightPoint', ctypes.c_ulong),
+ ('HappyPoint', ctypes.c_ulong),
+ ('MapID', ctypes.c_ulong),
+ ('DataMapID', ctypes.c_ulong),
+ ('CopyMapID', ctypes.c_ulong),
+ ('PosX', ctypes.c_ushort),
+ ('PosY', ctypes.c_ushort),
+ ('FromMapID', ctypes.c_ulong),
+ ('FromCopyMapID', ctypes.c_ulong),
+ ('FromPosX', ctypes.c_ushort),
+ ('FromPosY', ctypes.c_ushort),
+ ('State', ctypes.c_int),
+ ('HP', ctypes.c_ulong),
+ ('MP', ctypes.c_ulong),
+ ('XP', ctypes.c_ulong),
+ ('HPRestoreSetting', ctypes.c_ushort),
+ ('MPRestoreSetting', ctypes.c_ushort),
+ ('FreePoint', ctypes.c_ulong),
+ ('FreeSkillPoint', ctypes.c_ulong),
+ ('STR', ctypes.c_int),
+ ('PNE', ctypes.c_int),
+ ('PHY', ctypes.c_int),
+ ('CON', ctypes.c_int),
+ ('TotalSTR', ctypes.c_int),
+ ('TotalPNE', ctypes.c_int),
+ ('TotalPHY', ctypes.c_int),
+ ('TotalCON', ctypes.c_int),
+ ('Setting', ctypes.c_char * 100),
+ ('PKValue', ctypes.c_ushort),
+ ('FightPower', ctypes.c_ulong),
+ ('ActiveValue', ctypes.c_ushort),
+ ('PlayerType', ctypes.c_ubyte),
+ ('BackpackLV', ctypes.c_ubyte),
+ ('WarehouseLV', ctypes.c_ubyte),
+ ('HaveWarehousePsw', ctypes.c_ubyte),
+ ('WarehousePsw', ctypes.c_char * 15),
+ ('WarehouseLocked', ctypes.c_ubyte),
+ ('WarehouseGold', ctypes.c_ulong),
+ ('WarehouseSilver', ctypes.c_ulong),
+ ('TeamID', ctypes.c_ulong),
+ ('UseGoldType', ctypes.c_ubyte),
+ ('UseSilverType', ctypes.c_ubyte),
+ ('AttackMode', ctypes.c_ubyte),
+ ('RebornMapID', ctypes.c_ushort),
+ ('RebornPosX', ctypes.c_ushort),
+ ('RebornPosY', ctypes.c_ushort),
+ ('WeekOnlineTime', ctypes.c_ulong),
+ ('LastWeekOnlineTime', ctypes.c_ulong),
+ ('LogoffTime', ctypes.c_char * 30),
+ ('IsHideMask', ctypes.c_ubyte),
+ ('DayProcessGameEventCount', ctypes.c_ulong),
+ ('LoginIP', ctypes.c_char * 20),
+ ('LoginTime', ctypes.c_char * 30),
+ ('OnlineTime', ctypes.c_ulong),
+ ('FriendFavor', ctypes.c_ulong),
+ ('TeamPrivity', ctypes.c_ulong),
+ ('OfflineMinutes', ctypes.c_ulong),
+ ('Energy', ctypes.c_ulong),
+ ('ReceivedSalary', ctypes.c_ulong),
+ ('EquipShowSwitch', ctypes.c_ulong),
+ ('LuckValue', ctypes.c_ushort),
+ ('ExAttr1', ctypes.c_ulong),
+ ('ExAttr2', ctypes.c_ulong),
+ ('ExAttr3', ctypes.c_ulong),
+ ('ExAttr4', ctypes.c_ulong),
+ ('ExAttr5', ctypes.c_ulong),
+ ('Faction', ctypes.c_int),
+ ('InfamyValue', ctypes.c_ulong),
+ ('OfficialRank', ctypes.c_ubyte),
+ ('IsFindByLabel', ctypes.c_ubyte),
+ ('IsCloseFriendLabel', ctypes.c_ubyte),
+ ('ChangeCoinPointTotal', ctypes.c_ulong),
+ ('VIPLv', ctypes.c_ubyte),
+ ('VIPLvForPhone', ctypes.c_ubyte),
+ ('PhoneVIPStartTime', ctypes.c_double),
+ ('PhoneVIPEndTime', ctypes.c_double),
+ ('VsRoomId', ctypes.c_ulong),
+ ('ExAttr6', ctypes.c_ulong),
+ ('ExAttr7', ctypes.c_ulong),
+ ('ExAttr8', ctypes.c_ulong),
+ ('ExAttr9', ctypes.c_ulong),
+ ('ExAttr10', ctypes.c_ulong),
+ ('ModelMark', ctypes.c_ulong),
+ ('FromDataMapID', ctypes.c_ulong),
+ ('LastOrderId', ctypes.c_char * 40),
+ ('PrizeCoin', ctypes.c_ulong),
+ ('ExAttr11', ctypes.c_ulong),
+ ('ExAttr12', ctypes.c_ulong),
+ ('ExAttr13', ctypes.c_ulong),
+ ('ExAttr14', ctypes.c_ulong),
+ ('CreateRoleTime', ctypes.c_char * 30),
+ ('LVEx', ctypes.c_ushort),
+ ('LV2', ctypes.c_ushort),
+ ('ExpPoint', ctypes.c_ulong),
+ ('OperateInfo', ctypes.c_ulong),
+ ('Operate', ctypes.c_char * 15),
+ ('ServerID', ctypes.c_ulong),
+ ('ExAttr15', ctypes.c_ulong),
+ ('ExAttr16', ctypes.c_ulong),
+ ('ExAttr17', ctypes.c_ulong),
+ ('ExAttr18', ctypes.c_ulong),
+ ('ExAttr19', ctypes.c_ulong),
+ ('ExAttr20', ctypes.c_ulong),
+ ('HPEx', ctypes.c_ulong),
+ ('FightPowerEx', ctypes.c_ulong),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+
+ def clear(self):
+ memset(addressof(self), 0, self.getLength())
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ return -1
+ if len(buf) < pos + self.getLength():
+ return -1
+ self.clear()
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.AccID, pos = CommFunc.ReadString(buf, pos, 65)
+ self.PlayerName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.AccState, pos = CommFunc.ReadBYTE(buf, pos)
+ self.IsDeleted, pos = CommFunc.ReadBYTE(buf, pos)
+ self.GMLevel, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Sex, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Hair, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HairColor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Face, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FacePic, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Job, pos = CommFunc.ReadDWORD(buf, pos)
+ self.RoleType, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ReincarnationLv, pos = CommFunc.ReadWORD(buf, pos)
+ self.LV, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalExp, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.Country, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyActiveValue, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LastWeekFamilyActiveValue, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CountryHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CountryLastWeekHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Mate, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Gold, pos = CommFunc.ReadDWORD(buf, pos)
+ self.GoldPaper, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Silver, pos = CommFunc.ReadDWORD(buf, pos)
+ self.SilverPaper, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HappyPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.MapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.DataMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CopyMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PosX, pos = CommFunc.ReadWORD(buf, pos)
+ self.PosY, pos = CommFunc.ReadWORD(buf, pos)
+ self.FromMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FromCopyMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FromPosX, pos = CommFunc.ReadWORD(buf, pos)
+ self.FromPosY, pos = CommFunc.ReadWORD(buf, pos)
+ self.State, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HP, pos = CommFunc.ReadDWORD(buf, pos)
+ self.MP, pos = CommFunc.ReadDWORD(buf, pos)
+ self.XP, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HPRestoreSetting, pos = CommFunc.ReadWORD(buf, pos)
+ self.MPRestoreSetting, pos = CommFunc.ReadWORD(buf, pos)
+ self.FreePoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FreeSkillPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.STR, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PNE, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PHY, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CON, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalSTR, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalPNE, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalPHY, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalCON, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Setting, pos = CommFunc.ReadString(buf, pos, 100)
+ self.PKValue, pos = CommFunc.ReadWORD(buf, pos)
+ self.FightPower, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ActiveValue, pos = CommFunc.ReadWORD(buf, pos)
+ self.PlayerType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.BackpackLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.WarehouseLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.HaveWarehousePsw, pos = CommFunc.ReadBYTE(buf, pos)
+ self.WarehousePsw, pos = CommFunc.ReadString(buf, pos, 15)
+ self.WarehouseLocked, pos = CommFunc.ReadBYTE(buf, pos)
+ self.WarehouseGold, pos = CommFunc.ReadDWORD(buf, pos)
+ self.WarehouseSilver, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.UseGoldType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.UseSilverType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.AttackMode, pos = CommFunc.ReadBYTE(buf, pos)
+ self.RebornMapID, pos = CommFunc.ReadWORD(buf, pos)
+ self.RebornPosX, pos = CommFunc.ReadWORD(buf, pos)
+ self.RebornPosY, pos = CommFunc.ReadWORD(buf, pos)
+ self.WeekOnlineTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LastWeekOnlineTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LogoffTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.IsHideMask, pos = CommFunc.ReadBYTE(buf, pos)
+ self.DayProcessGameEventCount, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LoginIP, pos = CommFunc.ReadString(buf, pos, 20)
+ self.LoginTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.OnlineTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FriendFavor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamPrivity, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OfflineMinutes, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Energy, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ReceivedSalary, pos = CommFunc.ReadDWORD(buf, pos)
+ self.EquipShowSwitch, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LuckValue, pos = CommFunc.ReadWORD(buf, pos)
+ self.ExAttr1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr2, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr3, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr4, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr5, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Faction, pos = CommFunc.ReadDWORD(buf, pos)
+ self.InfamyValue, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OfficialRank, pos = CommFunc.ReadBYTE(buf, pos)
+ self.IsFindByLabel, pos = CommFunc.ReadBYTE(buf, pos)
+ self.IsCloseFriendLabel, pos = CommFunc.ReadBYTE(buf, pos)
+ self.ChangeCoinPointTotal, pos = CommFunc.ReadDWORD(buf, pos)
+ self.VIPLv, pos = CommFunc.ReadBYTE(buf, pos)
+ self.VIPLvForPhone, pos = CommFunc.ReadBYTE(buf, pos)
+ self.PhoneVIPStartTime, pos = CommFunc.ReadDouble(buf, pos)
+ self.PhoneVIPEndTime, pos = CommFunc.ReadDouble(buf, pos)
+ self.VsRoomId, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr6, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr7, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr8, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr9, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr10, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ModelMark, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FromDataMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LastOrderId, pos = CommFunc.ReadString(buf, pos, 40)
+ self.PrizeCoin, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr11, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr12, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr13, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr14, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CreateRoleTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.LVEx, pos = CommFunc.ReadWORD(buf, pos)
+ self.LV2, pos = CommFunc.ReadWORD(buf, pos)
+ self.ExpPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OperateInfo, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Operate, pos = CommFunc.ReadString(buf, pos, 15)
+ self.ServerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr15, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr16, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr17, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr18, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr19, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr20, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HPEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPowerEx, pos = CommFunc.ReadDWORD(buf, pos)
+ return self.getLength()
+
+
+ def getBuffer(self):
+ buf = create_string_buffer(self.getLength())
+ memmove(addressof(buf), addressof(self), self.getLength())
+ return string_at(addressof(buf), self.getLength())
+
+ def getLength(self):
+ return sizeof(tagDBPlayer)
+
+ def outputString(self):
+ output = '''//玩家详细信息#tagDBPlayer:
+ PlayerID = %s,
+ AccID = %s,
+ PlayerName = %s,
+ AccState = %s,
+ IsDeleted = %s,
+ GMLevel = %s,
+ Sex = %s,
+ Hair = %s,
+ HairColor = %s,
+ Face = %s,
+ FacePic = %s,
+ Job = %s,
+ RoleType = %s,
+ ReincarnationLv = %s,
+ LV = %s,
+ TotalExp = %s,
+ FamilyID = %s,
+ FamilyName = %s,
+ Country = %s,
+ TeamHornor = %s,
+ FamilyHornor = %s,
+ FamilyActiveValue = %s,
+ LastWeekFamilyActiveValue = %s,
+ CountryHornor = %s,
+ CountryLastWeekHornor = %s,
+ Mate = %s,
+ Gold = %s,
+ GoldPaper = %s,
+ Silver = %s,
+ SilverPaper = %s,
+ FightPoint = %s,
+ HappyPoint = %s,
+ MapID = %s,
+ DataMapID = %s,
+ CopyMapID = %s,
+ PosX = %s,
+ PosY = %s,
+ FromMapID = %s,
+ FromCopyMapID = %s,
+ FromPosX = %s,
+ FromPosY = %s,
+ State = %s,
+ HP = %s,
+ MP = %s,
+ XP = %s,
+ HPRestoreSetting = %s,
+ MPRestoreSetting = %s,
+ FreePoint = %s,
+ FreeSkillPoint = %s,
+ STR = %s,
+ PNE = %s,
+ PHY = %s,
+ CON = %s,
+ TotalSTR = %s,
+ TotalPNE = %s,
+ TotalPHY = %s,
+ TotalCON = %s,
+ Setting = %s,
+ PKValue = %s,
+ FightPower = %s,
+ ActiveValue = %s,
+ PlayerType = %s,
+ BackpackLV = %s,
+ WarehouseLV = %s,
+ HaveWarehousePsw = %s,
+ WarehousePsw = %s,
+ WarehouseLocked = %s,
+ WarehouseGold = %s,
+ WarehouseSilver = %s,
+ TeamID = %s,
+ UseGoldType = %s,
+ UseSilverType = %s,
+ AttackMode = %s,
+ RebornMapID = %s,
+ RebornPosX = %s,
+ RebornPosY = %s,
+ WeekOnlineTime = %s,
+ LastWeekOnlineTime = %s,
+ LogoffTime = %s,
+ IsHideMask = %s,
+ DayProcessGameEventCount = %s,
+ LoginIP = %s,
+ LoginTime = %s,
+ OnlineTime = %s,
+ FriendFavor = %s,
+ TeamPrivity = %s,
+ OfflineMinutes = %s,
+ Energy = %s,
+ ReceivedSalary = %s,
+ EquipShowSwitch = %s,
+ LuckValue = %s,
+ ExAttr1 = %s,
+ ExAttr2 = %s,
+ ExAttr3 = %s,
+ ExAttr4 = %s,
+ ExAttr5 = %s,
+ Faction = %s,
+ InfamyValue = %s,
+ OfficialRank = %s,
+ IsFindByLabel = %s,
+ IsCloseFriendLabel = %s,
+ ChangeCoinPointTotal = %s,
+ VIPLv = %s,
+ VIPLvForPhone = %s,
+ PhoneVIPStartTime = %s,
+ PhoneVIPEndTime = %s,
+ VsRoomId = %s,
+ ExAttr6 = %s,
+ ExAttr7 = %s,
+ ExAttr8 = %s,
+ ExAttr9 = %s,
+ ExAttr10 = %s,
+ ModelMark = %s,
+ FromDataMapID = %s,
+ LastOrderId = %s,
+ PrizeCoin = %s,
+ ExAttr11 = %s,
+ ExAttr12 = %s,
+ ExAttr13 = %s,
+ ExAttr14 = %s,
+ CreateRoleTime = %s,
+ LVEx = %s,
+ LV2 = %s,
+ ExpPoint = %s,
+ OperateInfo = %s,
+ Operate = %s,
+ ServerID = %s,
+ ExAttr15 = %s,
+ ExAttr16 = %s,
+ ExAttr17 = %s,
+ ExAttr18 = %s,
+ ExAttr19 = %s,
+ ExAttr20 = %s,
+ HPEx = %s,
+ FightPowerEx = %s,
+ ADOResult = %s,
+ '''%(
+ self.PlayerID,
+ self.AccID,
+ self.PlayerName,
+ self.AccState,
+ self.IsDeleted,
+ self.GMLevel,
+ self.Sex,
+ self.Hair,
+ self.HairColor,
+ self.Face,
+ self.FacePic,
+ self.Job,
+ self.RoleType,
+ self.ReincarnationLv,
+ self.LV,
+ self.TotalExp,
+ self.FamilyID,
+ self.FamilyName,
+ self.Country,
+ self.TeamHornor,
+ self.FamilyHornor,
+ self.FamilyActiveValue,
+ self.LastWeekFamilyActiveValue,
+ self.CountryHornor,
+ self.CountryLastWeekHornor,
+ self.Mate,
+ self.Gold,
+ self.GoldPaper,
+ self.Silver,
+ self.SilverPaper,
+ self.FightPoint,
+ self.HappyPoint,
+ self.MapID,
+ self.DataMapID,
+ self.CopyMapID,
+ self.PosX,
+ self.PosY,
+ self.FromMapID,
+ self.FromCopyMapID,
+ self.FromPosX,
+ self.FromPosY,
+ self.State,
+ self.HP,
+ self.MP,
+ self.XP,
+ self.HPRestoreSetting,
+ self.MPRestoreSetting,
+ self.FreePoint,
+ self.FreeSkillPoint,
+ self.STR,
+ self.PNE,
+ self.PHY,
+ self.CON,
+ self.TotalSTR,
+ self.TotalPNE,
+ self.TotalPHY,
+ self.TotalCON,
+ self.Setting,
+ self.PKValue,
+ self.FightPower,
+ self.ActiveValue,
+ self.PlayerType,
+ self.BackpackLV,
+ self.WarehouseLV,
+ self.HaveWarehousePsw,
+ self.WarehousePsw,
+ self.WarehouseLocked,
+ self.WarehouseGold,
+ self.WarehouseSilver,
+ self.TeamID,
+ self.UseGoldType,
+ self.UseSilverType,
+ self.AttackMode,
+ self.RebornMapID,
+ self.RebornPosX,
+ self.RebornPosY,
+ self.WeekOnlineTime,
+ self.LastWeekOnlineTime,
+ self.LogoffTime,
+ self.IsHideMask,
+ self.DayProcessGameEventCount,
+ self.LoginIP,
+ self.LoginTime,
+ self.OnlineTime,
+ self.FriendFavor,
+ self.TeamPrivity,
+ self.OfflineMinutes,
+ self.Energy,
+ self.ReceivedSalary,
+ self.EquipShowSwitch,
+ self.LuckValue,
+ self.ExAttr1,
+ self.ExAttr2,
+ self.ExAttr3,
+ self.ExAttr4,
+ self.ExAttr5,
+ self.Faction,
+ self.InfamyValue,
+ self.OfficialRank,
+ self.IsFindByLabel,
+ self.IsCloseFriendLabel,
+ self.ChangeCoinPointTotal,
+ self.VIPLv,
+ self.VIPLvForPhone,
+ self.PhoneVIPStartTime,
+ self.PhoneVIPEndTime,
+ self.VsRoomId,
+ self.ExAttr6,
+ self.ExAttr7,
+ self.ExAttr8,
+ self.ExAttr9,
+ self.ExAttr10,
+ self.ModelMark,
+ self.FromDataMapID,
+ self.LastOrderId,
+ self.PrizeCoin,
+ self.ExAttr11,
+ self.ExAttr12,
+ self.ExAttr13,
+ self.ExAttr14,
+ self.CreateRoleTime,
+ self.LVEx,
+ self.LV2,
+ self.ExpPoint,
+ self.OperateInfo,
+ self.Operate,
+ self.ServerID,
+ self.ExAttr15,
+ self.ExAttr16,
+ self.ExAttr17,
+ self.ExAttr18,
+ self.ExAttr19,
+ self.ExAttr20,
+ self.HPEx,
+ self.FightPowerEx,
+ self.ADOResult,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetAccID(self,Str):
+ if len(Str)<=65:
+ self.AccID = Str
+ else:
+ self.AccID = Str[:65]
+
+ def SetPlayerName(self,Str):
+ if len(Str)<=33:
+ self.PlayerName = Str
+ else:
+ self.PlayerName = Str[:33]
+
+ def SetFamilyName(self,Str):
+ if len(Str)<=33:
+ self.FamilyName = Str
+ else:
+ self.FamilyName = Str[:33]
+
+ def SetSetting(self,Str):
+ if len(Str)<=100:
+ self.Setting = Str
+ else:
+ self.Setting = Str[:100]
+
+ def SetWarehousePsw(self,Str):
+ if len(Str)<=15:
+ self.WarehousePsw = Str
+ else:
+ self.WarehousePsw = Str[:15]
+
+ def SetLogoffTime(self,Str):
+ if len(Str)<=30:
+ self.LogoffTime = Str
+ else:
+ self.LogoffTime = Str[:30]
+
+ def SetLoginIP(self,Str):
+ if len(Str)<=20:
+ self.LoginIP = Str
+ else:
+ self.LoginIP = Str[:20]
+
+ def SetLoginTime(self,Str):
+ if len(Str)<=30:
+ self.LoginTime = Str
+ else:
+ self.LoginTime = Str[:30]
+
+ def SetLastOrderId(self,Str):
+ if len(Str)<=40:
+ self.LastOrderId = Str
+ else:
+ self.LastOrderId = Str[:40]
+
+ def SetCreateRoleTime(self,Str):
+ if len(Str)<=30:
+ self.CreateRoleTime = Str
+ else:
+ self.CreateRoleTime = Str[:30]
+
+ def SetOperate(self,Str):
+ if len(Str)<=15:
+ self.Operate = Str
+ else:
+ self.Operate = Str[:15]
+
+
# 跨服补偿个人领取表 #tagDBCrossPersonalCompensation
class tagDBCrossPersonalCompensation(Structure):
_pack_ = 1
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
index 1328c7c..c3f1e64 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ShareDefine.py
@@ -890,7 +890,7 @@
Def_BT_Max, #排行榜最大类型
) = range(0, 40 + 2)
-''' 跨服排行榜类型, 从 150 开始
+''' 跨服排行榜类型, 从 150 开始,最大条数在功能配置表 CrossBillboardSet 配置,没配默认100
与本服榜单存储的是不一样的数据库表格,理论上类型可以和本服榜单类型重复,为了做下区分防误导,跨服榜单从 150 开始
跨服榜单表(tagDBCrossBillboard)
本服榜单表(tagDBBillboard)
@@ -911,20 +911,8 @@
Def_CBT_XianXiaMJScore, # 仙匣秘境积分 - 个人榜 162
Def_CBT_GubaoScore, # 古宝养成积分 - 个人榜 163
Def_CBT_HorsePetTrainScore, # 骑宠养成积分 - 个人榜 164
-) = range(150, 164 + 1)
-
-# 跨服榜单最大数据名次,没有设置的默认100
-CrossBillboard_MaxDataCount = {
- Def_CBT_BattlefieldWJoin:1000,
- Def_CBT_BattlefieldWCall:1000,
- Def_CBT_BattlefieldWScore:1000,
- Def_CBT_BattlefieldWScoreLastWeek:1000,
- Def_CBT_BossTrialSubmit:1000,
- Def_CBT_BossTrialSubmitBak:1000,
- Def_CBT_XianXiaMJScore:1000,
- Def_CBT_GubaoScore:1000,
- Def_CBT_HorsePetTrainScore:1000,
- }
+Def_CBT_CrossRealmPK, # 跨服PK竞技场 165
+) = range(150, 165 + 1)
#职业对应战力排行榜类型
JobFightPowerBillboardDict = {
@@ -1653,12 +1641,8 @@
CrossServerMsg_PullPlayerPackData = "PullPlayerPackData"# 拉取玩家打包数据
CrossServerMsg_PushPlayerPackData = "PushPlayerPackData"# 推送玩家打包数据
CrossServerMsg_PKMatchReqRet = "PKMatchReqRet" # 跨服PK匹配请求结果
-CrossServerMsg_PKMatchResult = "PKMatchResult" # 跨服PK匹配结果
-CrossServerMsg_PKReadyOKRoomList = "PKReadyOKRoomList" # 跨服PK已准备好的房间列表
-CrossServerMsg_PKTimeoutRoomList = "PKTimeoutRoomList" # 跨服PK已超时的房间列表
CrossServerMsg_PKOverInfo = "PKOverInfo" # 跨服PK结果
CrossServerMsg_PKSeasonInfo = "PKSeasonInfo" # 跨服PK赛季信息
-CrossServerMsg_PKSyncBillboard = "PKSyncBillboard" # 跨服PK同步排行榜
CrossServerMsg_SyncBillboard = "SyncBillboard" # 跨服同步排行榜
CrossServerMsg_CrossBossInfo = "CrossBossInfo" # 跨服Boss信息
CrossServerMsg_CrossBossState = "CrossBossState" # 跨服Boss状态
@@ -1713,9 +1697,7 @@
ClientServerMsg_PullOtherPlayerPackData = "PullOtherPlayerPackData" # 拉其他服玩家打包数据
ClientServerMsg_PlayerPackData = "PlayerPackData" # 玩家打包数据同步
ClientServerMsg_PKMatch = "PKMatch" # 跨服PK匹配
-ClientServerMsg_PKRobotOver = "PKRobotOver" # 跨服PK机器人结算
-ClientServerMsg_PKCancel = "PKCancel" # 跨服PK取消匹配
-ClientServerMsg_PKPrepareOK = "PKPrepareOK" # 跨服PK准备完毕
+ClientServerMsg_PKOver = "PKOver" # 跨服PK结算
ClientServerMsg_PKBillboard = "PKBillboard" # 跨服PK排行榜
ClientServerMsg_QueryBillboard = "QueryBillboard" # 跨服排行榜 - 查询、同步等
ClientServerMsg_UpdateBillboard = "UpdateBillboard" # 跨服排行榜 - 更新
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/MirrorAttack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/MirrorAttack.py
index e2b4736..73f663d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/MirrorAttack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/MirrorAttack.py
@@ -445,6 +445,9 @@
playerID = 0
if curPlayer:
+ if not FBLogic.OnMirrorBattleRequest(curPlayer, mapID, funcLineID):
+ GameWorld.DebugLog("当前不允许该镜像战斗请求! mapID=%s,funcLineID=%s" % (mapID, funcLineID), playerID)
+ return
playerID = curPlayer.GetPlayerID()
if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_MirrorBattleID):
GameWorld.DebugLog("镜像战斗场景中,无法请求!", playerID)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index c46400a..8320744 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3581,7 +3581,6 @@
Def_Player_Dict_FromFBLineID = 'FromFBLineID' # 最后一次离开的可返回的副本ID,线路ID
Def_PlayerKey_CrossRegisterMap = "CrossRegisterMap" #跨服注册活动地图, dataMapID
-Def_PlayerKey_IsCrossPKMatching = "IsCrossPKMatching" #是否跨服匹配中
Def_Player_Dict_FamilyTechLV = "FamilyTechLV_%s" #家族科技等级, 参数(科技ID)
Def_Player_Dict_RouteServerInitOK = "RouteServerInitOK_33" #RouteServer初始化成功(仅登陆一次)
@@ -4354,7 +4353,6 @@
# 跨服竞技场
Def_PDict_CrossPK_TotalScore = "CrossPK_TotalScore" # 当前总积分
-Def_PDict_CrossPK_OnDayScore = "CrossPK_OnDayScore" # 今天过天时的积分
Def_PDict_CrossPK_DanLV = "CrossPK_DanLV" # 当前段位
Def_PDict_CrossPK_PKCount = "CrossPK_PKCount" # 当前总PK次数
Def_PDict_CrossPK_WinCount = "CrossPK_WinCount" # 当前胜利次数
@@ -4364,6 +4362,7 @@
Def_PDict_CrossPK_TodayWinCount = "CrossPK_TodayWinCount" # 今日已胜利次数
Def_PDict_CrossPK_TodayBuyCount = "CrossPK_TodayBuyCount" # 今日已购买PK次数
Def_PDict_CrossPK_ItemAddCount = "CrossPK_ItemAddCount" # 今日道具增加PK次数
+Def_PDict_CrossPK_RefreshCount = "CrossPK_RefreshCount" # 今日已刷新次数
Def_PDict_CrossPK_DayPKCountAwardState = "CrossPK_DayPKCountAwardState" # 每日匹配次数奖励记录,二进制位存储是否已领取,按匹配次数升序排序索引代表奖励位
Def_PDict_CrossPK_DayWinCountAwardState = "CrossPK_DayWinCountAwardState" # 每日胜利次数奖励记录,二进制位存储是否已领取,按胜利次数升序排序索引代表奖励位
Def_PDict_CrossPK_DanLVAwardState = "CrossPK_DanLVAwardState" # 段位达标奖励记录,二进制位存储是否已领取,按段位代表奖励位
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index 20e03e0..c74e612 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -23226,7 +23226,7 @@
_fields_ = [
("Cmd", c_ubyte),
("SubCmd", c_ubyte),
- ("Type", c_ubyte), # 0-取消匹配; 1-进行匹配
+ ("Type", c_ubyte), # 0-查询匹配;1-刷新匹配
]
def __init__(self):
@@ -23279,6 +23279,7 @@
("Cmd", c_ubyte),
("SubCmd", c_ubyte),
("IsWin", c_ubyte), #是否获胜
+ ("TagPlayerID", c_int), #目标玩家ID
]
def __init__(self):
@@ -23296,6 +23297,7 @@
self.Cmd = 0xC1
self.SubCmd = 0x08
self.IsWin = 0
+ self.TagPlayerID = 0
return
def GetLength(self):
@@ -23308,12 +23310,14 @@
DumpString = '''// C1 08 跨服PK挑战机器人结算 //tagCMCrossRealmPKRobotOver:
Cmd:%s,
SubCmd:%s,
- IsWin:%d
+ IsWin:%d,
+ TagPlayerID:%d
'''\
%(
self.Cmd,
self.SubCmd,
- self.IsWin
+ self.IsWin,
+ self.TagPlayerID
)
return DumpString
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index c02243e..4158f76 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -17741,11 +17741,11 @@
PlayerName = "" #(String PlayerName)// 跨服名字
Job = 0 #(BYTE Job)
LV = 0 #(WORD LV)
+ RealmLV = 0 #(WORD RealmLV)//境界
Face = 0 #(DWORD Face)//基本脸型
FacePic = 0 #(DWORD FacePic)//头像框
- MaxHP = 0 #(DWORD MaxHP)// 默认满血,求余亿部分
- MaxHPEx = 0 #(DWORD MaxHPEx)// 默认满血,整除亿部分
- MaxProDef = 0 #(DWORD MaxProDef)// 最大护盾
+ FightPower = 0 #(DWORD FightPower)//战力,求余亿部分
+ FightPowerEx = 0 #(DWORD FightPowerEx)//战力,整除亿部分
data = None
def __init__(self):
@@ -17759,11 +17759,11 @@
self.PlayerName,_pos = CommFunc.ReadString(_lpData, _pos,self.NameLen)
self.Job,_pos = CommFunc.ReadBYTE(_lpData, _pos)
self.LV,_pos = CommFunc.ReadWORD(_lpData, _pos)
+ self.RealmLV,_pos = CommFunc.ReadWORD(_lpData, _pos)
self.Face,_pos = CommFunc.ReadDWORD(_lpData, _pos)
self.FacePic,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.MaxHP,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.MaxHPEx,_pos = CommFunc.ReadDWORD(_lpData, _pos)
- self.MaxProDef,_pos = CommFunc.ReadDWORD(_lpData, _pos)
+ self.FightPower,_pos = CommFunc.ReadDWORD(_lpData, _pos)
+ self.FightPowerEx,_pos = CommFunc.ReadDWORD(_lpData, _pos)
return _pos
def Clear(self):
@@ -17772,11 +17772,11 @@
self.PlayerName = ""
self.Job = 0
self.LV = 0
+ self.RealmLV = 0
self.Face = 0
self.FacePic = 0
- self.MaxHP = 0
- self.MaxHPEx = 0
- self.MaxProDef = 0
+ self.FightPower = 0
+ self.FightPowerEx = 0
return
def GetLength(self):
@@ -17786,7 +17786,7 @@
length += len(self.PlayerName)
length += 1
length += 2
- length += 4
+ length += 2
length += 4
length += 4
length += 4
@@ -17801,11 +17801,11 @@
data = CommFunc.WriteString(data, self.NameLen, self.PlayerName)
data = CommFunc.WriteBYTE(data, self.Job)
data = CommFunc.WriteWORD(data, self.LV)
+ data = CommFunc.WriteWORD(data, self.RealmLV)
data = CommFunc.WriteDWORD(data, self.Face)
data = CommFunc.WriteDWORD(data, self.FacePic)
- data = CommFunc.WriteDWORD(data, self.MaxHP)
- data = CommFunc.WriteDWORD(data, self.MaxHPEx)
- data = CommFunc.WriteDWORD(data, self.MaxProDef)
+ data = CommFunc.WriteDWORD(data, self.FightPower)
+ data = CommFunc.WriteDWORD(data, self.FightPowerEx)
return data
def OutputString(self):
@@ -17815,11 +17815,11 @@
PlayerName:%s,
Job:%d,
LV:%d,
+ RealmLV:%d,
Face:%d,
FacePic:%d,
- MaxHP:%d,
- MaxHPEx:%d,
- MaxProDef:%d
+ FightPower:%d,
+ FightPowerEx:%d
'''\
%(
self.PlayerID,
@@ -17827,21 +17827,17 @@
self.PlayerName,
self.Job,
self.LV,
+ self.RealmLV,
self.Face,
self.FacePic,
- self.MaxHP,
- self.MaxHPEx,
- self.MaxProDef
+ self.FightPower,
+ self.FightPowerEx
)
return DumpString
class tagGCCrossRealmPKMatchOK(Structure):
Head = tagHead()
- RoomID = 0 #(WORD RoomID)// 房间ID
- NameLen = 0 #(BYTE NameLen)
- PlayerName = "" #(String PlayerName)// 跨服名字
- Number = 0 #(BYTE Number)// 位置编号;1-左,2-右
MatchPlayerCount = 0 #(BYTE MatchPlayerCount)
MatchPlayer = list() #(vector<tagGCCrossRealmPKMatchPlayer> MatchPlayer)// 匹配到的玩家
data = None
@@ -17855,10 +17851,6 @@
def ReadData(self, _lpData, _pos=0, _Len=0):
self.Clear()
_pos = self.Head.ReadData(_lpData, _pos)
- self.RoomID,_pos = CommFunc.ReadWORD(_lpData, _pos)
- self.NameLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
- self.PlayerName,_pos = CommFunc.ReadString(_lpData, _pos,self.NameLen)
- self.Number,_pos = CommFunc.ReadBYTE(_lpData, _pos)
self.MatchPlayerCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
for i in range(self.MatchPlayerCount):
temMatchPlayer = tagGCCrossRealmPKMatchPlayer()
@@ -17871,10 +17863,6 @@
self.Head.Clear()
self.Head.Cmd = 0xC0
self.Head.SubCmd = 0x01
- self.RoomID = 0
- self.NameLen = 0
- self.PlayerName = ""
- self.Number = 0
self.MatchPlayerCount = 0
self.MatchPlayer = list()
return
@@ -17882,10 +17870,6 @@
def GetLength(self):
length = 0
length += self.Head.GetLength()
- length += 2
- length += 1
- length += len(self.PlayerName)
- length += 1
length += 1
for i in range(self.MatchPlayerCount):
length += self.MatchPlayer[i].GetLength()
@@ -17895,10 +17879,6 @@
def GetBuffer(self):
data = ''
data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
- data = CommFunc.WriteWORD(data, self.RoomID)
- data = CommFunc.WriteBYTE(data, self.NameLen)
- data = CommFunc.WriteString(data, self.NameLen, self.PlayerName)
- data = CommFunc.WriteBYTE(data, self.Number)
data = CommFunc.WriteBYTE(data, self.MatchPlayerCount)
for i in range(self.MatchPlayerCount):
data = CommFunc.WriteString(data, self.MatchPlayer[i].GetLength(), self.MatchPlayer[i].GetBuffer())
@@ -17907,19 +17887,11 @@
def OutputString(self):
DumpString = '''
Head:%s,
- RoomID:%d,
- NameLen:%d,
- PlayerName:%s,
- Number:%d,
MatchPlayerCount:%d,
MatchPlayer:%s
'''\
%(
self.Head.OutputString(),
- self.RoomID,
- self.NameLen,
- self.PlayerName,
- self.Number,
self.MatchPlayerCount,
"..."
)
@@ -57002,6 +56974,7 @@
("DayWinCount", c_ubyte), # 当日已胜利次数
("DayBuyCount", c_ubyte), # 当日已购买次数
("DayItemAddCount", c_ubyte), # 当日物品增加次数
+ ("DayRefreshCount", c_ushort), # 今日已刷新匹配次数
]
def __init__(self):
@@ -57027,6 +57000,7 @@
self.DayWinCount = 0
self.DayBuyCount = 0
self.DayItemAddCount = 0
+ self.DayRefreshCount = 0
return
def GetLength(self):
@@ -57047,7 +57021,8 @@
DayPKCount:%d,
DayWinCount:%d,
DayBuyCount:%d,
- DayItemAddCount:%d
+ DayItemAddCount:%d,
+ DayRefreshCount:%d
'''\
%(
self.Cmd,
@@ -57060,7 +57035,8 @@
self.DayPKCount,
self.DayWinCount,
self.DayBuyCount,
- self.DayItemAddCount
+ self.DayItemAddCount,
+ self.DayRefreshCount
)
return DumpString
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
index d75d1e4..c55c792 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/FunctionNPCCommon.py
@@ -359,6 +359,8 @@
def CheckMysticalShopRefresh(curPlayer, tick):
##神秘商店刷新
createRoleTime = curPlayer.GetCreateRoleTime()
+ if not createRoleTime:
+ return
diffTime = GameWorld.GetCurrentTime() - GameWorld.GetDateTimeByStr(createRoleTime, ChConfig.TYPE_Time_Format)
pastSeconds = diffTime.days*24*60*60 + diffTime.seconds
refreshTime = IpyGameDataPY.GetFuncCfg('MysteryShopRefresh', 4)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/PlayerMirror.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/PlayerMirror.py
index a6272b7..7bb7fb0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/PlayerMirror.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/PlayerMirror.py
@@ -34,6 +34,9 @@
GameWorld.DebugAnswer(curPlayer, "跳过战斗: PlayerMirror q")
GameWorld.DebugAnswer(curPlayer, "退出战斗: PlayerMirror e")
GameWorld.DebugAnswer(curPlayer, "更新镜像: PlayerMirror 5")
+ GameWorld.DebugAnswer(curPlayer, "加假数据: PlayerMirror a 个数 [起始ID 战力 区服ID 模版key]")
+ GameWorld.DebugAnswer(curPlayer, "删假数据: PlayerMirror d")
+ GameWorld.DebugAnswer(curPlayer, "输出数据: PlayerMirror p [起始索引 个数 ]")
GameWorld.DebugAnswer(curPlayer, "是否后台:0-玩家自身参与战斗")
GameWorld.DebugAnswer(curPlayer, "是否后台:1-玩家无感知,系统直接出结果")
GameWorld.DebugAnswer(curPlayer, "目标ID:无-自己;>0-其他玩家ID支持跨服玩家ID")
@@ -95,5 +98,6 @@
tick = GameWorld.GetGameWorld().GetTick()
PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick, forcePackData=True)
GameWorld.DebugAnswer(curPlayer, "已更新最新镜像缓存!")
-
+ elif value1 in ["a", "d", "p"]:
+ return True
return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py
index 74ae10c..48cb47d 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetCrossPK.py
@@ -18,7 +18,6 @@
import GameWorld
import PlayerControl
import PlayerCrossRealmPK
-import CrossRealmPlayer
import IpyGameDataPY
import ShareDefine
import ChConfig
@@ -39,44 +38,18 @@
if msgList[0] == "b":
danLV = msgList[1] if len(msgList) > 1 else 0
pkScore = msgList[2] if len(msgList) > 2 else 0
-
- billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])
- danLVLimit = billboardCfg[1] if len(billboardCfg) > 1 else 0
- if danLV < danLVLimit:
- GameWorld.DebugAnswer(curPlayer, "最低上榜段位为:%s" % danLVLimit)
- return
+ cWinCount = msgList[3] if len(msgList) > 3 else None
danIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)
if not danIpyData:
GameWorld.DebugAnswer(curPlayer, "不存在该段位:%s" % danLV)
return
if pkScore <= 0:
pkScore = danIpyData.GetLVUpScore()
-
- zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
- seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
- if not zoneID or not seasonID:
- GameWorld.DebugAnswer(curPlayer, "没有分区或赛季!zoneID:%s,seasonID:%s" % (zoneID, seasonID))
- return
-
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
-
- # 请求查询跨服服务器
- playerInfoDict = {"accID":curPlayer.GetAccID(),
- "playerID":curPlayer.GetPlayerID(),
- "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
- "playerJob":curPlayer.GetJob(),
- "face":curPlayer.GetFace(),
- "facePic":curPlayer.GetFacePic(),
- "fightPower":PlayerControl.GetFightPower(curPlayer),
- "realmLV":curPlayer.GetOfficialRank(),
- "ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore),
- "pkScore":pkScore, "danLV":danLV, "cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount),
- }
- dataMsg = {"ZoneID":zoneID, "SeasonID":seasonID, "GMSetCrossPK":1, "PlayerInfo":playerInfoDict}
- GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKBillboard, dataMsg)
- PlayerCrossRealmPK.SyncCrossRealmPKPlayerInfo(curPlayer)
- GameWorld.DebugAnswer(curPlayer, "设置上榜段位:%s,积分:%s" % (danLV, pkScore))
+ errorMsg = PlayerCrossRealmPK.GMSetPlayerCrossPKData(curPlayer, danLV, pkScore, cWinCount)
+ if errorMsg:
+ GameWorld.DebugAnswer(curPlayer, "分区赛季异常!")
+ else:
+ GameWorld.DebugAnswer(curPlayer, "设置上榜段位:%s,积分:%s" % (danLV, pkScore))
return
if len(msgList) == 1:
@@ -86,7 +59,6 @@
# 重置数据
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, 0)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_OnDayScore, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_WinCount, 0)
@@ -95,6 +67,7 @@
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_RefreshCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayPKCountAwardState, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayWinCountAwardState, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLVAwardState, 0)
@@ -115,7 +88,6 @@
if len(msgList) == 2 or len(msgList) % 2 == 0:
setTypeDict = {0:[ChConfig.Def_PDict_CrossPK_TotalScore, "积分"],
- 1:[ChConfig.Def_PDict_CrossPK_OnDayScore, "过天积分"],
2:[ChConfig.Def_PDict_CrossPK_DanLV, "段位"],
3:[ChConfig.Def_PDict_CrossPK_PKCount, "PK次数"],
4:[ChConfig.Def_PDict_CrossPK_WinCount, "胜利次数"],
@@ -124,6 +96,7 @@
7:[ChConfig.Def_PDict_CrossPK_TodayPKCount, "今日PK次数"],
8:[ChConfig.Def_PDict_CrossPK_TodayWinCount, "今日胜利次数"],
9:[ChConfig.Def_PDict_CrossPK_TodayBuyCount, "今日购买次数"],
+ 10:[ChConfig.Def_PDict_CrossPK_RefreshCount, "今日刷新次数"],
}
indexList = range(len(msgList))
for i in indexList[::2]:
@@ -162,12 +135,12 @@
def __PrintHelp(curPlayer):
GameWorld.DebugAnswer(curPlayer, "重置数据: SetCrossPK 0")
GameWorld.DebugAnswer(curPlayer, "设置数据: SetCrossPK 类型 值")
- GameWorld.DebugAnswer(curPlayer, "类型:0-积分,1-过天积分,2-段位,3-PK次数,4-胜利次数,5-连胜次数,6-连败次数")
- GameWorld.DebugAnswer(curPlayer, "7-今日PK次数,8-今日胜利次数,9-今日购买次数")
+ GameWorld.DebugAnswer(curPlayer, "类型:0-积分,2-段位,3-PK次数,4-胜利次数,5-连胜次数,6-连败次数")
+ GameWorld.DebugAnswer(curPlayer, "7-今日PK次数,8-今日胜利次数,9-今日购买次数,10-今日刷新次数")
GameWorld.DebugAnswer(curPlayer, "设置历史记录: SetCrossPK 赛季ID 类型 数值")
GameWorld.DebugAnswer(curPlayer, "类型:0-段位,1-名次,2-积分,3-奖励等级")
GameWorld.DebugAnswer(curPlayer, "当前连败次数: %s" % curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount))
- GameWorld.DebugAnswer(curPlayer, "设置上榜: SetCrossPK b 段位 [积分]")
+ GameWorld.DebugAnswer(curPlayer, "设置上榜: SetCrossPK b 段位 [积分 连胜]")
return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
index 056f726..c27f52f 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBLogic.py
@@ -2506,6 +2506,18 @@
return callFunc(curPlayer, mapID, funcLineID, hurtObj, hurtValue, factionHurtValue)
+def OnMirrorBattleRequest(curPlayer, mapID, funcLineID):
+ ## 镜像战斗请求
+ do_FBLogic_ID = __GetFBLogic_MapID(mapID)
+
+ callFunc = GameWorld.GetExecFunc(FBProcess, "GameLogic_%s.%s" % (do_FBLogic_ID, "OnMirrorBattleRequest"))
+
+ if callFunc == None:
+ # 默认允许
+ return True
+
+ return callFunc(curPlayer, mapID, funcLineID)
+
def OnMirrorBattleOver(battleID, mapID):
## 镜像战斗结束
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_CrossRealmPK.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_CrossRealmPK.py
index 8090a7b..31247dc 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_CrossRealmPK.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/GameLogic_CrossRealmPK.py
@@ -15,561 +15,64 @@
#"""Version = 2018-12-21 18:00"""
#-------------------------------------------------------------------------------
-import ChPlayer
import GameWorld
-import IPY_GameWorld
-import PlayerControl
-import GameWorldProcess
-import IpyGameDataPY
-import SkillCommon
-import FBCommon
-import ChConfig
+import MirrorAttack
+import PlayerCrossRealmPK
import GameObj
-
-(
-Def_Time_MaxWait, # 最长等待时间, 秒
-Def_Time_MapPrepare, # 准备时间, 秒
-Def_Time_Fight, # 战斗时间, 秒
-Def_Time_Protect, # 保护时间,秒,玩家战斗中掉线保护时长
-Def_Time_Leave, # 结束退出时间, 秒
-) = range(5)
-
-# 当前副本地图的状态
-(
-FB_State_Open,
-FB_State_Waiting, # 等待对手阶段
-FB_State_MapPrepare, # 地图准备
-FB_State_Fight, # 战斗阶段
-FB_State_Reborn, # 复活阶段
-FB_State_Leave, # 离开阶段
-FB_State_Close, # 关闭阶段
-) = range(7)
-
-# 对战结束类型定义
-(
-Def_OverType_LackPlayer, # 缺少对手
-Def_OverType_PlayerExit, # 对手退出(视为认输)
-Def_OverType_Kill, # 击杀对手
-Def_OverType_TimeOut, # PK时间超时
-) = range(4)
-
-# 副本相关字典key
-GameFBDict_FBPlayerID = "FBD_FBPlayerID_%s" # 玩家ID, 参数, 进入顺序
-GameFBDict_PlayerWinCnt = "FBD_PlayerWinCnt_%s" # 玩家已获胜次数, 参数[playerID]
-GameFBDict_PlayerLeaveTick = "FBD_PlayerLeaveTick_%s" # 玩家已获胜次数, 参数[playerID]
-
-FBPDict_PVPDamage = "FBPD_PVPDamage" # 玩家伤害输出
-FBPDict_PVPDamUpdTick = "FBPD_PVPDamUpdTick" # 更新伤害tick
-FBPDict_ResetPosX = "FBPD_ResetPosX" # 玩家重置坐标X
-FBPDict_ResetPosY = "FBPD_ResetPosY" # 玩家重置坐标Y
-FBPDict_RoundNum = "FBPD_RoundNum" # 玩家当前所属回合数
-
-FB_RoundNum = "FB_RoundNum" # 副本当前回合数
-FB_RoundWinPlayerID = "FB_RoundWinPlayerID_%s" # 回合获胜玩家ID, 参数[回合数]
-
-## 是否能够通过活动查询进入
-def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
+###处理副本中杀死玩家逻辑
+def DoFBOnKill_Player(atkobj, defender, tick):
+ GameWorld.DebugLog("镜像切磋击杀玩家: defID=%s" % (defender.GetID()), atkobj.GetID())
return True
-#def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
-# posDict = {117401:(40,37), 117403:(10, 7)}
-# return posDict.get(curPlayer.GetPlayerID())
-
-## 玩家进入副本
-def DoEnterFB(curPlayer, tick):
- playerID = curPlayer.GetPlayerID()
- playerVSRoomID = curPlayer.GetVsRoomId()
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- gameFB = GameWorld.GetGameFB()
- fbStep = gameFB.GetFBStep()
- GameWorld.Log("DoEnterFB fbRoomID=%s,playerVSRoomID=%s,fbStep=%s" % (roomID, playerVSRoomID, fbStep), playerID)
+def OnMirrorBattleRequest(curPlayer, mapID, funcLineID):
+ ## 镜像战斗请求
- if gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerID):
- GameWorld.Log(" 玩家离线保护时间内上线!", playerID)
- gameFB.SetGameFBDict(GameFBDict_PlayerLeaveTick % playerID, 0)
- playerManager = GameWorld.GetMapCopyPlayerManager()
- for index in xrange(playerManager.GetPlayerCount()):
- player = playerManager.GetPlayerByIndex(index)
- if player and player.GetPlayerID() != curPlayer.GetPlayerID():
- player.Sync_TimeTick(ChConfig.tttPlayerLeave, 0, 0, True)
-
- fbRoundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
- playerRoundNum = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_RoundNum)
- if playerRoundNum and fbRoundNum and playerRoundNum != fbRoundNum:
- # 一般是掉线时上个回合已经结束了
- GameWorld.DebugLog("玩家进入副本时与当前副本回合数不一致时,重置状态!fbRoundNum=%s,playerRoundNum=%s"
- % (fbRoundNum, playerRoundNum), playerID)
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_RoundNum, fbRoundNum)
- __ResetPlayerState(gameFB, curPlayer, playerID)
-
- if fbStep >= FB_State_Leave or not roomID or not playerVSRoomID or roomID != playerVSRoomID:
- PlayerControl.PlayerLeaveFB(curPlayer)
- return
- PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 3)
-
- # 非战斗阶段,通知动态障碍点
- if fbStep < FB_State_Fight:
- FBCommon.SyncDynamicBarrierState(IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 2), 1, curPlayer) # 准备期间有动态障碍点
-
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
-
- if fbStep == FB_State_Open:
- gameFB.SetGameFBDict(GameFBDict_FBPlayerID % 1, playerID)
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosX, curPlayer.GetPosX())
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosY, curPlayer.GetPosY())
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_RoundNum, 1)
- FBCommon.SetFBStep(FB_State_Waiting, tick)
- GameWorld.Log(" 第一个进入,阵营1,设置副本进入等待对手阶段!roomID=%s" % (roomID), playerID)
- __ResetPlayerState(gameFB, curPlayer, playerID)
- curPlayer.Sync_TimeTick(ChConfig.tttWaitPlayer, 0, fbTimeList[Def_Time_MaxWait] * 1000, True)
- sendMsg = str([roomID])
- GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "CrossPKRoomOpen", sendMsg, len(sendMsg))
-
- elif fbStep == FB_State_Waiting:
- playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
- playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
- if not playerIDB and playerIDA != playerID:
- gameFB.SetGameFBDict(GameFBDict_FBPlayerID % 2, playerID)
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosX, curPlayer.GetPosX())
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_ResetPosY, curPlayer.GetPosY())
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_RoundNum, 1)
- GameWorld.Log(" 第二个进入的玩家!阵营2,roomID=%s" % (roomID), playerID)
- __ResetPlayerState(gameFB, curPlayer, playerID)
-
- if GameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 2:
- GameWorld.Log(" 两个人都在,设置副本进入战斗倒计时阶段!roomID=%s" % (roomID), playerID)
- FBCommon.SetFBStep(FB_State_MapPrepare, tick)
- FBCommon.Sync_Player_TimeTick(ChConfig.tttWaitStart, fbTimeList[Def_Time_MapPrepare] * 1000)
- gameFB.SetGameFBDict(FB_RoundNum, 1)
- else:
- GameWorld.Log(" 对手不在,继续等待!roomID=%s" % (roomID), playerID)
-
- elif fbStep == FB_State_MapPrepare:
- notify_tick = fbTimeList[Def_Time_MapPrepare] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
- curPlayer.Sync_TimeTick(ChConfig.tttWaitStart, 0, max(notify_tick, 0), True)
-
- elif fbStep == FB_State_Fight:
- notify_tick = fbTimeList[Def_Time_Fight] * 1000 - (tick - GameWorld.GetGameFB().GetFBStepTick())
- curPlayer.Sync_TimeTick(ChConfig.tttTowerTake, 0, max(notify_tick, 0), True)
-
- FBCommon.Notify_FBHelp(curPlayer, __GetFBHelpInfo())
- PlayerControl.DelLimitSuperBuff(curPlayer, tick)
- PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
- return
-
-def __GetFBHelpInfo():
- gameFB = GameWorld.GetGameFB()
- roundWinerIDList = []
- roundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
- for roundNum in xrange(1, roundNum + 1):
- winnerID = gameFB.GetGameFBDictByKey(FB_RoundWinPlayerID % roundNum)
- if not winnerID:
- break
- roundWinerIDList.append(winnerID)
-
- return {"roundNum":roundNum, "roundWinerIDList":roundWinerIDList}
-
-
-## 玩家退出副本
-def DoExitFB(curPlayer, tick):
- # 结算时间
- gameFB = GameWorld.GetGameFB()
- fbStep = gameFB.GetFBStep()
-
- if fbStep >= FB_State_Leave:
+ if not PlayerCrossRealmPK.CheckCanMatch(curPlayer):
return
- playerID = curPlayer.GetPlayerID()
- gameFB.SetGameFBDict(GameFBDict_PlayerLeaveTick % playerID, tick)
- GameWorld.Log("玩家战斗阶段下线!playerID=%s,waitPlayerID=%s" % (playerID, playerID))
-
- ## 通知对方,对手掉线
- playerManager = GameWorld.GetMapCopyPlayerManager()
- for index in xrange(playerManager.GetPlayerCount()):
- player = playerManager.GetPlayerByIndex(index)
- if player and player.GetPlayerID() != curPlayer.GetPlayerID():
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- player.Sync_TimeTick(ChConfig.tttPlayerLeave, 0, max(fbTimeList[Def_Time_Protect] * 1000, 0), True)
-
- return
-
-##玩家主动离开副本.
-def DoPlayerLeaveFB(curPlayer, tick):
- gameFB = GameWorld.GetGameFB()
- fbStep = gameFB.GetFBStep()
-
- if fbStep <= FB_State_Waiting or fbStep >= FB_State_Leave:
+ if not PlayerCrossRealmPK.CheckHavePKCount(curPlayer):
return
-
- leavePlayerID = curPlayer.GetPlayerID()
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
- playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
-
- loser, loserID = curPlayer, leavePlayerID
- winnerID = playerIDA if playerIDB == loserID else playerIDB
- winner = GameWorld.GetMapCopyPlayerManager().FindPlayerByID(winnerID)
- GameWorld.Log("玩家主动退出,直接算输! roomID=%s,leavePlayerID=%s,loserID=%s,winnerID=%s" % (roomID, leavePlayerID, loserID, winnerID))
- __DoFBPKAllOver(winner, winnerID, loser, loserID, Def_OverType_PlayerExit, tick)
- return
-
-## 获得副本帮助信息
-def DoFBHelp(curPlayer, tick):
- return
-
-## 副本总逻辑计时器
-def OnProcess(tick):
- gameFB = GameWorld.GetGameFB()
- fbStep = gameFB.GetFBStep()
-
- if fbStep == FB_State_Waiting:
- __DoLogic_Waiting(tick)
- elif fbStep == FB_State_MapPrepare:
- if not __CheckLeaveProtectTimeout(tick):
- __DoLogic_MapPrepare(tick)
- elif fbStep == FB_State_Fight:
- if not __CheckLeaveProtectTimeout(tick):
- __DoLogic_MapFight(tick)
- elif fbStep == FB_State_Reborn:
- __DoLogic_Reborn(tick)
- elif fbStep == FB_State_Leave:
- __DoLogic_LeaveTime(tick)
-
- return
-
-##等待玩家进入阶段处理
-def __DoLogic_Waiting(tick):
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- if tick - GameWorld.GetGameFB().GetFBStepTick() < fbTimeList[Def_Time_MaxWait] * 1000:
- return
-
- winner, winnerID, loser, loserID = __GetTimeoutWinerInfo(tick)
- # 对手没来,直接获胜
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- GameWorld.Log("战前等待对手阶段超时,直接结束!roomID=%s,winnerID=%s,loserID=%s" % (roomID, winnerID, loserID))
- __DoFBPKAllOver(winner, winnerID, loser, loserID, Def_OverType_LackPlayer, tick)
- return
-
-def __CheckLeaveProtectTimeout(tick):
- gameFB = GameWorld.GetGameFB()
- playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
- playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
- playerLeaveTickA = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDA)
- playerLeaveTickB = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDB)
- if not playerLeaveTickA and not playerLeaveTickB:
- return
-
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- if playerLeaveTickA > playerLeaveTickB:
- if tick - playerLeaveTickA < fbTimeList[Def_Time_Protect] * 1000:
- return
- else:
- if tick - playerLeaveTickB < fbTimeList[Def_Time_Protect] * 1000:
- return
-
- winner, winnerID, loser, loserID = __GetTimeoutWinerInfo(tick)
- # 对手没来,直接获胜
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- GameWorld.Log("战斗中对手离线超时,直接结束!roomID=%s,winnerID=%s,loserID=%s" % (roomID, winnerID, loserID))
- __DoFBPKAllOver(winner, winnerID, loser, loserID, Def_OverType_PlayerExit, tick)
- return True
-
-def __GetTimeoutWinerInfo(tick):
- ''' 时间超时,获取获胜的玩家
- 战斗阶段有两个玩家时优先比较输出
- 其他情况则在线玩家获胜,如果没有玩家在线,则最迟离线的获胜
- '''
- winner, winnerID, loser, loserID = None, 0, None, 0
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- gameFB = GameWorld.GetGameFB()
- fbStep = gameFB.GetFBStep()
- copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
- playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
- playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
-
- # 战斗阶段有两个玩家时优先比较输出
- if fbStep == FB_State_Fight and copyMapPlayerManager.GetPlayerCount() == 2:
- # 时间到还没分出胜负, 根据以下规则决定胜负,这里用玩家ID处理,防止结算时都掉线了导致没有结果
- # 伤害输出 > 优先到达时间 > 剩余HP > 最大HP > playerID
-
- GameWorld.Log("两个人都在线,根据超时规则判断胜负玩家! roomID=%s" % (roomID))
- playerInfoList = []
- for playerID in [playerIDA, playerIDB]:
- player = copyMapPlayerManager.FindPlayerByID(playerID)
- # 还是离线时间的,走掉线逻辑,越晚掉线的赢;需要加这个逻辑主要是因为当玩家没有触发完整登录流程导致玩家在线但是没有触发DoEnter
- playerLeaveTick = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerID)
- if playerLeaveTick:
- pvpDamage, sortTick, curHP, curMaxHP = 0, 0, 0, 0
- playerInfoList.append([pvpDamage, sortTick, curHP, curMaxHP, playerLeaveTick, playerID, player])
- GameWorld.Log("PK超时: playerLeaveTick=%s" % (playerLeaveTick), playerID)
- continue
- pvpDamage = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_PVPDamage)
- pvpDamTick = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_PVPDamUpdTick)
- sortTick = tick - pvpDamTick
- curHP = 0 if not player else GameObj.GetHP(player)
- curMaxHP = 0 if not player else GameObj.GetMaxHP(player)
- playerInfoList.append([pvpDamage, sortTick, curHP, curMaxHP, playerLeaveTick, playerID, player])
- GameWorld.Log("PK超时: pvpDamge=%s,pvpDamTick=%s,tick=%s,sortTick=%s,HP=%s/%s,playerLeaveTick=%s"
- % (pvpDamage, pvpDamTick, tick, sortTick, curHP, curMaxHP, playerLeaveTick), playerID)
-
- playerInfoList.sort(reverse=True)
- GameWorld.Log("PK超时, 进入结算!playerInfoList=%s" % str(playerInfoList))
- winner = playerInfoList[0][-1] if len(playerInfoList) > 0 else None
- loser = playerInfoList[1][-1] if len(playerInfoList) > 1 else None
- winnerID = 0 if not winner else winner.GetPlayerID()
- loserID = 0 if not loser else loser.GetPlayerID()
- return winner, winnerID, loser, loserID
-
- # 其他情况则在线玩家获胜,如果没有玩家在线,则最迟离线的获胜
- for i in xrange(copyMapPlayerManager.GetPlayerCount()):
- player = copyMapPlayerManager.GetPlayerByIndex(i)
- if player == None or player.IsEmpty():
- continue
- playerID = player.GetPlayerID()
- if playerID not in [playerIDA, playerIDB]:
- GameWorld.ErrLog("副本中玩家不在进入的玩家ID里,不处理! roomID=%s,playerID=%s" % (roomID, playerID))
- continue
- winner = player
- winnerID = player.GetPlayerID()
- GameWorld.Log("超时结算,玩家在线,直接获胜: roomID=%s,winnerID=%s" % (roomID, winnerID))
- break
-
- if not winner:
- playerLeaveTickA = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDA)
- playerLeaveTickB = gameFB.GetGameFBDictByKey(GameFBDict_PlayerLeaveTick % playerIDB)
- GameWorld.Log("超时结算,没有玩家在线,后离线的获胜: playerLeaveTickA=%s,playerLeaveTickB=%s" % (playerLeaveTickA, playerLeaveTickB))
- # 离线tick较大的就是比较晚离线的
- if playerLeaveTickA > playerLeaveTickB:
- winnerID = playerIDA
- loserID = playerIDB
- else:
- winnerID = playerIDB
- loserID = playerIDA
- else:
- loserID = playerIDB if playerIDA == winnerID else playerIDA
- return winner, winnerID, loser, loserID
-
-##副本准备时间
-def __DoLogic_MapPrepare(tick):
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- GameWorld.DebugLog("__DoLogic_MapPrepare ... %s" % fbTimeList[Def_Time_MapPrepare])
- if tick - GameWorld.GetGameFB().GetFBStepTick() < fbTimeList[Def_Time_MapPrepare] * 1000:
- return
-
- FBCommon.SetFBStep(FB_State_Fight, tick)
- FBCommon.Sync_Player_TimeTick(ChConfig.tttTowerTake, fbTimeList[Def_Time_Fight] * 1000)
- FBCommon.SyncDynamicBarrierState(IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 2), 0)
-
- # 通知回合开始
- helpDict = __GetFBHelpInfo()
- helpDict["isStart"] = 1
- copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
- for i in xrange(copyMapPlayerManager.GetPlayerCount()):
- player = copyMapPlayerManager.GetPlayerByIndex(i)
- if player == None or player.IsEmpty():
- continue
- FBCommon.Notify_FBHelp(player, helpDict)
-
- return
-
-##战斗阶段
-def __DoLogic_MapFight(tick):
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- if tick - GameWorld.GetGameFB().GetFBStepTick() < fbTimeList[Def_Time_Fight] * 1000:
- return
-
- winner, winnerID, loser, loserID = __GetTimeoutWinerInfo(tick)
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- GameWorld.Log("PK超时, 进入结算! roomID=%s,winnerID=%s,loserID=%s" % (roomID, winnerID, loserID))
- __DoLogicAddPlayerWinCnt(winner, winnerID, loser, loserID, Def_OverType_TimeOut, tick)
- return
-
-##复活阶段阶段
-def __DoLogic_Reborn(tick):
- gameFB = GameWorld.GetGameFB()
-
- helpDict = __GetFBHelpInfo()
-
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- prepareTime = fbTimeList[Def_Time_MapPrepare] * 1000
- helpDict["prepareTime"] = prepareTime
-
- roundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
- winnerID = gameFB.GetGameFBDictByKey(FB_RoundWinPlayerID % roundNum)
-
- nextRoundNum = gameFB.GetGameFBDictByKey(FB_RoundNum) + 1
- gameFB.SetGameFBDict(FB_RoundNum, nextRoundNum)
-
- copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()
- for i in xrange(copyMapPlayerManager.GetPlayerCount()):
- player = copyMapPlayerManager.GetPlayerByIndex(i)
- if player == None or player.IsEmpty():
- continue
-
- playerID = player.GetPlayerID()
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_RoundNum, nextRoundNum)
-
- if player.GetPlayerAction() == IPY_GameWorld.paDie or GameObj.GetHP(player) <= 0:
- GameWorld.DebugLog("复活玩家...", player.GetPlayerID())
- ChPlayer.PlayerRebornByType(player, ChConfig.rebornType_System, tick, isAddSuperBuff=False)
- __ResetPlayerState(gameFB, player, playerID)
- elif winnerID and playerID != winnerID:
- GameWorld.DebugLog("平局,输的玩家回满血!", playerID)
- __ResetPlayerState(gameFB, player, playerID)
- else:
- __ResetPlayerState(gameFB, player, playerID, False)
-
- FBCommon.Notify_FBHelp(player, helpDict)
-
- GameWorld.Log("开始下一回合: nextRoundNum=%s" % (nextRoundNum))
-
- # 重置伤害输出
- playerIDA = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 1)
- playerIDB = gameFB.GetGameFBDictByKey(GameFBDict_FBPlayerID % 2)
- gameFB.SetPlayerGameFBDict(playerIDA, FBPDict_PVPDamage, 0)
- gameFB.SetPlayerGameFBDict(playerIDA, FBPDict_PVPDamUpdTick, tick)
- gameFB.SetPlayerGameFBDict(playerIDB, FBPDict_PVPDamage, 0)
- gameFB.SetPlayerGameFBDict(playerIDB, FBPDict_PVPDamUpdTick, tick)
-
- # 进入准备倒计时,开始下一局准备
- FBCommon.SetFBStep(FB_State_MapPrepare, tick)
- #FBCommon.Sync_Player_TimeTick(ChConfig.tttWaitStart, prepareTime)
- return
-
-##比赛结束的空闲时间
-def __DoLogic_LeaveTime(tick):
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- if tick - GameWorld.GetGameFB().GetFBStepTick() < fbTimeList[Def_Time_Leave] * 1000:
- return
- FBCommon.SetFBStep(FB_State_Close, tick)
- GameWorldProcess.CloseFB(tick)
- return
-
-## PVP伤害相关
-def OnPVPDamage(curPlayer, damageValue, tagPlayer, tick):
- playerID = curPlayer.GetPlayerID()
- tagPlayerID = tagPlayer.GetPlayerID()
-
- gameFB = GameWorld.GetGameFB()
- curPlayerDamage = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_PVPDamage)
- updDamage = min(ChConfig.Def_UpperLimit_DWord, curPlayerDamage + damageValue)
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_PVPDamage, updDamage)
- gameFB.SetPlayerGameFBDict(playerID, FBPDict_PVPDamUpdTick, tick)
- GameWorld.DebugLog("OnPVPDamage playerID=%s,tagPlayerID=%s,damageValue=%s,updDamage=%s,tick=%s"
- % (playerID, tagPlayerID, damageValue, updDamage, tick))
-
- #helpDict = {"PVPDamage":[playerID, updDamage, tick]}
- #FBCommon.Notify_FBHelp(curPlayer, helpDict)
- #FBCommon.Notify_FBHelp(tagPlayer, helpDict)
- return
-
-##处理副本中杀死玩家逻辑
-def DoFBOnKill_Player(curPlayer, defender, tick):
- winnerID = curPlayer.GetPlayerID()
- loserID = defender.GetPlayerID()
- roomID = GameWorld.GetGameWorld().GetPropertyID()
-
- GameWorld.Log("DoFBOnKill_Player roomID=%s,winnerID=%s,loserID=%s" % (roomID, winnerID, loserID), winnerID)
- if GameWorld.GetGameFB().GetFBStep() != FB_State_Fight:
- return
-
- __DoLogicAddPlayerWinCnt(curPlayer, winnerID, defender, loserID, Def_OverType_Kill, tick)
- return True
-
-def __DoLogicAddPlayerWinCnt(winner, winnerID, loser, loserID, overType, tick):
-
- gameFB = GameWorld.GetGameFB()
- roomID = GameWorld.GetGameWorld().GetPropertyID()
-
- winnerWinCnt = gameFB.GetGameFBDictByKey(GameFBDict_PlayerWinCnt % winnerID)
- updWinCnt = winnerWinCnt + 1
- gameFB.SetGameFBDict(GameFBDict_PlayerWinCnt % winnerID, updWinCnt)
-
- roundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
- gameFB.SetGameFBDict(FB_RoundWinPlayerID % roundNum, winnerID)
-
- GameWorld.Log("回合结束: roomID=%s,roundNum=%s,winnerID=%s,loserID=%s,updWinCnt=%s" % (roomID, roundNum, winnerID, loserID, updWinCnt))
- isOver = (updWinCnt >= IpyGameDataPY.GetFuncCfg("CrossRealmPKFB", 3))
- if not isOver:
- if winner:
- clearDeBuff = False
- # 胜利者马上清除负面buff,防止死亡导致回合表现异常,如中毒
- for buffType in [IPY_GameWorld.bfDeBuff, IPY_GameWorld.bfProcessDeBuff, IPY_GameWorld.bfActionBuff]:
- buffTuple = SkillCommon.GetBuffManagerByBuffType(winner, buffType)
- if buffTuple:
- buffState = buffTuple[0]
- buffCount = buffState.GetBuffCount()
- if buffCount:
- clearDeBuff = True
- buffState.Clear()
- GameWorld.DebugLog("胜者马上清除 buffType=%s,buffCount=%s" % (buffType, buffCount), winner.GetPlayerID())
-
- if clearDeBuff:
- PlayerControl.PlayerControl(winner).RefreshAllState()
-
- FBCommon.SetFBStep(FB_State_Reborn, tick)
- return
-
- GameWorld.Log(" 已达到最大胜场,获得最终胜利!winnerID=%s" % winnerID)
- __DoFBPKAllOver(winner, winnerID, loser, loserID, overType, tick)
- return
-
-def __ResetPlayerState(gameFB, player, playerID, resetAttr=True):
- posX = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_ResetPosX)
- posY = gameFB.GetPlayerGameFBDictByKey(playerID, FBPDict_ResetPosY)
- player.ResetPos(posX, posY)
-
- if not resetAttr:
- return
-
- if GameObj.GetHP(player) != GameObj.GetMaxHP(player):
- GameObj.SetHP(player, GameObj.GetMaxHP(player))
-
- if PlayerControl.GetProDef(player) != PlayerControl.GetMaxProDef(player):
- PlayerControl.SetProDef(player, PlayerControl.GetMaxProDef(player))
-
- SkillCommon.ResetAllSkillCD(player)
- return
-
-## 跨服PK结束处理,注意 winner、loser 参数可能为None
-def __DoFBPKAllOver(winner, winnerID, loser, loserID, overType, tick):
- gameFB = GameWorld.GetGameFB()
-
- roundWinerIDList = []
- roundNum = gameFB.GetGameFBDictByKey(FB_RoundNum)
- for roundNum in xrange(1, roundNum + 1):
- roundWinerIDList.append(gameFB.GetGameFBDictByKey(FB_RoundWinPlayerID % roundNum))
-
- #副本状态进入关闭倒计时
- fbTimeList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKFB", 1)
- FBCommon.Sync_Player_TimeTick(ChConfig.tttLeaveMap, fbTimeList[Def_Time_Leave] * 1000)
- FBCommon.SetFBStep(FB_State_Leave, tick)
-
- #发送一条消息到GameServer通知PK对战结束,因为地图可能对手没来导致没有失败玩家ID,所以结算统一在GameServer处理
- overType = 1 if overType in [Def_OverType_LackPlayer, Def_OverType_PlayerExit] else 0
- roomID = GameWorld.GetGameWorld().GetPropertyID()
- sendMsg = str([roomID, winnerID, loserID, roundWinerIDList, overType])
- GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "CrossPKOver", sendMsg, len(sendMsg))
- GameWorld.Log("PK结算SendToGameServer: roomID=%s,winnerID=%s,loserID=%s,roundWinerIDList=%s,overType=%s"
- % (roomID, winnerID, loserID, roundWinerIDList, overType))
- return
-
-#关系有3层,无-友好-敌人
-def CheckPlayersRelation_IsFriend(curPlayer, curTagPlayer):
- return not CanAttackPlayer(curPlayer, curTagPlayer)
-
-##副本中,攻击队友逻辑
-def DoCanAttackTeamer(curPlayer, curTagPlayer):
- return CanAttackPlayer(curPlayer, curTagPlayer)
-
-##副本中,是否可攻击
-def CanAttackPlayer(curPlayer, curTagPlayer):
- fbStep = GameWorld.GetGameFB().GetFBStep()
-
- if fbStep != FB_State_Fight:
- GameWorld.DebugLog("非战斗阶段,不可攻击!")
- return False
return True
+
+def OnMirrorBattleOver(battleID):
+ ## 镜像战斗结束
+
+ battle = MirrorAttack.GetMirrorBattleByID(battleID)
+ if not battle:
+ return
+ isLogout = battle.isLogout
+
+ mapID = battle.mapID
+ funcLineID = battle.funcLineID
+ winFaction = battle.winFaction
+ curPlayerID = battle.requestID # 副本所属玩家ID,该玩家不一定参与实际战斗
+ curIsWin = 0
+ tagPlayerID = 0
+ GameWorld.DebugLog("镜像战斗结算: mapID=%s,funcLineID=%s,winFaction=%s,isLogout=%s" % (mapID, funcLineID, winFaction, isLogout), battleID)
+
+ playerMgr = GameWorld.GetMapCopyPlayerManager()
+ for playerID, faction in battle.playerFactionDict.items():
+ curPlayer = playerMgr.FindPlayerByID(playerID)
+ if not curPlayer:
+ continue
+ realPlayerID = curPlayer.GetRealPlayerID()
+ isWin = (faction == winFaction)
+ GameWorld.DebugLog("剩余血量: %s/%s,playerID=%s,realPlayerID=%s,faction=%s,isWin=%s"
+ % (GameObj.GetHP(curPlayer), GameObj.GetMaxHP(curPlayer), playerID, realPlayerID, faction, isWin), battleID)
+ if isWin and faction == 1:
+ curIsWin = 1
+ if faction != 1 and not tagPlayerID:
+ tagPlayerID = realPlayerID
+
+ if not curPlayerID:
+ return
+
+ curPlayer = playerMgr.FindPlayerByID(curPlayerID)
+ if not curPlayer:
+ return
+
+ PlayerCrossRealmPK.SendPKOver(curPlayer, tagPlayerID, curIsWin)
+ return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
index f9bb8a7..be5933c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -3149,7 +3149,6 @@
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_AutoTruck, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_CrossRegisterMap, 0)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_IsCrossPKMatching, 0)
#下线召回宠物
PetControl.ReCallFightPet(curPlayer)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/CrossPK.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/CrossPK.py
index dfcf81b..96a7033 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/CrossPK.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/GMTExec/CrossPK.py
@@ -22,11 +22,7 @@
import 其他模块需要写在此函数里,不然无法引用到
'''
import GameWorld
- import CrossRealmPlayer
import PlayerCrossRealmPK
- import PlayerControl
- import ShareDefine
- import ChConfig
orderId = exec_locals["orderId"]
cmdInfo = exec_locals["cmdInfo"]
@@ -47,40 +43,8 @@
pkScore = 32000 # 积分
cWinCount = 50 # 连胜
# =================================================================
-
- zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
- seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
- seasonState = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
-
- errorMsg = "OK"
- if not zoneID or not seasonID or seasonState == 2:
- errorMsg = "zone season or state error."
- else:
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, cWinCount)
- if cWinCount > 0:
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CLoseCount, 0)
-
- # 请求查询跨服服务器
- playerInfoDict = {"accID":curPlayer.GetAccID(),
- "playerID":curPlayer.GetPlayerID(),
- "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
- "playerJob":curPlayer.GetJob(),
- "face":curPlayer.GetFace(),
- "facePic":curPlayer.GetFacePic(),
- "fightPower":PlayerControl.GetFightPower(curPlayer),
- "realmLV":curPlayer.GetOfficialRank(),
- "ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore),
- "pkScore":pkScore, "danLV":danLV, "cWinCount":cWinCount,
- }
- resultDict.update({"PlayerInfo":playerInfoDict})
- dataMsg = {"ZoneID":zoneID, "SeasonID":seasonID, "GMSetCrossPK":1, "PlayerInfo":playerInfoDict}
- GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKBillboard, dataMsg)
- PlayerCrossRealmPK.SyncCrossRealmPKPlayerInfo(curPlayer)
-
+ PlayerCrossRealmPK.GMSetPlayerCrossPKData(curPlayer, danLV, pkScore, cWinCount, resultDict)
GameWorld.Log("This is MameServer GMT_Execfile run %s. orderId=%s" % (cmdInfo, orderId), curPlayer.GetPlayerID())
- resultDict.update({"zoneID":zoneID, "seasonID":seasonID, "seasonState":seasonState, "errorMsg":errorMsg})
return
exec_locals = locals()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
index 3fdbb89..d3ac587 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -1804,10 +1804,6 @@
NotifyCode(curPlayer, "CrossMap4")
return
- if PlayerCrossRealmPK.GetIsCrossPKMatching(curPlayer):
- NotifyCode(curPlayer, "CrossMap3")
- return
-
if PlayerState.IsInPKState(curPlayer):
NotifyCode(curPlayer, "SingleEnterPK", [mapID])
return
@@ -2013,12 +2009,6 @@
if isNotify:
NotifyCode(curPlayer, "SingleEnterPK", [mapID])
return ShareDefine.EntFBAskRet_PKState
-
- ## 跨服PK匹配中
- if PlayerCrossRealmPK.GetIsCrossPKMatching(curPlayer):
- if isNotify:
- NotifyCode(curPlayer, "CrossMatching8", [mapID])
- return ShareDefine.EntFBAskRet_CrossPKMatching
## 跨服地图中
if GetCrossMapID(curPlayer) and mapID not in ChConfig.Def_CrossMapIDList:
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 e402266..c94c0bb 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCrossRealmPK.py
@@ -36,20 +36,12 @@
import GameObj
import PlayerGubao
-## 是否匹配中
-def SetIsCrossPKMatching(curPlayer, isMatching):
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_IsCrossPKMatching, isMatching)
- return
-def GetIsCrossPKMatching(curPlayer):
- return curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_IsCrossPKMatching) and IsCrossRealmPKMatchState()
-
def DoPlayerOnDay(curPlayer):
if GameWorld.IsCrossServer():
return
totalScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)
if not totalScore:
return
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_OnDayScore, totalScore)
zoneID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ZoneID)
seasonID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonID)
@@ -71,6 +63,7 @@
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_ItemAddCount, 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_RefreshCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayPKCountAwardState, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayWinCountAwardState, 0)
SyncCrossRealmPKPlayerInfo(curPlayer)
@@ -176,7 +169,6 @@
# 重置状态
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, 0)
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_OnDayScore, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_WinCount, 0)
@@ -186,6 +178,7 @@
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_ItemAddCount, 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_RefreshCount, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayPKCountAwardState, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayWinCountAwardState, 0)
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLVAwardState, 0)
@@ -205,7 +198,7 @@
#struct tagCMCrossRealmPKMatch
#{
# tagHead Head;
-# BYTE Type; // 0-取消匹配; 1-进行匹配
+# BYTE Type; // 0-查询匹配;1-刷新匹配
#};
def OnCrossRealmPKMatch(index, clientData, tick):
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
@@ -213,6 +206,46 @@
playerID = curPlayer.GetPlayerID()
requestType = clientData.Type
+ GameWorld.DebugLog("跨服PK匹配请求: type=%s,accID=%s" % (requestType, accID), playerID)
+
+ # 刷新匹配
+ if requestType == 1:
+ if not CheckCanMatch(curPlayer):
+ return
+
+ refreshCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_RefreshCount)
+ freeRefreshCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchRefresh", 1)
+ if freeRefreshCountMax <= 0 or refreshCount < freeRefreshCountMax:
+ GameWorld.DebugLog("免费刷新: refreshCount=%s < %s" % (refreshCount, freeRefreshCountMax), playerID)
+ else:
+ refreshBuyCount = max(0, refreshCount - freeRefreshCountMax)
+ refreshBuyCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchRefresh", 2)
+ if refreshBuyCountMax and refreshBuyCount >= refreshBuyCountMax:
+ GameWorld.DebugLog("购买刷新次数已达每日上限! refreshBuyCount=%s >= %s" % (refreshBuyCount, refreshBuyCountMax), playerID)
+ return
+ costMoney = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKMatchRefresh", 3))
+ moneyType = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchRefresh", 4)
+ GameWorld.DebugLog("付费刷新: refreshCount=%s,refreshBuyCount=%s,costMoney=%s,moneyType=%s"
+ % (refreshCount, refreshBuyCount, costMoney, moneyType), playerID)
+ if not PlayerControl.PayMoney(curPlayer, moneyType, costMoney, ChConfig.Def_Cost_CrossRealmPK, {"Event":"Refresh", "refreshBuyCount":refreshBuyCount}):
+ return
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_RefreshCount, refreshCount + 1)
+ SyncCrossRealmPKPlayerInfo(curPlayer)
+
+ dataMsg = {
+ "requestType":requestType,
+ "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # 赛季ID
+ "zoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PK赛区
+ "playerID":playerID,
+ "fightPower":PlayerControl.GetFightPower(curPlayer),
+ }
+ GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKMatch, dataMsg)
+ GameWorld.DebugLog("发送请求匹配到跨服服务器 dataMsg=%s" % str(dataMsg), playerID)
+ return
+
+def CheckCanMatch(curPlayer):
+ ## 可否匹配、挑战
+ playerID = curPlayer.GetPlayerID()
if GameWorld.IsCrossServer():
GameWorld.DebugLog("跨服服务器无法发起匹配!", playerID)
return
@@ -239,43 +272,7 @@
#PlayerControl.NotifyCode(curPlayer, "MatchIsNotOpen")
return
- GameWorld.Log("收到跨服PK匹配: type=%s,accID=%s" % (requestType, accID), playerID)
-
- # 进行匹配
- if requestType == 1:
- if not CheckHavePKCount(curPlayer):
- return
-
- dataMsg = {
- "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # 赛季ID
- "pkZoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PK赛区
- "accID":accID,
- "playerID":playerID,
- "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
- "playerJob":curPlayer.GetJob(),
- "playerLV":curPlayer.GetLV(),
- "face":curPlayer.GetFace(),
- "facePic":curPlayer.GetFacePic(),
- "maxHP":GameObj.GetMaxHP(curPlayer),
- "maxProDef":PlayerControl.GetMaxProDef(curPlayer),
- "fightPower":PlayerControl.GetFightPower(curPlayer),
- "realmLV":curPlayer.GetOfficialRank(),
- "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)
- GameWorld.Log(" 发送请求匹配到跨服服务器 dataMsg=%s" % str(dataMsg), playerID)
-
- # 取消匹配
- else:
- sendMsg = "ClientCancel"
- GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "CrossRealmPKCancel", sendMsg, len(sendMsg))
- GameWorld.Log(" 发送取消匹配到GameServer sendMsg=%s" % str(sendMsg), playerID)
-
- return
+ return True
def CheckHavePKCount(curPlayer):
## 检查是否有PK次数
@@ -294,24 +291,20 @@
def CrossServerMsg_PKOverInfo(curPlayer, overInfo):
## 收到跨服服务器的PK结算信息
playerID = curPlayer.GetPlayerID()
- roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState = overInfo
+ zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName = overInfo
isWinner = winnerID == playerID
- GameWorld.Log("地图收到跨服PK结算: isWinner=%s,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"
- % (isWinner, roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState), playerID)
+ GameWorld.Log("地图收到跨服PK结算: isWinner=%s,zoneID=%s,seasonID=%s,timeStr=%s,winnerID=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s"
+ % (isWinner, zoneID, seasonID, timeStr, winnerID, pkScore, danLV, cWinCount, addScore, tagPlayerID), playerID)
isToday = GameWorld.CheckTimeIsSameServerDayEx(GameWorld.ChangeTimeStrToNum(timeStr))
if not __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):
return
- ## 跨服已经通知过了,证明还在跨服服务器,不做以下的处理
- if notifyState:
- return
-
overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()
overPack.TimeStr = timeStr
- overPack.OverType = overType
+ overPack.OverType = 0
overPack.WinnerID = winnerID
- overPack.RoundWinnerID = roundWinnerIDList
+ overPack.RoundWinnerID = []
overPack.RoundCount = len(overPack.RoundWinnerID)
overPack.AddScore = addScore
overPack.Score = pkScore
@@ -385,11 +378,13 @@
#{
# tagHead Head;
# BYTE IsWin; //是否获胜
+# DWORD TagPlayerID; //目标玩家ID
#};
def OnCrossRealmPKRobotOver(index, clientData, tick):
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
playerID = curPlayer.GetPlayerID()
isWinner = clientData.IsWin
+ tagPlayerID = clientData.TagPlayerID
if GameWorld.IsCrossServer():
GameWorld.DebugLog("跨服服务器无法发起机器人结算!", playerID)
@@ -398,14 +393,69 @@
if not CheckHavePKCount(curPlayer):
return
- dataMsg = {
- "playerID":playerID,
- "isWinner":isWinner,
- }
- GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKRobotOver, dataMsg)
- GameWorld.Log("同步跨服服务器与机器人PK结算: %s" % str(dataMsg), playerID)
+ SendPKOver(curPlayer, tagPlayerID, isWinner)
return
+def SendPKOver(curPlayer, tagPlayerID, isWinner):
+ ## 发送给跨服PK结算
+ playerID = curPlayer.GetPlayerID()
+ dataMsg = {
+ "playerID":playerID,
+ "tagPlayerID":tagPlayerID,
+ "isWinner":isWinner,
+ "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # 赛季ID
+ "pkZoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PK赛区
+ "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
+ "playerJob":curPlayer.GetJob(),
+ "face":curPlayer.GetFace(),
+ "facePic":curPlayer.GetFacePic(),
+ "realmLV":curPlayer.GetOfficialRank(),
+ "fightPower":PlayerControl.GetFightPower(curPlayer),
+ "pkScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore), # 当前积分
+ "danLV":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV), # 当前段位
+ "cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount), # 连胜次数
+ }
+ GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKOver, dataMsg)
+ GameWorld.DebugLog("同步跨服服务器PK结算: %s" % str(dataMsg), playerID)
+ return
+
+def GMSetPlayerCrossPKData(curPlayer, danLV, pkScore, cWinCount=None, resultDict=None):
+ ## GM设置玩家跨服PK数据,一般用于测试或修复外网数据
+ zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)
+ seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)
+ seasonState = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState)
+
+ errorMsg = ""
+ playerInfoDict = {}
+ if not zoneID or not seasonID or seasonState == 2:
+ errorMsg = "zone season or state error."
+ else:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)
+ if cWinCount >= 0:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, cWinCount)
+ if cWinCount > 0:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CLoseCount, 0)
+ else:
+ cWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CLoseCount)
+
+ # 请求查询跨服服务器
+ playerInfoDict = {"accID":curPlayer.GetAccID(),
+ "playerID":curPlayer.GetPlayerID(),
+ "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),
+ "playerJob":curPlayer.GetJob(),
+ "face":curPlayer.GetFace(),
+ "facePic":curPlayer.GetFacePic(),
+ "realmLV":curPlayer.GetOfficialRank(),
+ "pkScore":pkScore, "danLV":danLV, "cWinCount":cWinCount,
+ }
+ dataMsg = {"ZoneID":zoneID, "SeasonID":seasonID, "PlayerInfo":playerInfoDict}
+ GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKBillboard, dataMsg)
+ SyncCrossRealmPKPlayerInfo(curPlayer)
+
+ if resultDict:
+ resultDict.update({"zoneID":zoneID, "seasonID":seasonID, "seasonState":seasonState, "errorMsg":errorMsg, "PlayerInfo":playerInfoDict})
+ return errorMsg
#// C1 02 跨服PK购买次数 #tagCMCrossRealmPKBuy
#
@@ -721,6 +771,7 @@
pkPlayerInfo.DayWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayWinCount)
pkPlayerInfo.DayBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)
pkPlayerInfo.DayItemAddCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)
+ pkPlayerInfo.DayRefreshCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_RefreshCount)
NetPackCommon.SendFakePack(curPlayer, pkPlayerInfo)
return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
index dde8e67..bc48255 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerViewCacheTube.py
@@ -20,6 +20,7 @@
import PlayerControl
import IPY_GameWorld
import ChPyNetSendPack
+import PyGameDataStruct
import ChMapToGamePyPack
import PlayerMagicWeapon
import Operate_EquipStone
@@ -36,8 +37,11 @@
import PlayerPet
import GameObj
+import base64
import time
import json
+
+TempDBPlayer = PyGameDataStruct.tagDBPlayer()
Def_Process_Tick = "ProcessPlayerCache"
@@ -60,6 +64,13 @@
UpdateGameServerPlayerCache(curPlayer, tick, False)
return
+def GetDBPlayerByPackData(packData):
+ ## 根据 curPlayer.GetPackData() 打包返回的数据获取DBPlayer数据
+ TempDBPlayer.clear()
+ if packData:
+ TempDBPlayer.readData(base64.b64decode(packData))
+ return TempDBPlayer
+
def GetSyncPlayerPackData(curPlayer, force=False):
playerID = curPlayer.GetPlayerID()
fightPower = curPlayer.GetFightPower()
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_CrossPKMatching.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_CrossPKMatching.py
deleted file mode 100644
index 35bd430..0000000
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_CrossPKMatching.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/python
-# -*- coding: GBK -*-
-#-------------------------------------------------------------------------------
-#
-##@package Player.RemoteQuery.GY_Query_CrossPKMatching
-#
-# @todo:是否跨服匹配状态更新
-# @author hxp
-# @date 2018-12-26
-# @version 1.0
-#
-# 详细描述: 是否跨服匹配状态更新
-#
-#-------------------------------------------------------------------------------
-#"""Version = 2018-12-26 18:30"""
-#-------------------------------------------------------------------------------
-
-import PlayerCrossRealmPK
-import GameWorld
-
-#------------------------------------------------------------------------------
-## 跨服赛报名调用接口
-# @param query_Type 请求类型
-# @param query_ID 请求的玩家ID
-# @param packCMDList 发包命令
-# @param tick 当前时间
-# @return "True" or "False" or ""
-# @remarks 函数详细说明.
-def DoLogic(query_Type, query_ID, packCMDList, tick):
- return
-
-
-#------------------------------------------------------------------------------
-## 执行结果
-# @param curPlayer 发出请求的玩家
-# @param callFunName 功能名称
-# @param funResult 查询的结果
-# @param tick 当前时间
-# @return None
-# @remarks 函数详细说明.
-def DoResult(curPlayer, callFunName, funResult, tick):
- isMatching = eval(funResult)
- GameWorld.Log("GY_Query_CrossPKMatching isMatching=%s" % isMatching, curPlayer.GetPlayerID())
- if not curPlayer:
- return
- PlayerCrossRealmPK.SetIsCrossPKMatching(curPlayer, isMatching)
- return
-
-
-
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py
index 9c98f39..b928a72 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/RemoteQuery/GY_Query_PlayerMirror.py
@@ -56,7 +56,8 @@
if msgType == "PackDataSyncState":
PlayerViewCacheTube.UpdPackDataSyncState(curPlayer, msgData)
-
+ if msgData.get("PackDataCross"): # 如果跨服需要的,立即同步一次
+ PlayerViewCacheTube.UpdateGameServerPlayerCache(curPlayer, tick)
elif msgType == "PullPlayerPackData":
msgInfo = msgData
__DoPullPlayerPackData(curPlayer, msgInfo, tick)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameDataStruct.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameDataStruct.py
new file mode 100644
index 0000000..7af8c46
--- /dev/null
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/PyGameDataStruct.py
@@ -0,0 +1,665 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#
+##@package E:/GameSVN/U3DGame/ProjectSServer/ServerPython/CoreServerGroup/GameServer/Script/PyGameDataStruct.py
+# @todo:
+#
+# @author: Alee
+# @date 2017-8-21 下午04:21:36
+# @version 1.0
+#
+# @note: CodeMaker PyGameServerSaveData.py生成
+#
+#---------------------------------------------------------------------
+import ctypes
+from ctypes import (Structure, memset, memmove, sizeof, addressof, create_string_buffer, string_at)
+import CommFunc
+
+#玩家详细信息#tagDBPlayer
+class tagDBPlayer(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PlayerID', ctypes.c_ulong),
+ ('AccID', ctypes.c_char * 65),
+ ('PlayerName', ctypes.c_char * 33),
+ ('AccState', ctypes.c_ubyte),
+ ('IsDeleted', ctypes.c_ubyte),
+ ('GMLevel', ctypes.c_ubyte),
+ ('Sex', ctypes.c_int),
+ ('Hair', ctypes.c_int),
+ ('HairColor', ctypes.c_int),
+ ('Face', ctypes.c_int),
+ ('FacePic', ctypes.c_int),
+ ('Job', ctypes.c_int),
+ ('RoleType', ctypes.c_ulong),
+ ('ReincarnationLv', ctypes.c_ushort),
+ ('LV', ctypes.c_int),
+ ('TotalExp', ctypes.c_ulong),
+ ('FamilyID', ctypes.c_ulong),
+ ('FamilyName', ctypes.c_char * 33),
+ ('Country', ctypes.c_int),
+ ('TeamHornor', ctypes.c_ulong),
+ ('FamilyHornor', ctypes.c_ulong),
+ ('FamilyActiveValue', ctypes.c_ulong),
+ ('LastWeekFamilyActiveValue', ctypes.c_ulong),
+ ('CountryHornor', ctypes.c_ulong),
+ ('CountryLastWeekHornor', ctypes.c_ulong),
+ ('Mate', ctypes.c_ulong),
+ ('Gold', ctypes.c_ulong),
+ ('GoldPaper', ctypes.c_ulong),
+ ('Silver', ctypes.c_ulong),
+ ('SilverPaper', ctypes.c_ulong),
+ ('FightPoint', ctypes.c_ulong),
+ ('HappyPoint', ctypes.c_ulong),
+ ('MapID', ctypes.c_ulong),
+ ('DataMapID', ctypes.c_ulong),
+ ('CopyMapID', ctypes.c_ulong),
+ ('PosX', ctypes.c_ushort),
+ ('PosY', ctypes.c_ushort),
+ ('FromMapID', ctypes.c_ulong),
+ ('FromCopyMapID', ctypes.c_ulong),
+ ('FromPosX', ctypes.c_ushort),
+ ('FromPosY', ctypes.c_ushort),
+ ('State', ctypes.c_int),
+ ('HP', ctypes.c_ulong),
+ ('MP', ctypes.c_ulong),
+ ('XP', ctypes.c_ulong),
+ ('HPRestoreSetting', ctypes.c_ushort),
+ ('MPRestoreSetting', ctypes.c_ushort),
+ ('FreePoint', ctypes.c_ulong),
+ ('FreeSkillPoint', ctypes.c_ulong),
+ ('STR', ctypes.c_int),
+ ('PNE', ctypes.c_int),
+ ('PHY', ctypes.c_int),
+ ('CON', ctypes.c_int),
+ ('TotalSTR', ctypes.c_int),
+ ('TotalPNE', ctypes.c_int),
+ ('TotalPHY', ctypes.c_int),
+ ('TotalCON', ctypes.c_int),
+ ('Setting', ctypes.c_char * 100),
+ ('PKValue', ctypes.c_ushort),
+ ('FightPower', ctypes.c_ulong),
+ ('ActiveValue', ctypes.c_ushort),
+ ('PlayerType', ctypes.c_ubyte),
+ ('BackpackLV', ctypes.c_ubyte),
+ ('WarehouseLV', ctypes.c_ubyte),
+ ('HaveWarehousePsw', ctypes.c_ubyte),
+ ('WarehousePsw', ctypes.c_char * 15),
+ ('WarehouseLocked', ctypes.c_ubyte),
+ ('WarehouseGold', ctypes.c_ulong),
+ ('WarehouseSilver', ctypes.c_ulong),
+ ('TeamID', ctypes.c_ulong),
+ ('UseGoldType', ctypes.c_ubyte),
+ ('UseSilverType', ctypes.c_ubyte),
+ ('AttackMode', ctypes.c_ubyte),
+ ('RebornMapID', ctypes.c_ushort),
+ ('RebornPosX', ctypes.c_ushort),
+ ('RebornPosY', ctypes.c_ushort),
+ ('WeekOnlineTime', ctypes.c_ulong),
+ ('LastWeekOnlineTime', ctypes.c_ulong),
+ ('LogoffTime', ctypes.c_char * 30),
+ ('IsHideMask', ctypes.c_ubyte),
+ ('DayProcessGameEventCount', ctypes.c_ulong),
+ ('LoginIP', ctypes.c_char * 20),
+ ('LoginTime', ctypes.c_char * 30),
+ ('OnlineTime', ctypes.c_ulong),
+ ('FriendFavor', ctypes.c_ulong),
+ ('TeamPrivity', ctypes.c_ulong),
+ ('OfflineMinutes', ctypes.c_ulong),
+ ('Energy', ctypes.c_ulong),
+ ('ReceivedSalary', ctypes.c_ulong),
+ ('EquipShowSwitch', ctypes.c_ulong),
+ ('LuckValue', ctypes.c_ushort),
+ ('ExAttr1', ctypes.c_ulong),
+ ('ExAttr2', ctypes.c_ulong),
+ ('ExAttr3', ctypes.c_ulong),
+ ('ExAttr4', ctypes.c_ulong),
+ ('ExAttr5', ctypes.c_ulong),
+ ('Faction', ctypes.c_int),
+ ('InfamyValue', ctypes.c_ulong),
+ ('OfficialRank', ctypes.c_ubyte),
+ ('IsFindByLabel', ctypes.c_ubyte),
+ ('IsCloseFriendLabel', ctypes.c_ubyte),
+ ('ChangeCoinPointTotal', ctypes.c_ulong),
+ ('VIPLv', ctypes.c_ubyte),
+ ('VIPLvForPhone', ctypes.c_ubyte),
+ ('PhoneVIPStartTime', ctypes.c_double),
+ ('PhoneVIPEndTime', ctypes.c_double),
+ ('VsRoomId', ctypes.c_ulong),
+ ('ExAttr6', ctypes.c_ulong),
+ ('ExAttr7', ctypes.c_ulong),
+ ('ExAttr8', ctypes.c_ulong),
+ ('ExAttr9', ctypes.c_ulong),
+ ('ExAttr10', ctypes.c_ulong),
+ ('ModelMark', ctypes.c_ulong),
+ ('FromDataMapID', ctypes.c_ulong),
+ ('LastOrderId', ctypes.c_char * 40),
+ ('PrizeCoin', ctypes.c_ulong),
+ ('ExAttr11', ctypes.c_ulong),
+ ('ExAttr12', ctypes.c_ulong),
+ ('ExAttr13', ctypes.c_ulong),
+ ('ExAttr14', ctypes.c_ulong),
+ ('CreateRoleTime', ctypes.c_char * 30),
+ ('LVEx', ctypes.c_ushort),
+ ('LV2', ctypes.c_ushort),
+ ('ExpPoint', ctypes.c_ulong),
+ ('OperateInfo', ctypes.c_ulong),
+ ('Operate', ctypes.c_char * 15),
+ ('ServerID', ctypes.c_ulong),
+ ('ExAttr15', ctypes.c_ulong),
+ ('ExAttr16', ctypes.c_ulong),
+ ('ExAttr17', ctypes.c_ulong),
+ ('ExAttr18', ctypes.c_ulong),
+ ('ExAttr19', ctypes.c_ulong),
+ ('ExAttr20', ctypes.c_ulong),
+ ('HPEx', ctypes.c_ulong),
+ ('FightPowerEx', ctypes.c_ulong),
+ ('ADOResult', ctypes.c_ulong),
+ ]
+
+ def __init__(self):
+ Structure.__init__(self)
+ self.clear()
+
+
+ def clear(self):
+ memset(addressof(self), 0, self.getLength())
+
+ def readData(self, buf, pos = 0, length = 0):
+ if not pos <= length:
+ return -1
+ if len(buf) < pos + self.getLength():
+ return -1
+ self.clear()
+ self.PlayerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.AccID, pos = CommFunc.ReadString(buf, pos, 65)
+ self.PlayerName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.AccState, pos = CommFunc.ReadBYTE(buf, pos)
+ self.IsDeleted, pos = CommFunc.ReadBYTE(buf, pos)
+ self.GMLevel, pos = CommFunc.ReadBYTE(buf, pos)
+ self.Sex, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Hair, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HairColor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Face, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FacePic, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Job, pos = CommFunc.ReadDWORD(buf, pos)
+ self.RoleType, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ReincarnationLv, pos = CommFunc.ReadWORD(buf, pos)
+ self.LV, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalExp, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyName, pos = CommFunc.ReadString(buf, pos, 33)
+ self.Country, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FamilyActiveValue, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LastWeekFamilyActiveValue, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CountryHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CountryLastWeekHornor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Mate, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Gold, pos = CommFunc.ReadDWORD(buf, pos)
+ self.GoldPaper, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Silver, pos = CommFunc.ReadDWORD(buf, pos)
+ self.SilverPaper, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HappyPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.MapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.DataMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CopyMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PosX, pos = CommFunc.ReadWORD(buf, pos)
+ self.PosY, pos = CommFunc.ReadWORD(buf, pos)
+ self.FromMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FromCopyMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FromPosX, pos = CommFunc.ReadWORD(buf, pos)
+ self.FromPosY, pos = CommFunc.ReadWORD(buf, pos)
+ self.State, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HP, pos = CommFunc.ReadDWORD(buf, pos)
+ self.MP, pos = CommFunc.ReadDWORD(buf, pos)
+ self.XP, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HPRestoreSetting, pos = CommFunc.ReadWORD(buf, pos)
+ self.MPRestoreSetting, pos = CommFunc.ReadWORD(buf, pos)
+ self.FreePoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FreeSkillPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.STR, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PNE, pos = CommFunc.ReadDWORD(buf, pos)
+ self.PHY, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CON, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalSTR, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalPNE, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalPHY, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TotalCON, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Setting, pos = CommFunc.ReadString(buf, pos, 100)
+ self.PKValue, pos = CommFunc.ReadWORD(buf, pos)
+ self.FightPower, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ActiveValue, pos = CommFunc.ReadWORD(buf, pos)
+ self.PlayerType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.BackpackLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.WarehouseLV, pos = CommFunc.ReadBYTE(buf, pos)
+ self.HaveWarehousePsw, pos = CommFunc.ReadBYTE(buf, pos)
+ self.WarehousePsw, pos = CommFunc.ReadString(buf, pos, 15)
+ self.WarehouseLocked, pos = CommFunc.ReadBYTE(buf, pos)
+ self.WarehouseGold, pos = CommFunc.ReadDWORD(buf, pos)
+ self.WarehouseSilver, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.UseGoldType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.UseSilverType, pos = CommFunc.ReadBYTE(buf, pos)
+ self.AttackMode, pos = CommFunc.ReadBYTE(buf, pos)
+ self.RebornMapID, pos = CommFunc.ReadWORD(buf, pos)
+ self.RebornPosX, pos = CommFunc.ReadWORD(buf, pos)
+ self.RebornPosY, pos = CommFunc.ReadWORD(buf, pos)
+ self.WeekOnlineTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LastWeekOnlineTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LogoffTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.IsHideMask, pos = CommFunc.ReadBYTE(buf, pos)
+ self.DayProcessGameEventCount, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LoginIP, pos = CommFunc.ReadString(buf, pos, 20)
+ self.LoginTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.OnlineTime, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FriendFavor, pos = CommFunc.ReadDWORD(buf, pos)
+ self.TeamPrivity, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OfflineMinutes, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Energy, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ReceivedSalary, pos = CommFunc.ReadDWORD(buf, pos)
+ self.EquipShowSwitch, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LuckValue, pos = CommFunc.ReadWORD(buf, pos)
+ self.ExAttr1, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr2, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr3, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr4, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr5, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Faction, pos = CommFunc.ReadDWORD(buf, pos)
+ self.InfamyValue, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OfficialRank, pos = CommFunc.ReadBYTE(buf, pos)
+ self.IsFindByLabel, pos = CommFunc.ReadBYTE(buf, pos)
+ self.IsCloseFriendLabel, pos = CommFunc.ReadBYTE(buf, pos)
+ self.ChangeCoinPointTotal, pos = CommFunc.ReadDWORD(buf, pos)
+ self.VIPLv, pos = CommFunc.ReadBYTE(buf, pos)
+ self.VIPLvForPhone, pos = CommFunc.ReadBYTE(buf, pos)
+ self.PhoneVIPStartTime, pos = CommFunc.ReadDouble(buf, pos)
+ self.PhoneVIPEndTime, pos = CommFunc.ReadDouble(buf, pos)
+ self.VsRoomId, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr6, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr7, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr8, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr9, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr10, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ModelMark, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FromDataMapID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.LastOrderId, pos = CommFunc.ReadString(buf, pos, 40)
+ self.PrizeCoin, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr11, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr12, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr13, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr14, pos = CommFunc.ReadDWORD(buf, pos)
+ self.CreateRoleTime, pos = CommFunc.ReadString(buf, pos, 30)
+ self.LVEx, pos = CommFunc.ReadWORD(buf, pos)
+ self.LV2, pos = CommFunc.ReadWORD(buf, pos)
+ self.ExpPoint, pos = CommFunc.ReadDWORD(buf, pos)
+ self.OperateInfo, pos = CommFunc.ReadDWORD(buf, pos)
+ self.Operate, pos = CommFunc.ReadString(buf, pos, 15)
+ self.ServerID, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr15, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr16, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr17, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr18, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr19, pos = CommFunc.ReadDWORD(buf, pos)
+ self.ExAttr20, pos = CommFunc.ReadDWORD(buf, pos)
+ self.HPEx, pos = CommFunc.ReadDWORD(buf, pos)
+ self.FightPowerEx, pos = CommFunc.ReadDWORD(buf, pos)
+ return self.getLength()
+
+
+ def getBuffer(self):
+ buf = create_string_buffer(self.getLength())
+ memmove(addressof(buf), addressof(self), self.getLength())
+ return string_at(addressof(buf), self.getLength())
+
+ def getLength(self):
+ return sizeof(tagDBPlayer)
+
+ def outputString(self):
+ output = '''//玩家详细信息#tagDBPlayer:
+ PlayerID = %s,
+ AccID = %s,
+ PlayerName = %s,
+ AccState = %s,
+ IsDeleted = %s,
+ GMLevel = %s,
+ Sex = %s,
+ Hair = %s,
+ HairColor = %s,
+ Face = %s,
+ FacePic = %s,
+ Job = %s,
+ RoleType = %s,
+ ReincarnationLv = %s,
+ LV = %s,
+ TotalExp = %s,
+ FamilyID = %s,
+ FamilyName = %s,
+ Country = %s,
+ TeamHornor = %s,
+ FamilyHornor = %s,
+ FamilyActiveValue = %s,
+ LastWeekFamilyActiveValue = %s,
+ CountryHornor = %s,
+ CountryLastWeekHornor = %s,
+ Mate = %s,
+ Gold = %s,
+ GoldPaper = %s,
+ Silver = %s,
+ SilverPaper = %s,
+ FightPoint = %s,
+ HappyPoint = %s,
+ MapID = %s,
+ DataMapID = %s,
+ CopyMapID = %s,
+ PosX = %s,
+ PosY = %s,
+ FromMapID = %s,
+ FromCopyMapID = %s,
+ FromPosX = %s,
+ FromPosY = %s,
+ State = %s,
+ HP = %s,
+ MP = %s,
+ XP = %s,
+ HPRestoreSetting = %s,
+ MPRestoreSetting = %s,
+ FreePoint = %s,
+ FreeSkillPoint = %s,
+ STR = %s,
+ PNE = %s,
+ PHY = %s,
+ CON = %s,
+ TotalSTR = %s,
+ TotalPNE = %s,
+ TotalPHY = %s,
+ TotalCON = %s,
+ Setting = %s,
+ PKValue = %s,
+ FightPower = %s,
+ ActiveValue = %s,
+ PlayerType = %s,
+ BackpackLV = %s,
+ WarehouseLV = %s,
+ HaveWarehousePsw = %s,
+ WarehousePsw = %s,
+ WarehouseLocked = %s,
+ WarehouseGold = %s,
+ WarehouseSilver = %s,
+ TeamID = %s,
+ UseGoldType = %s,
+ UseSilverType = %s,
+ AttackMode = %s,
+ RebornMapID = %s,
+ RebornPosX = %s,
+ RebornPosY = %s,
+ WeekOnlineTime = %s,
+ LastWeekOnlineTime = %s,
+ LogoffTime = %s,
+ IsHideMask = %s,
+ DayProcessGameEventCount = %s,
+ LoginIP = %s,
+ LoginTime = %s,
+ OnlineTime = %s,
+ FriendFavor = %s,
+ TeamPrivity = %s,
+ OfflineMinutes = %s,
+ Energy = %s,
+ ReceivedSalary = %s,
+ EquipShowSwitch = %s,
+ LuckValue = %s,
+ ExAttr1 = %s,
+ ExAttr2 = %s,
+ ExAttr3 = %s,
+ ExAttr4 = %s,
+ ExAttr5 = %s,
+ Faction = %s,
+ InfamyValue = %s,
+ OfficialRank = %s,
+ IsFindByLabel = %s,
+ IsCloseFriendLabel = %s,
+ ChangeCoinPointTotal = %s,
+ VIPLv = %s,
+ VIPLvForPhone = %s,
+ PhoneVIPStartTime = %s,
+ PhoneVIPEndTime = %s,
+ VsRoomId = %s,
+ ExAttr6 = %s,
+ ExAttr7 = %s,
+ ExAttr8 = %s,
+ ExAttr9 = %s,
+ ExAttr10 = %s,
+ ModelMark = %s,
+ FromDataMapID = %s,
+ LastOrderId = %s,
+ PrizeCoin = %s,
+ ExAttr11 = %s,
+ ExAttr12 = %s,
+ ExAttr13 = %s,
+ ExAttr14 = %s,
+ CreateRoleTime = %s,
+ LVEx = %s,
+ LV2 = %s,
+ ExpPoint = %s,
+ OperateInfo = %s,
+ Operate = %s,
+ ServerID = %s,
+ ExAttr15 = %s,
+ ExAttr16 = %s,
+ ExAttr17 = %s,
+ ExAttr18 = %s,
+ ExAttr19 = %s,
+ ExAttr20 = %s,
+ HPEx = %s,
+ FightPowerEx = %s,
+ ADOResult = %s,
+ '''%(
+ self.PlayerID,
+ self.AccID,
+ self.PlayerName,
+ self.AccState,
+ self.IsDeleted,
+ self.GMLevel,
+ self.Sex,
+ self.Hair,
+ self.HairColor,
+ self.Face,
+ self.FacePic,
+ self.Job,
+ self.RoleType,
+ self.ReincarnationLv,
+ self.LV,
+ self.TotalExp,
+ self.FamilyID,
+ self.FamilyName,
+ self.Country,
+ self.TeamHornor,
+ self.FamilyHornor,
+ self.FamilyActiveValue,
+ self.LastWeekFamilyActiveValue,
+ self.CountryHornor,
+ self.CountryLastWeekHornor,
+ self.Mate,
+ self.Gold,
+ self.GoldPaper,
+ self.Silver,
+ self.SilverPaper,
+ self.FightPoint,
+ self.HappyPoint,
+ self.MapID,
+ self.DataMapID,
+ self.CopyMapID,
+ self.PosX,
+ self.PosY,
+ self.FromMapID,
+ self.FromCopyMapID,
+ self.FromPosX,
+ self.FromPosY,
+ self.State,
+ self.HP,
+ self.MP,
+ self.XP,
+ self.HPRestoreSetting,
+ self.MPRestoreSetting,
+ self.FreePoint,
+ self.FreeSkillPoint,
+ self.STR,
+ self.PNE,
+ self.PHY,
+ self.CON,
+ self.TotalSTR,
+ self.TotalPNE,
+ self.TotalPHY,
+ self.TotalCON,
+ self.Setting,
+ self.PKValue,
+ self.FightPower,
+ self.ActiveValue,
+ self.PlayerType,
+ self.BackpackLV,
+ self.WarehouseLV,
+ self.HaveWarehousePsw,
+ self.WarehousePsw,
+ self.WarehouseLocked,
+ self.WarehouseGold,
+ self.WarehouseSilver,
+ self.TeamID,
+ self.UseGoldType,
+ self.UseSilverType,
+ self.AttackMode,
+ self.RebornMapID,
+ self.RebornPosX,
+ self.RebornPosY,
+ self.WeekOnlineTime,
+ self.LastWeekOnlineTime,
+ self.LogoffTime,
+ self.IsHideMask,
+ self.DayProcessGameEventCount,
+ self.LoginIP,
+ self.LoginTime,
+ self.OnlineTime,
+ self.FriendFavor,
+ self.TeamPrivity,
+ self.OfflineMinutes,
+ self.Energy,
+ self.ReceivedSalary,
+ self.EquipShowSwitch,
+ self.LuckValue,
+ self.ExAttr1,
+ self.ExAttr2,
+ self.ExAttr3,
+ self.ExAttr4,
+ self.ExAttr5,
+ self.Faction,
+ self.InfamyValue,
+ self.OfficialRank,
+ self.IsFindByLabel,
+ self.IsCloseFriendLabel,
+ self.ChangeCoinPointTotal,
+ self.VIPLv,
+ self.VIPLvForPhone,
+ self.PhoneVIPStartTime,
+ self.PhoneVIPEndTime,
+ self.VsRoomId,
+ self.ExAttr6,
+ self.ExAttr7,
+ self.ExAttr8,
+ self.ExAttr9,
+ self.ExAttr10,
+ self.ModelMark,
+ self.FromDataMapID,
+ self.LastOrderId,
+ self.PrizeCoin,
+ self.ExAttr11,
+ self.ExAttr12,
+ self.ExAttr13,
+ self.ExAttr14,
+ self.CreateRoleTime,
+ self.LVEx,
+ self.LV2,
+ self.ExpPoint,
+ self.OperateInfo,
+ self.Operate,
+ self.ServerID,
+ self.ExAttr15,
+ self.ExAttr16,
+ self.ExAttr17,
+ self.ExAttr18,
+ self.ExAttr19,
+ self.ExAttr20,
+ self.HPEx,
+ self.FightPowerEx,
+ self.ADOResult,
+ )
+ return output
+
+ #Char数组类型Set接口,使用该接口对此类型数据赋值,防止赋值的数据过长报错
+ def SetAccID(self,Str):
+ if len(Str)<=65:
+ self.AccID = Str
+ else:
+ self.AccID = Str[:65]
+
+ def SetPlayerName(self,Str):
+ if len(Str)<=33:
+ self.PlayerName = Str
+ else:
+ self.PlayerName = Str[:33]
+
+ def SetFamilyName(self,Str):
+ if len(Str)<=33:
+ self.FamilyName = Str
+ else:
+ self.FamilyName = Str[:33]
+
+ def SetSetting(self,Str):
+ if len(Str)<=100:
+ self.Setting = Str
+ else:
+ self.Setting = Str[:100]
+
+ def SetWarehousePsw(self,Str):
+ if len(Str)<=15:
+ self.WarehousePsw = Str
+ else:
+ self.WarehousePsw = Str[:15]
+
+ def SetLogoffTime(self,Str):
+ if len(Str)<=30:
+ self.LogoffTime = Str
+ else:
+ self.LogoffTime = Str[:30]
+
+ def SetLoginIP(self,Str):
+ if len(Str)<=20:
+ self.LoginIP = Str
+ else:
+ self.LoginIP = Str[:20]
+
+ def SetLoginTime(self,Str):
+ if len(Str)<=30:
+ self.LoginTime = Str
+ else:
+ self.LoginTime = Str[:30]
+
+ def SetLastOrderId(self,Str):
+ if len(Str)<=40:
+ self.LastOrderId = Str
+ else:
+ self.LastOrderId = Str[:40]
+
+ def SetCreateRoleTime(self,Str):
+ if len(Str)<=30:
+ self.CreateRoleTime = Str
+ else:
+ self.CreateRoleTime = Str[:30]
+
+ def SetOperate(self,Str):
+ if len(Str)<=15:
+ self.Operate = Str
+ else:
+ self.Operate = Str[:15]
+
+
\ No newline at end of file
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
index 1328c7c..c3f1e64 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ShareDefine.py
@@ -890,7 +890,7 @@
Def_BT_Max, #排行榜最大类型
) = range(0, 40 + 2)
-''' 跨服排行榜类型, 从 150 开始
+''' 跨服排行榜类型, 从 150 开始,最大条数在功能配置表 CrossBillboardSet 配置,没配默认100
与本服榜单存储的是不一样的数据库表格,理论上类型可以和本服榜单类型重复,为了做下区分防误导,跨服榜单从 150 开始
跨服榜单表(tagDBCrossBillboard)
本服榜单表(tagDBBillboard)
@@ -911,20 +911,8 @@
Def_CBT_XianXiaMJScore, # 仙匣秘境积分 - 个人榜 162
Def_CBT_GubaoScore, # 古宝养成积分 - 个人榜 163
Def_CBT_HorsePetTrainScore, # 骑宠养成积分 - 个人榜 164
-) = range(150, 164 + 1)
-
-# 跨服榜单最大数据名次,没有设置的默认100
-CrossBillboard_MaxDataCount = {
- Def_CBT_BattlefieldWJoin:1000,
- Def_CBT_BattlefieldWCall:1000,
- Def_CBT_BattlefieldWScore:1000,
- Def_CBT_BattlefieldWScoreLastWeek:1000,
- Def_CBT_BossTrialSubmit:1000,
- Def_CBT_BossTrialSubmitBak:1000,
- Def_CBT_XianXiaMJScore:1000,
- Def_CBT_GubaoScore:1000,
- Def_CBT_HorsePetTrainScore:1000,
- }
+Def_CBT_CrossRealmPK, # 跨服PK竞技场 165
+) = range(150, 165 + 1)
#职业对应战力排行榜类型
JobFightPowerBillboardDict = {
@@ -1653,12 +1641,8 @@
CrossServerMsg_PullPlayerPackData = "PullPlayerPackData"# 拉取玩家打包数据
CrossServerMsg_PushPlayerPackData = "PushPlayerPackData"# 推送玩家打包数据
CrossServerMsg_PKMatchReqRet = "PKMatchReqRet" # 跨服PK匹配请求结果
-CrossServerMsg_PKMatchResult = "PKMatchResult" # 跨服PK匹配结果
-CrossServerMsg_PKReadyOKRoomList = "PKReadyOKRoomList" # 跨服PK已准备好的房间列表
-CrossServerMsg_PKTimeoutRoomList = "PKTimeoutRoomList" # 跨服PK已超时的房间列表
CrossServerMsg_PKOverInfo = "PKOverInfo" # 跨服PK结果
CrossServerMsg_PKSeasonInfo = "PKSeasonInfo" # 跨服PK赛季信息
-CrossServerMsg_PKSyncBillboard = "PKSyncBillboard" # 跨服PK同步排行榜
CrossServerMsg_SyncBillboard = "SyncBillboard" # 跨服同步排行榜
CrossServerMsg_CrossBossInfo = "CrossBossInfo" # 跨服Boss信息
CrossServerMsg_CrossBossState = "CrossBossState" # 跨服Boss状态
@@ -1713,9 +1697,7 @@
ClientServerMsg_PullOtherPlayerPackData = "PullOtherPlayerPackData" # 拉其他服玩家打包数据
ClientServerMsg_PlayerPackData = "PlayerPackData" # 玩家打包数据同步
ClientServerMsg_PKMatch = "PKMatch" # 跨服PK匹配
-ClientServerMsg_PKRobotOver = "PKRobotOver" # 跨服PK机器人结算
-ClientServerMsg_PKCancel = "PKCancel" # 跨服PK取消匹配
-ClientServerMsg_PKPrepareOK = "PKPrepareOK" # 跨服PK准备完毕
+ClientServerMsg_PKOver = "PKOver" # 跨服PK结算
ClientServerMsg_PKBillboard = "PKBillboard" # 跨服PK排行榜
ClientServerMsg_QueryBillboard = "QueryBillboard" # 跨服排行榜 - 查询、同步等
ClientServerMsg_UpdateBillboard = "UpdateBillboard" # 跨服排行榜 - 更新
--
Gitblit v1.8.0