|  |  |  | 
|---|
|  |  |  | import PlayerUniversalGameRec | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import random | 
|---|
|  |  |  | import json | 
|---|
|  |  |  | import math | 
|---|
|  |  |  | import cPickle | 
|---|
|  |  |  | import json | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 = json.dumps(cPickle.loads(curCache.GetPropData()), ensure_ascii=False) | 
|---|
|  |  |  | packData.PropData = curCache.PropData | 
|---|
|  |  |  | packData.PropDataSize = len(packData.PropData) | 
|---|
|  |  |  | packData.ItemData = json.dumps(cPickle.loads(PlayerViewCache.GetItemData(curCache)), ensure_ascii=False) | 
|---|
|  |  |  | packData.ItemDataSize = len(packData.ItemData) | 
|---|
|  |  |  | NetPackCommon.SendFakePack(curPlayer, packData) | 
|---|
|  |  |  | return | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | faction_2_Score = self.XMZZFactionDict.get(Faction_2, [0, 0])[0] | 
|---|
|  |  |  | if faction_1_Score + faction_2_Score >= XMZZDogFallLimit: | 
|---|
|  |  |  | SavePKRecord('XMZZ_Draw', [], True) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey('XMZZDogfall', Faction_2_IDList + Faction_1_IDList, [], goldPaper=dogfallAward) | 
|---|
|  |  |  | if dogfallAward: | 
|---|
|  |  |  | PlayerCompensation.SendMailByKey('XMZZDogfall', Faction_2_IDList + Faction_1_IDList, [], goldPaper=dogfallAward) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_XMZZIsOver, 1) | 
|---|
|  |  |  | self.NotifyXMZZInfo() | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | propDataDict = cPickle.loads(curCache.GetPropData()) | 
|---|
|  |  |  | itemDataDict = cPickle.loads(itemData) | 
|---|
|  |  |  | if playerID in g_playerPowerDict: | 
|---|
|  |  |  | power = g_playerPowerDict[playerID] | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | power = propDataDict.get('FightPower', 0) | 
|---|
|  |  |  | g_playerPowerDict[playerID] = power | 
|---|
|  |  |  | propDataDict = PlayerViewCache.GetCachePropDataDict(curCache) | 
|---|
|  |  |  | power = propDataDict.get('FightPower', 0) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | pkDataDict[playerID] = [propDataDict, itemDataDict] | 
|---|
|  |  |  | #GameWorld.DebugLog('    筛选对手 playerID=%s,power=%s' % (playerID, power)) | 
|---|
|  |  |  | if minPower1 < power < myPower: | 
|---|
|  |  |  | underList1.append(playerID) | 
|---|
|  |  |  | 
|---|
|  |  |  | if isRobotNPC: | 
|---|
|  |  |  | #机器人, 职业随机 | 
|---|
|  |  |  | openJob = IpyGameDataPY.GetFuncEvalCfg("OpenJob") | 
|---|
|  |  |  | PropData = {"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 = json.dumps(PropData, ensure_ascii=False) | 
|---|
|  |  |  | packData.PropData = json.dumps(pkPlayerPropData, ensure_ascii=False) | 
|---|
|  |  |  | packData.PropDataSize = len(packData.PropData) | 
|---|
|  |  |  | packData.ItemData = json.dumps(ItemData, ensure_ascii=False) | 
|---|
|  |  |  | packData.ItemDataSize = len(packData.ItemData) | 
|---|
|  |  |  | NetPackCommon.SendFakePack(curPlayer, packData) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #通知地图 | 
|---|
|  |  |  | pkPlayerPropData = {} | 
|---|
|  |  |  | if PropData: | 
|---|
|  |  |  | pkPlayerPropData = PropData | 
|---|
|  |  |  | else: | 
|---|
|  |  |  | if not pkPlayerPropData: | 
|---|
|  |  |  | GameWorld.ErrLog("仙魔之争没有匹配到对手信息!fightPower=%s" % curPlayer.GetFightPower(), myPlayerID) | 
|---|
|  |  |  | vsPlayerInfo = [pkPlayerID, pkPlayerPropData] | 
|---|
|  |  |  | XMZZManager.MapServer_XMZZPKInfo(curPlayer, overInfo, vsPlayerInfo) | 
|---|