Merge branch 'master' of http://192.168.0.87:10010/r/SnxxServerCode
| | |
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("PlayerID", c_int), # 跨服玩家ID
|
| | | ("EquipClassLV", c_ubyte), #大于0为查看指定境界阶装备信息, 0为查看默认信息
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | |
| | | self.Cmd = 0xC0
|
| | | self.SubCmd = 0x02
|
| | | self.PlayerID = 0
|
| | | self.EquipClassLV = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | DumpString = '''// C0 02 查看跨服玩家信息 //tagCGViewCrossPlayerInfo:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | PlayerID:%d
|
| | | PlayerID:%d,
|
| | | EquipClassLV:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.PlayerID
|
| | | self.PlayerID,
|
| | | self.EquipClassLV
|
| | | )
|
| | | return DumpString
|
| | |
|
| | |
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD PlayerID; // 跨服玩家ID
|
| | | # BYTE EquipClassLV; //大于0为查看指定境界阶装备信息, 0为查看默认信息
|
| | | #};
|
| | | def OnViewCrossPlayerInfo(index, clientData, tick):
|
| | | if GameWorld.IsCrossServer():
|
| | |
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | tagPlayerID = clientData.PlayerID
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagPlayerID)
|
| | | equipClassLV = clientData.EquipClassLV
|
| | | curCache = PlayerViewCache.FindViewCache(tagPlayerID)
|
| | | ## 本服有,直接回客户端
|
| | | if curCache:
|
| | | GameWorld.DebugLog("查看跨服玩家,是本服玩家,直接回复!tagPlayerID=%s" % (tagPlayerID), playerID)
|
| | | sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
|
| | | sendPack.PlayerID = tagPlayerID
|
| | | sendPack.PropData = curCache.GetPropData()
|
| | | sendPack.PropDataSize = len(sendPack.PropData)
|
| | | sendPack.ItemData = PlayerViewCache.GetItemData(curCache)
|
| | | sendPack.ItemDataSize = len(sendPack.ItemData)
|
| | | sendPack.PlusData = PlayerViewCache.GetPlusData(curCache)
|
| | | sendPack.PlusDataSize = len(sendPack.PlusData)
|
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | PlayerViewCache.Sync_PlayerCache(curPlayer, curCache, equipClassLV)
|
| | | return
|
| | |
|
| | | if tagPlayerID in PyGameData.g_crossPlayerViewCache:
|
| | | validChaheTime = 5 * 60 * 1000
|
| | | validChaheTime = 10 * 60 * 1000
|
| | | cacheInfo, updTick = PyGameData.g_crossPlayerViewCache[tagPlayerID]
|
| | | if tick - updTick <= validChaheTime:
|
| | | GameWorld.DebugLog("查看跨服玩家数据同步CD中,直接用缓存数据回复!tagPlayerID=%s" % (tagPlayerID), playerID)
|
| | | SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, cacheInfo)
|
| | | SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo)
|
| | | return
|
| | |
|
| | | for crossPlayerID, cacheInfoList in PyGameData.g_crossPlayerViewCache.items():
|
| | |
| | | PyGameData.g_crossPlayerViewCache.pop(crossPlayerID)
|
| | |
|
| | | # 发送跨服服务器查询
|
| | | dataMsg = {"tagPlayerID":tagPlayerID, "playerID":playerID}
|
| | | dataMsg = {"tagPlayerID":tagPlayerID, "playerID":playerID, "equipClassLV":equipClassLV}
|
| | | CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ViewPlayerCache, dataMsg)
|
| | | return
|
| | |
|
| | | def ClientServerMsg_ViewPlayerCache(serverGroupID, msgData):
|
| | | tagPlayerID = msgData["tagPlayerID"]
|
| | | playerID = msgData["playerID"]
|
| | | equipClassLV = msgData["equipClassLV"]
|
| | |
|
| | | GameWorld.Log("收到子服查看跨服玩家信息: serverGroupID=%s,playerID=%s,tagPlayerID=%s" % (serverGroupID, playerID, tagPlayerID))
|
| | |
|
| | | cacheInfo = []
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagPlayerID)
|
| | | cacheInfo = {}
|
| | | curCache = PlayerViewCache.FindViewCache(tagPlayerID)
|
| | | if curCache:
|
| | | cacheInfo = [curCache.GetPropData(), PlayerViewCache.GetItemData(curCache), PlayerViewCache.GetPlusData(curCache)]
|
| | | |
| | | viewPlayerCacheRet = [playerID, tagPlayerID, cacheInfo]
|
| | | cacheInfo = {"PropData":curCache.PropData, "PlusData":curCache.PlusData}
|
| | | for classLV in xrange(1, 15 + 1):
|
| | | attrName = "ItemData%s" % classLV
|
| | | if hasattr(curCache, attrName):
|
| | | cacheInfo[attrName] = getattr(curCache, attrName)
|
| | | |
| | | viewPlayerCacheRet = [playerID, tagPlayerID, equipClassLV, cacheInfo]
|
| | | CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ViewPlayerCacheRet, viewPlayerCacheRet, [serverGroupID])
|
| | | return
|
| | |
|
| | | def CrossServerMsg_ViewPlayerCacheRet(msgData, tick):
|
| | |
|
| | | playerID, tagPlayerID, cacheInfo = msgData
|
| | | playerID, tagPlayerID, equipClassLV, cacheInfo = msgData
|
| | | GameWorld.Log("收到跨服服务器回复的查看玩家信息: playerID=%s,tagPlayerID=%s" % (playerID, tagPlayerID))
|
| | |
|
| | | PyGameData.g_crossPlayerViewCache[tagPlayerID] = [cacheInfo, tick] # 更新信息
|
| | |
|
| | | curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
|
| | | if curPlayer:
|
| | | SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, cacheInfo)
|
| | | SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo)
|
| | |
|
| | | return
|
| | |
|
| | | def SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, cacheInfo):
|
| | | def SyncPlayerViewCrossPlayerInfo(curPlayer, tagPlayerID, equipClassLV, cacheInfo):
|
| | | if not cacheInfo:
|
| | | PlayerControl.NotifyCode(curPlayer, "ViewPlayer_OffLine")
|
| | | return
|
| | | PropData, ItemData, PlusData = cacheInfo
|
| | | |
| | | if equipClassLV:
|
| | | itemData = cacheInfo.get("ItemData%s" % equipClassLV, "")
|
| | | sendPack = ChPyNetSendPack.tagSCPlayerEquipCacheResult()
|
| | | sendPack.PlayerID = tagPlayerID
|
| | | sendPack.EquipClassLV = equipClassLV
|
| | | sendPack.ItemData = itemData
|
| | | sendPack.ItemDataSize = len(sendPack.ItemData)
|
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | return
|
| | | |
| | | #回包客户端
|
| | | sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
|
| | | sendPack.PlayerID = tagPlayerID
|
| | | sendPack.PropData = PropData
|
| | | sendPack.PropData = cacheInfo.get("PropData", "")
|
| | | sendPack.PropDataSize = len(sendPack.PropData)
|
| | | sendPack.ItemData = ItemData
|
| | | sendPack.ItemDataSize = len(sendPack.ItemData)
|
| | | sendPack.PlusData = PlusData
|
| | | sendPack.PlusData = cacheInfo.get("PlusData", "")
|
| | | sendPack.PlusDataSize = len(sendPack.PlusData)
|
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | return
|
| | |
| | | import datetime
|
| | | import PlayerFamily
|
| | | import PlayerDBGSEvent
|
| | | import GameWorldActionControl
|
| | | import PlayerViewCache
|
| | | import PlayerFBHelpBattle
|
| | | import PlayerFairyDomain
|
| | | import ChPyNetSendPack
|
| | |
| | | PlayerDuJie.OnDayEx()
|
| | | #副本助战
|
| | | PlayerFBHelpBattle.HelpBattleOnDay()
|
| | | #玩家缓存
|
| | | PlayerViewCache.DelOutofTimeViewCacheData()
|
| | | #缥缈OnDay
|
| | | PlayerFairyDomain.OnDayEx()
|
| | | playerManager = GameWorld.GetPlayerManager()
|
| | |
| | | checkInCount, fightPower = msgList[1:]
|
| | | curTime = int(time.time())
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID)
|
| | | curCache = PlayerViewCache.FindViewCache(playerID)
|
| | | haveViewCache = 1 if curCache else 0
|
| | | todayXianyuanCoin = PlayerControl.GetTodayXianyuanCoin(curPlayer)
|
| | |
|
| | |
| | | return
|
| | |
|
| | | if not tagPlayer:
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(curTagPlayerID)
|
| | | curCache = PlayerViewCache.FindViewCache(curTagPlayerID)
|
| | | if not curCache:
|
| | | #玩家的数据没有缓存过
|
| | | PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
|
| | | return
|
| | | tagLV = curCache.GetPlayerLV()
|
| | | tagLV = curCache.LV
|
| | | else:
|
| | | tagLV = tagPlayer.GetLV()
|
| | |
|
| | |
| | | srcPlayer = playerManager.FindPlayerByID(srcPlayerID)
|
| | | if srcPlayer == None:
|
| | | # 玩家已下线
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(srcPlayerID)
|
| | | curCache = PlayerViewCache.FindViewCache(srcPlayerID)
|
| | | if not curCache:
|
| | | #玩家的数据没有缓存过
|
| | | #PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
|
| | |
| | | PlayerControl.NotifyCode(srcPlayer, 'Friend_MakeFriend', [curPlayer.GetName()])
|
| | | #srcPlayer.MapServer_QueryPlayerResult(0, 0, 'AddFriendSucceed', "", 0)
|
| | | else:
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | PlayerControl.NotifyCode(curPlayer, 'Friend_MakeFriend', [cacheDict['Name']])
|
| | | # 记录等对方上线通知地图,任务等会用到触发逻辑,通用记录次数即可, MapServer_SyncFriendInfo为具体的好友数量,根据策划需求制作
|
| | | pass
|
| | |
| | |
|
| | | tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagID)
|
| | | if not tagPlayer:
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagID)
|
| | | curCache = PlayerViewCache.FindViewCache(tagID)
|
| | | if not curCache:
|
| | | return
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | playerName = cacheDict['Name']
|
| | | else:
|
| | | playerName = tagPlayer.GetName()
|
| | |
| | |
|
| | | # 个推基础判定
|
| | | def CanGeTuiByCache(curCache):
|
| | | if not curCache.GetGeTuiID():
|
| | | if not curCache.GeTuiID:
|
| | | return False
|
| | |
|
| | | # 离线超过24小时不再推送,目前极光推送的特点是推送ID同机器不同包都是同一个ID
|
| | | if time.time() - curCache.GetOffTime() > 24*60*60:
|
| | | if time.time() - curCache.OffTime > 24*60*60:
|
| | | return False
|
| | | return True
|
| | |
|
| | |
| | | continue
|
| | |
|
| | | # 离线玩家
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID)
|
| | | curCache = PlayerViewCache.FindViewCache(playerID)
|
| | | if not curCache:
|
| | | continue
|
| | |
|
| | |
| | | #0-默认未关注, 1-主动关注, 2-自动关注, 9-主动取消关注
|
| | | continue
|
| | |
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | if not CheckCanGeTui(cacheDict, geTuiType):
|
| | | # 个推逻辑检查
|
| | | continue
|
| | |
| | | if appID not in appIDDict:
|
| | | appIDDict[appID] = []
|
| | |
|
| | | appIDDict[appID].append([curCache.GetGeTuiID(), cacheDict.get("Name", "")])
|
| | | appIDDict[appID].append([curCache.GeTuiID, cacheDict.get("Name", "")])
|
| | |
|
| | |
|
| | | if not appIDDict:
|
| | |
| | |
|
| | | # 私聊
|
| | | def ChatMiGeTui(playerID, playerName, tagPlayerName):
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID)
|
| | | curCache = PlayerViewCache.FindViewCache(playerID)
|
| | | if not curCache:
|
| | | return
|
| | |
|
| | |
| | | #无推送资格,基础判定
|
| | | return
|
| | |
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | if not CheckCanGeTui(cacheDict, Def_Onoff_Chat):
|
| | | # 过滤个推
|
| | | return
|
| | |
|
| | | showStr = GameWorld.GbkToCode(IpyGameDataPY.GetFuncCfg("GeTuiOffLine", 3))%(tagPlayerName) # 文字信息
|
| | | GeTuiNotify({cacheDict.get("AppID", ""):[[curCache.GetGeTuiID(), playerName]]}, showStr)
|
| | | GeTuiNotify({cacheDict.get("AppID", ""):[[curCache.GeTuiID, playerName]]}, showStr)
|
| | | return
|
| | |
|
| | | # 下线时,低级玩家没有离线时间的玩家提示, 上线清空
|
| | |
| | |
|
| | | # 增加社交对象信息,针对不在社交圈记录并且不在线玩家的情况
|
| | | def AddPlayerInfoByViewCache(self, playerID):
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(playerID)
|
| | | curCache = PlayerViewCache.FindViewCache(playerID)
|
| | | playerSocial = PyGameDataStruct.tagPersonalSocial()
|
| | | if not curCache:
|
| | | # 实在找不到设置为初始化数据
|
| | |
| | | playerSocial.RealmLV = 1
|
| | | playerSocial.OnlineType = ChConfig.Def_Offline
|
| | | else:
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | |
|
| | | playerSocial.clear()
|
| | | playerSocial.PlayerID = playerID
|
| | |
| | | curCache = None
|
| | | tagPlayerName = ""
|
| | | if tagPlayer == None:
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(tagPlayerID)
|
| | | curCache = PlayerViewCache.FindViewCache(tagPlayerID)
|
| | | if not curCache:
|
| | | PlayerControl.NotifyCode(curPlayer, "CanootTalk10")
|
| | | return
|
| | |
| | | return
|
| | |
|
| | | if curCache:
|
| | | cacheDict = eval(curCache.GetPropData())
|
| | | cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | tagPlayerName = cacheDict["Name"]
|
| | |
|
| | | talkType = sendPack.GetTalkType()
|
| | |
| | | import ChConfig
|
| | |
|
| | | import json
|
| | | import time
|
| | |
|
| | | ViewCacheMgr = GameWorld.GameWorldData.GetPlayerViewCacheMgr()
|
| | |
|
| | |
|
| | | # 优先取缓存数据,后取可保存数据
|
| | | def GetItemData(curCache):
|
| | | result = curCache.GetItemDataNoSave()
|
| | | if not result:
|
| | | return curCache.GetItemData()
|
| | | |
| | | return result
|
| | |
|
| | | def GetPlusData(curCache):
|
| | | result = curCache.GetPlusDataNoSave()
|
| | | if not result:
|
| | | return curCache.GetPlusData()
|
| | | |
| | | return result
|
| | | def DoOnDay():
|
| | | DelOutofTimeViewCacheData()
|
| | | return
|
| | |
|
| | | def IsSaveDBViewCache(playerID, playerLV):
|
| | | ## 是否保存基本的缓存数据
|
| | |
| | |
|
| | | return False
|
| | |
|
| | | def DelOutofTimeViewCacheData():
|
| | | ## 删除过期的查看缓存数据
|
| | | |
| | | curTime = int(time.time())
|
| | | MaxTime = 30 * 3600 * 24 # 30天
|
| | | |
| | | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
|
| | | playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
|
| | | for playerID, viewCache in playerViewCachePyDict.items():
|
| | | |
| | | passTime = curTime - viewCache.OffTime
|
| | | if passTime < MaxTime:
|
| | | continue
|
| | | if IsSaveAllViewCache(playerID):
|
| | | continue
|
| | | playerViewCachePyDict.pop(playerID)
|
| | | |
| | | return
|
| | |
|
| | | def DeleteViewCache(playerID):
|
| | | ## 删除玩家缓存
|
| | | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
|
| | |
| | | curCache.PlayerID = playerID
|
| | | playerViewCachePyDict[playerID] = curCache
|
| | | return curCache
|
| | |
|
| | | def GetCachePropDataDict(curCache):
|
| | | ## 获取缓存基础属性字典信息
|
| | | if not hasattr(curCache, "PropDataDict"):
|
| | | curCache.PropDataDict = {}
|
| | | if not curCache.PropDataDict:
|
| | | curCache.PropDataDict = eval(curCache.PropData)
|
| | | return curCache.PropDataDict
|
| | |
|
| | | #//04 01 地图同步玩家缓存数据到GameServer#tagMGUpdatePlayerCache
|
| | | #
|
| | |
| | | curCache.GeTuiID = curPlayer.GetGeTuiClientID()
|
| | | curCache.GeTuiIDSize = len(curCache.GeTuiID)
|
| | |
|
| | | curCache.PropDataDict = {} # 每次更新数据时,重置字典缓存,下次获取时重新eval缓存
|
| | | curCache.PropData = curPackData.PropData
|
| | | curCache.PropDataSize = curPackData.PropDataSize
|
| | | curCache.PlusData = curPackData.PlusData
|
| | |
| | | #GameWorld.DebugLog(" %s" % curCache.outputString())
|
| | | # 同步更新助战信息
|
| | | if PlayerFBHelpBattle.IsInHelpBattleCheckInList(playerID):
|
| | | #PropDataDict = json.loads(curCache.PropData)
|
| | | PropDataDict = eval(curCache.PropData)
|
| | | PropDataDict = GetCachePropDataDict(curCache)
|
| | | fightPower = PropDataDict.get("FightPower", 0)
|
| | | familyID = PropDataDict.get("FamilyID", 0)
|
| | | playerName = PropDataDict.get("Name", "")
|
| | |
| | | if not curCache:
|
| | | PlayerControl.NotifyCode(curPlayer, "ViewPlayer_OffLine")
|
| | | return
|
| | | |
| | | Sync_PlayerCache(curPlayer, curCache, equipClassLV)
|
| | | return
|
| | |
|
| | | def Sync_PlayerCache(curPlayer, curCache, equipClassLV=0):
|
| | | ## 同步玩家缓存
|
| | | if equipClassLV:
|
| | | itemData = ""
|
| | | if hasattr(curCache, "ItemDataSize%s" % equipClassLV):
|
| | | itemData = getattr(curCache, "ItemData%s" % equipClassLV)
|
| | | sendPack = ChPyNetSendPack.tagSCPlayerEquipCacheResult()
|
| | | sendPack.PlayerID = findPlayerID
|
| | | sendPack.PlayerID = curCache.PlayerID
|
| | | sendPack.EquipClassLV = equipClassLV
|
| | | sendPack.ItemData = itemData
|
| | | sendPack.ItemDataSize = len(sendPack.ItemData)
|
| | |
| | |
|
| | | #回包客户端
|
| | | sendPack = ChPyNetSendPack.tagSCQueryPlayerCacheResult()
|
| | | sendPack.PlayerID = findPlayerID
|
| | | sendPack.PlayerID = curCache.PlayerID
|
| | | sendPack.PropData = curCache.PropData
|
| | | sendPack.PropDataSize = len(sendPack.PropData)
|
| | | sendPack.PlusData = curCache.PlusData
|
| | | sendPack.PlusDataSize = len(sendPack.PlusData)
|
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | #GameWorld.DebugLog('ViewCache### OnMGQueryPlayerCache out')
|
| | | return
|
| | |
|
| | | #===============================================================================
|
| | |
| | | answerPack.OnlineType = ChConfig.Def_Offline
|
| | | answerPack.ServerGroupID = 0
|
| | | else:
|
| | | cacheDict = eval(curCache.PropData)
|
| | | cacheDict = GetCachePropDataDict(curCache)
|
| | | answerPack.PlayerID = clientPack.PlayerID
|
| | | answerPack.PlayerName = cacheDict["Name"]
|
| | | answerPack.Job = cacheDict["Job"]
|
| | |
| | | curCache = FindViewCache(playerID)
|
| | | if not curCache:
|
| | | return
|
| | | PropData = eval(curCache.PropData)
|
| | | PropData = GetCachePropDataDict(curCache)
|
| | | PropData["FamilyID"] = familyID
|
| | | PropData["FamilyName"] = familyName
|
| | | PropData = json.dumps(PropData, ensure_ascii=False).replace(" ", "")
|
| | |
| | | RecType = ShareDefine.Def_UniversalGameRecType_XMZZStageRecord
|
| | | RecType1 = ShareDefine.Def_UniversalGameRecType_XMZZPKInfoRecord
|
| | | #strValue3 {投注索引:结果,..}
|
| | | g_playerPowerDict = {} #玩家战力缓存
|
| | | g_historyPKDict = {} #历史对手ID缓存
|
| | |
|
| | | (
|
| | |
| | |
|
| | | def XMZZOndayEx():
|
| | | #过天
|
| | | global g_playerPowerDict
|
| | | global g_historyPKDict
|
| | | PyDataManager.GetXMZZManager().ResetXMZZ()
|
| | | g_playerPowerDict = {} #玩家战力缓存
|
| | | g_historyPKDict = {} #历史对手ID缓存
|
| | | return
|
| | |
|
| | |
| | | if playerID not in self.vsPlayerIDDict:
|
| | | return
|
| | | pkPlayerID = self.vsPlayerIDDict[playerID]
|
| | | curCache = PlayerViewCache.ViewCacheMgr.FindCache(pkPlayerID)
|
| | | curCache = PlayerViewCache.FindViewCache(pkPlayerID)
|
| | | if not curCache:
|
| | | return
|
| | |
|
| | | packData = ChPyNetSendPack.tagGCXMZZFightInfo()
|
| | | packData.Clear()
|
| | | packData.PlayerID = pkPlayerID
|
| | | packData.PropData = curCache.GetPropData()
|
| | | packData.PropData = curCache.PropData
|
| | | packData.PropDataSize = len(packData.PropData)
|
| | | packData.ItemData = PlayerViewCache.GetItemData(curCache)
|
| | | packData.ItemDataSize = len(packData.ItemData)
|
| | | NetPackCommon.SendFakePack(curPlayer, packData)
|
| | | return
|
| | |
|
| | |
| | |
|
| | | def RandomBattler(curPlayer, overInfo=[]):
|
| | | #筛选对手 根据连胜次数一定几率随机到高级机器人,否则每5个的第1个低于自己战力 先从小范围随机,再大范围随机,没有则用NPC
|
| | | global g_playerPowerDict
|
| | | global g_historyPKDict
|
| | | myPlayerID = curPlayer.GetID()
|
| | | GameWorld.DebugLog(' 仙魔之争开始筛选对手', myPlayerID)
|
| | |
| | |
|
| | | pkPlayerID = 0 # 默认低级机器人
|
| | | isRobotNPC = True
|
| | | pkDataDict = {}
|
| | | conWinCnt = XMZZPlayerDict[myPlayerID].ConWinCnt #参数
|
| | | XMZZSpecialNPCRate = eval(IpyGameDataPY.GetFuncCompileCfg('XMZZSpecialNPCRate'))
|
| | | XMZZSuperNPCRate = eval(IpyGameDataPY.GetFuncCompileCfg('XMZZSpecialNPCRate', 2))
|
| | |
| | | underList1, aboveList1 = [], [] #小范围
|
| | | underList2, aboveList2 = [], [] #大范围
|
| | |
|
| | | ViewCacheMgr = GameWorld.GameWorldData.GetPlayerViewCacheMgr()
|
| | | for i in xrange(ViewCacheMgr.GetCount()):
|
| | | curCache = ViewCacheMgr.At(i)
|
| | | itemData = PlayerViewCache.GetItemData(curCache)
|
| | | if not itemData:
|
| | | #没有装备信息
|
| | | continue
|
| | | playerID = curCache.GetPlayerID()
|
| | | |
| | | pyViewCacheMgr = PyDataManager.GetPlayerViewCachePyManager()
|
| | | playerViewCachePyDict = pyViewCacheMgr.playerViewCachePyDict
|
| | | for playerID, curCache in playerViewCachePyDict.items():
|
| | | if myPlayerID == playerID:
|
| | | #不和自己pk
|
| | | continue
|
| | |
| | | #已匹配过的跳过
|
| | | continue
|
| | |
|
| | | if playerID in g_playerPowerDict:
|
| | | power = g_playerPowerDict[playerID]
|
| | | else:
|
| | | propDataDict = eval(curCache.GetPropData())
|
| | | power = propDataDict.get('FightPower', 0)
|
| | | g_playerPowerDict[playerID] = power
|
| | | propDataDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
| | | power = propDataDict.get('FightPower', 0)
|
| | |
|
| | | pkDataDict[playerID] = [curCache.GetPropData(), itemData]
|
| | | #GameWorld.DebugLog(' 筛选对手 playerID=%s,power=%s' % (playerID, power))
|
| | | if minPower1 < power < myPower:
|
| | | underList1.append(playerID)
|
| | |
| | | if isRobotNPC:
|
| | | #机器人, 职业随机
|
| | | openJob = IpyGameDataPY.GetFuncEvalCfg("OpenJob")
|
| | | PropData = str({"Job":random.choice(openJob), "LV":curPlayer.GetLV()})
|
| | | ItemData = "" # 前端自己根据职业及NPC等级处理
|
| | | pkPlayerPropData = {"Job":random.choice(openJob), "LV":curPlayer.GetLV()}
|
| | | else:
|
| | | if myPlayerID in g_historyPKDict:
|
| | | g_historyPKDict[myPlayerID].append(pkPlayerID)
|
| | | else:
|
| | | g_historyPKDict[myPlayerID] = [pkPlayerID]
|
| | |
|
| | | PropData, ItemData = pkDataDict.get(pkPlayerID, ["", ""])
|
| | | pkPlayerCache = PlayerViewCache.FindViewCache(pkPlayerID)
|
| | | pkPlayerPropData = {} if not pkPlayerCache else PlayerViewCache.GetCachePropDataDict(pkPlayerCache)
|
| | | XMZZManager.vsPlayerIDDict[myPlayerID] = pkPlayerID
|
| | |
|
| | | GameWorld.DebugLog(' 仙魔之争匹配对手信息 pkPlayerID=%s, PropData=%s, overInfo=%s' % (pkPlayerID, PropData, overInfo), myPlayerID)
|
| | | GameWorld.DebugLog(' 仙魔之争匹配对手信息 pkPlayerID=%s, pkPlayerPropData=%s, overInfo=%s' % (pkPlayerID, pkPlayerPropData, overInfo), myPlayerID)
|
| | |
|
| | | #通知前端
|
| | | packData = ChPyNetSendPack.tagGCXMZZFightInfo()
|
| | | packData.Clear()
|
| | | packData.PlayerID = pkPlayerID
|
| | | packData.PropData = PropData
|
| | | packData.PropData = str(pkPlayerPropData)
|
| | | packData.PropDataSize = len(packData.PropData)
|
| | | packData.ItemData = ItemData
|
| | | packData.ItemDataSize = len(packData.ItemData)
|
| | | NetPackCommon.SendFakePack(curPlayer, packData)
|
| | |
|
| | | #通知地图
|
| | | pkPlayerPropData = {}
|
| | | if PropData:
|
| | | pkPlayerPropData = eval(PropData)
|
| | | else:
|
| | | if not pkPlayerPropData:
|
| | | GameWorld.ErrLog("仙魔之争没有匹配到对手信息!fightPower=%s" % curPlayer.GetFightPower(), myPlayerID)
|
| | | vsPlayerInfo = [pkPlayerID, pkPlayerPropData]
|
| | | XMZZManager.MapServer_XMZZPKInfo(curPlayer, overInfo, vsPlayerInfo)
|
| | |
| | | ("Cmd", c_ubyte),
|
| | | ("SubCmd", c_ubyte),
|
| | | ("PlayerID", c_int), # 跨服玩家ID
|
| | | ("EquipClassLV", c_ubyte), #大于0为查看指定境界阶装备信息, 0为查看默认信息
|
| | | ]
|
| | |
|
| | | def __init__(self):
|
| | |
| | | self.Cmd = 0xC0
|
| | | self.SubCmd = 0x02
|
| | | self.PlayerID = 0
|
| | | self.EquipClassLV = 0
|
| | | return
|
| | |
|
| | | def GetLength(self):
|
| | |
| | | DumpString = '''// C0 02 查看跨服玩家信息 //tagCGViewCrossPlayerInfo:
|
| | | Cmd:%s,
|
| | | SubCmd:%s,
|
| | | PlayerID:%d
|
| | | PlayerID:%d,
|
| | | EquipClassLV:%d
|
| | | '''\
|
| | | %(
|
| | | self.Cmd,
|
| | | self.SubCmd,
|
| | | self.PlayerID
|
| | | self.PlayerID,
|
| | | self.EquipClassLV
|
| | | )
|
| | | return DumpString
|
| | |
|