| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package CrossChampionship  | 
| #  | 
| # @todo:¿ç·þÅÅλÕù°ÔÈü  | 
| # @author hxp  | 
| # @date 2022-09-21  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ¿ç·þÅÅλÕù°ÔÈü  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2022-09-21 21:30"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import GameWorld  | 
| import ShareDefine  | 
| import IpyGameDataPY  | 
| import PlayerViewCache  | 
| import PlayerDBGSEvent  | 
| import ChPyNetSendPack  | 
| import IPY_PlayerDefine  | 
| import PlayerCompensation  | 
| import CrossRealmPlayer  | 
| import DataRecordPack  | 
| import CrossRealmMsg  | 
| import PlayerControl  | 
| import PyDataManager  | 
| import NetPackCommon  | 
| import PyGameData  | 
| import ChConfig  | 
| import PlayerFB  | 
|   | 
| import datetime  | 
| import random  | 
| import time  | 
|   | 
| Def_CrossChampionshipPlayerMax = 64 # ×î´óÍæ¼ÒÊý  | 
| Def_CrossChampionshipPlayerWFCount = 8 # Ê¤¸ºÅÅλËùÐèÍæ¼ÒÊý  | 
|   | 
| Def_RecType_CrossChampionshipGroup = ShareDefine.Def_UniversalGameRecType_CrossChampionshipGroup  | 
| '''  | 
| ¿ç·þÅÅλÕù°ÔÈü·Ö×éÐÅÏ¢  | 
| ShareDefine.Def_UniversalGameRecType_CrossChampionshipGroup  | 
| time:time                Õ½¶·½áËãʱ¼ä  | 
| value1:zoneID            ·ÖÇøID  | 
| value2:groupInfo         ·Ö×é±êʶ*100+¶ÔÕ½±àºÅ  | 
| value3:playerIDA        Íæ¼ÒIDA  | 
| value4:playerIDB        Íæ¼ÒIDB  | 
| value5:winPlayerID      »ñÊ¤Íæ¼ÒID  | 
| '''  | 
|   | 
| Def_RecType_CrossChampionshipGuess = ShareDefine.Def_UniversalGameRecType_CrossChampionshipGuess  | 
| '''  | 
| ¿ç·þÅÅλÕù°ÔÈü¾º²Â¼Ç¼ÐÅÏ¢  | 
| ShareDefine.Def_UniversalGameRecType_CrossChampionshipGuess  | 
| value1:zoneID            ·ÖÇøID  | 
| value2:guessInfo         ¾º²ÂÀàÐÍ*100 + ¾º²ÂÖµ£º  ÀàÐÍ£º8-8Ç¿£»4-4Ç¿£» Öµ£º¶ÔÓ¦ÅÅÃû  | 
| value3:guessPlayerID     ¾º²ÂÍæ¼ÒID  | 
| value4:tagPlayerID       Ä¿±êÍæ¼ÒID  | 
| value5:moneyTotal        Í¶×¢×Ü»õ±ÒÖµ  | 
| StrValue1:isClose        ÊÇ·ñÒѽáËã  | 
| '''  | 
|   | 
| Def_RecType_CrossChampionshipOfficial = ShareDefine.Def_UniversalGameRecType_CrossChampionshipOfficial  | 
| '''  | 
| ¿ç·þÅÅλÕù°ÔÈü×îÖÕÅÅÃû¹ÙÖ°ÐÅÏ¢  | 
| ShareDefine.Def_UniversalGameRecType_CrossChampionshipOfficial  | 
| time:time                ÉÏÒ»´Î´ÇÍËϼ¶ÏɹÙʱ¼ä  | 
| value1:zoneID¹ÙÖ°ID      ¹ÙÖ°ID*10 + ·ÖÇøID  | 
| value2:playerID          Íæ¼ÒID£¬¿ÉÄÜΪ0  | 
| value3:worshipValue      ±»Ä¤°Ý´ÎÊý*10 + ÊÇ·ñË«±¶  | 
| value4:rank              ÅÅÃû  | 
| StrValue3:               [ÉêÇë¸Ã¹ÙÖ°Íæ¼ÒID,...]  | 
| '''  | 
|   | 
| Def_RecType_CrossChampionshipOffChallenge = ShareDefine.Def_UniversalGameRecType_CrossChampionshipOffChallenge  | 
| '''  | 
| ¿ç·þÅÅλÕù°ÔÈü¹ÙÖ°ÌôÕ½ÐÅÏ¢  | 
| ShareDefine.Def_UniversalGameRecType_CrossChampionshipOffChallenge  | 
| value1:zoneID¹ÙÖ°ID      ¹ÙÖ°ID*10 + ·ÖÇøID  | 
| StrValue3:               {ÌôÕ½Íæ¼ÒÐÅÏ¢key:value, ...}  | 
| '''  | 
|   | 
| class ChampionshipOfficial():  | 
|     ## Õù°ÔÈü¹Ù¾ôÍæ¼Ò  | 
|       | 
|     def __init__(self):  | 
|         self.zoneID = 0  | 
|         self.officialID = 0 # ¹ÙÖ°ID  | 
|         self.lastDismissJuniorTime = 0 # ÉϴδÇÍËϼ¶ÏɹÙʱ¼ä´Á  | 
|           | 
|         self.rank = 0 # Ãû´Î  | 
|         self.worshipCount = 0 # ±»Ä¤°Ý´ÎÊý£¬ÈËÆøÖµ  | 
|         self.applyPlayerInfo = {} # ÉêÇë¸Ã¹ÙÖ°Íæ¼ÒÐÅÏ¢ {playerID:{Íæ¼Ò¼ò¶ÌÐÅÏ¢×Öµä}, ...}  | 
|         self.challengeList = [] # ÌôÕ½¼Ç¼ÐÅÏ¢ [{ÌôÕ½Íæ¼ÒÐÅÏ¢key:value, ...}, ...] key: Ret,AccID,Name,Time  | 
|           | 
|         self.ResetPlayer()  | 
|           | 
|         self.worshipDouble = 0 # Ä¤°ÝÊÇ·ñË«±¶   | 
|         return  | 
|       | 
|     def ResetPlayer(self):  | 
|         self.playerID = 0  | 
|         self.accID = ""  | 
|         self.playerName = ""  | 
|         self.job = 0  | 
|         self.lv = 0  | 
|         self.fightPower = 0  | 
|         self.realmLV = 0  | 
|         return  | 
|       | 
|     def GetString(self):  | 
|         for applyPlayerID in self.applyPlayerInfo.keys():  | 
|             curCache = PlayerViewCache.FindViewCache(applyPlayerID)  | 
|             if curCache:  | 
|                 playerShortInfo = {}  | 
|                 cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)  | 
|                 playerShortInfo["AccID"] = cacheDict.get("AccID", "")  | 
|                 playerShortInfo["Name"] = cacheDict.get("Name", str(applyPlayerID))  | 
|                 playerShortInfo["Job"] = cacheDict.get("Job", 1)  | 
|                 playerShortInfo["LV"] = cacheDict.get("LV", 1)  | 
|                 playerShortInfo["FightPower"] = cacheDict.get("FightPower", 0)  | 
|                 playerShortInfo["RealmLV"] = cacheDict.get("RealmLV", 0)  | 
|                 self.applyPlayerInfo[applyPlayerID] = playerShortInfo  | 
|         return {"zoneID":self.zoneID, "officialID":self.officialID, "lastDismissJuniorTime":self.lastDismissJuniorTime,  | 
|                 "accID":self.accID, "playerID":self.playerID, "playerName":self.playerName,  | 
|                 "job":self.job, "lv":self.lv, "fightPower":self.fightPower, "realmLV":self.realmLV, "rank":self.rank,  | 
|                 "worshipCount":self.worshipCount, "applyPlayerInfo":self.applyPlayerInfo, "challengeList":self.challengeList,  | 
|                 "worshipDouble":self.worshipDouble  | 
|                 }  | 
|           | 
|     def SetAttr(self, attrDict):  | 
|         for k, v in attrDict.items():  | 
|             setattr(self, k, v)  | 
|         return  | 
|       | 
| class ChampionshipOfficialZoneMgr():  | 
|     ## Õù°ÔÈüÅÅλ·ÖÇø¹ÜÀí  | 
|       | 
|     def __init__(self, zoneID):  | 
|         self.zoneID = zoneID  | 
|         self.officialInfo = {} # ¹Ù¾ôÐÅÏ¢ {officialID:ChampionshipOfficial, ...}  | 
|         return  | 
|       | 
|     def GetOfficialObj(self, officialID):  | 
|         officialObj = None  | 
|         if officialID in self.officialInfo:  | 
|             officialObj = self.officialInfo[officialID]  | 
|             if GameWorld.IsCrossServer() and officialObj.playerID:  | 
|                 UpdCachePlayerInfo(officialObj, officialObj.playerID)  | 
|         else:  | 
|             ipyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", officialID)  | 
|             if ipyData:  | 
|                 officialObj = ChampionshipOfficial()  | 
|                 officialObj.zoneID = self.zoneID  | 
|                 officialObj.officialID = officialID  | 
|                   | 
|                 self.officialInfo[officialID] = officialObj  | 
|                   | 
|         if not officialObj:  | 
|             GameWorld.ErrLog("ÏɹٹÙÖ°Êý¾ÝÐÅÏ¢²»´æÔÚ! officialID=%s" % officialID)  | 
|               | 
|         return officialObj  | 
|       | 
|     def GetPlayerOfficial(self, playerID):  | 
|         for offObj in self.officialInfo.values():  | 
|             if offObj.playerID == playerID:  | 
|                 return offObj  | 
|         return  | 
|       | 
| class ChampionshipGuess():  | 
|     ## Õù°ÔÈü¾º²Â  | 
|       | 
|     def __init__(self):  | 
|         self.zoneID = 0  | 
|         self.guessType = 0 # ¾º²ÂÀàÐÍ£º8-8Ç¿£»4-4Ç¿  | 
|         self.guessPlayerID = 0 # ¾º²ÂÍæ¼ÒID  | 
|         self.tagPlayerID = 0 # Ä¿±êÍæ¼ÒID  | 
|         self.moneyTotal = 0 # Í¶×¢×Ü»õ±ÒÖµ  | 
|         self.guessRank = 0 # ¾º²ÂÃû´Î£¬Ã»ÓÐÃû´ÎµÄ¾º²ÂĬÈÏ0£»1-´ú±íµÚÒ»Ãû  | 
|         self.isClose = 0 # ÊÇ·ñÒѽáËã  | 
|         return  | 
|       | 
|     def GetString(self):  | 
|         return {"zoneID":self.zoneID, "guessType":self.guessType, "guessRank":self.guessRank,   | 
|                 "guessPlayerID":self.guessPlayerID, "tagPlayerID":self.tagPlayerID, "moneyTotal":self.moneyTotal}  | 
|           | 
|     def SetAttr(self, attrDict):  | 
|         for k, v in attrDict.items():  | 
|             setattr(self, k, v)  | 
|         return  | 
|       | 
|       | 
| class ChampionshipBatPlayer():  | 
|     ## Õù°ÔÈüÍæ¼Ò  | 
|       | 
|     def __init__(self):  | 
|         self.zoneID = 0  | 
|         self.accID = ""  | 
|         self.playerID = 0  | 
|         self.playerName = ""  | 
|         self.job = 0  | 
|         self.lv = 0  | 
|         self.fightPower = 0  | 
|         self.realmLV = 0  | 
|         return  | 
|       | 
|     def GetString(self):  | 
|         return {"zoneID":self.zoneID, "accID":self.accID, "playerID":self.playerID, "playerName":self.playerName,  | 
|                 "job":self.job, "lv":self.lv, "fightPower":self.fightPower, "realmLV":self.realmLV}  | 
|       | 
|     def SetAttr(self, attrDict):  | 
|         for k, v in attrDict.items():  | 
|             setattr(self, k, v)  | 
|         return  | 
|       | 
| class ChampionshipBattle():  | 
|     ## Õù°ÔÈü¶ÔÕ½  | 
|       | 
|     def __init__(self):  | 
|         self.overTime = 0 # Õ½¶·½áËãʱ¼ä  | 
|         self.zoneID = 0  | 
|         self.groupMark = 0 # ·Ö×é±êʶ£¬Èç 64 32 16 8 4 2  | 
|         self.battleNum = 0 # ¶ÔÕ½±àºÅ£¬Èç 1 ~ 32  | 
|         self.playerIDA = 0  | 
|         self.playerIDB = 0  | 
|         self.winPlayerID = 0  | 
|           | 
|         # ²»´æµµ  | 
|         self.roomID = 0  | 
|         self.mapID = 0  | 
|         self.copyMapID = 0  | 
|         return  | 
|       | 
|     def GetString(self):  | 
|         return {"overTime":self.overTime, "zoneID":self.zoneID, "groupMark":self.groupMark, "battleNum":self.battleNum,  | 
|                 "playerIDA":self.playerIDA, "playerIDB":self.playerIDB, "winPlayerID":self.winPlayerID}  | 
|           | 
|     def SetAttr(self, attrDict):  | 
|         for k, v in attrDict.items():  | 
|             setattr(self, k, v)  | 
|         return  | 
|       | 
| class ChampionshipPKZoneMgr():  | 
|     ## Õù°ÔÈüPK·ÖÇø¹ÜÀí  | 
|       | 
|     def __init__(self, zoneID):  | 
|         self.zoneID = zoneID  | 
|         self.playerDict = {} # ²ÎÈüÍæ¼Ò {playerID:ChampionshipBatPlayer, ...}  | 
|         self.battleInfo = {} # ·Ö×é¶ÔÕ½ÐÅÏ¢ {·Ö×é±êʶ:{¶ÔÕ½±àºÅ:ChampionshipBattle, ...}, ...}  | 
|         self.guessInfo = {} # ¾º²ÂÐÅÏ¢ {¾º²ÂÀàÐÍ:{¾º²ÂÍæ¼ÒID:[ChampionshipGuess, ...]}, ...}  | 
|         self.supportCountInfo = {} # {¾º²ÂÀàÐÍ:{±»¾º²ÂÍæ¼ÒID:Ö§³ÖÈËÊý, ...}, ...}  | 
|           | 
|         # ×Ó·þ  | 
|         self.syncGuessPlayerIDInfo = {} # Í¬²½¹ý¾º²ÂÐÅÏ¢µÄÍæ¼ÒID {playerID:tick, ...}  | 
|         return  | 
|       | 
|     def AddBattle(self, groupMark, battleNum, battle):  | 
|         if groupMark not in self.battleInfo:  | 
|             self.battleInfo[groupMark] = {}  | 
|         battleDict = self.battleInfo[groupMark]  | 
|         battleDict[battleNum] = battle  | 
|         self.battleInfo[groupMark] = battleDict  | 
|         return  | 
|       | 
|     def GetBattle(self, groupMark, battleNum):  | 
|         battle = None  | 
|         if groupMark in self.battleInfo:  | 
|             battleDict = self.battleInfo[groupMark]  | 
|             if battleNum in battleDict:  | 
|                 battle = battleDict[battleNum]  | 
|                   | 
|         if not battle:  | 
|             GameWorld.Log("Î޸ÿç·þÅÅλÕù°ÔÈü¶ÔÕ½³¡´ÎÐÅÏ¢: groupMark=%s,battleNum=%s" % (groupMark, battleNum))  | 
|               | 
|         # ²»¿ÉÄÜÖ´ÐеĴúÂ룬·½±ã . ³öÌáʾ´úÂë  | 
|         if False:  | 
|             battle = ChampionshipBattle()  | 
|         return battle  | 
|       | 
|     def GetBatPlayerIDList(self): return self.playerDict.keys()  | 
|     def GetBatPlayer(self, playerID):  | 
|         batPlayer = None  | 
|         if playerID in self.playerDict:  | 
|             batPlayer = self.playerDict[playerID]  | 
|             if GameWorld.IsCrossServer():  | 
|                 UpdCachePlayerInfo(batPlayer, playerID)  | 
|                   | 
|         # ²»¿ÉÄÜÖ´ÐеĴúÂ룬·½±ã . ³öÌáʾ´úÂë  | 
|         if False:  | 
|             batPlayer = ChampionshipBatPlayer()  | 
|         return batPlayer  | 
|       | 
|     def GetPlayerGuessList(self, playerID, guessType):  | 
|         ## »ñÈ¡Íæ¼Ò¾º²ÂÁÐ±í  | 
|         if guessType not in self.guessInfo:  | 
|             self.guessInfo[guessType] = {}  | 
|         playerGuessDict = self.guessInfo[guessType]  | 
|         if playerID not in playerGuessDict:  | 
|             playerGuessDict[playerID] = []  | 
|         return playerGuessDict[playerID]  | 
|       | 
|     def GetTop8PlayerIDList(self):  | 
|         ## »ñȡǰ8Ç¿Íæ¼ÒIDÁÐ±í  | 
|         top8PlayerIDList = []  | 
|         preGroupMark = 16 # È¡16ǿս¶·Ê¤Õß  | 
|         battleNumList = self.battleInfo.get(preGroupMark, {}).keys()  | 
|         for battleNum in battleNumList:  | 
|             batObj = self.GetBattle(preGroupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|             if batObj.overTime and batObj.winPlayerID:  | 
|                 top8PlayerIDList.append(batObj.winPlayerID)  | 
|         return top8PlayerIDList  | 
|       | 
| def UpdCachePlayerInfo(obj, playerID):  | 
|     ## ¸üÐÂÍæ¼Ò»º´æÐÅÏ¢  | 
|       | 
|     # »úÆ÷ÈË  | 
|     if not obj or not hasattr(obj, "playerName"):  | 
|         return  | 
|       | 
|     if playerID < 10000:  | 
|         if obj.playerName:  | 
|             return  | 
|         obj.accID = "accID%s@robot@s1" % (playerID)  | 
|         obj.playerName = "name%s" % playerID  | 
|         obj.job = random.randint(1, 2)  | 
|         obj.lv = random.randint(200, 300)  | 
|         obj.fightPower = random.randint(100000, 1000000)  | 
|         obj.realmLV = random.randint(10, 20)  | 
|         return  | 
|     curCache = PlayerViewCache.FindViewCache(playerID)  | 
|     if curCache:  | 
|         cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)  | 
|         obj.accID = cacheDict.get("AccID", obj.accID)  | 
|         obj.playerName = cacheDict.get("Name", obj.playerName)  | 
|         obj.job = cacheDict.get("Job", obj.job)  | 
|         obj.lv = cacheDict.get("LV", obj.lv)  | 
|         obj.fightPower = cacheDict.get("FightPower", obj.fightPower)  | 
|         obj.realmLV = cacheDict.get("RealmLV", obj.realmLV)  | 
|           | 
|     return  | 
|   | 
| class ChampionshipMgr():  | 
|     ## Õù°ÔÈü¹ÜÀí  | 
|       | 
|     def __init__(self):  | 
|         '''×¢ÒâÇø·Ö¿ç·þÆ¥Åä·ÖÇø¡¢ÅÅλ·ÖÇø¡¢ÏɹٷÖÇø£¬ÈýÕß²»Ò»Ñù  | 
|                                         Æ¥Åä·ÖÇø£ºµ±Ç°½øÐÐÖеĿç·þÆ¥ÅäPK·ÖÇø CrossRealmPK  | 
|                                         ÅÅλ·ÖÇø£ºÈ¡ÉÏÒ»Èü¼¾µÄ¿ç·þÆ¥ÅäPK·ÖÇøÅÅÃûǰ64×÷ΪPK·ÖÇø£¬¿ÉÄÜÓ뵱ǰ½øÐÐÖеĿç·þPK·ÖÇø²»Ò»Ñù  | 
|                                         ÏɹٷÖÇø£ºÓÉÅÅλ·ÖÇøPK¾ö³öµÄ½á¹û×öΪÏɹٷÖÇø£¬¿ÉÄÜÓ뵱ǰ½øÐÐÖеÄÅÅλPK·ÖÇø²»Ò»Ñù  | 
|         '''  | 
|         self._pkZoneInfo = {} # ÅÅλ¶ÔÕ½·ÖÇø {zoneID:ChampionshipZoneMgr, ...}  | 
|         self._officialZoneInfo = {} # ÏɹٷÖÇø {zoneID:ChampionshipOfficialZoneMgr, ...}  | 
|         return  | 
|       | 
|     def ClearPKZone(self):  | 
|         self._pkZoneInfo = {}  | 
|         return  | 
|       | 
|     def GetChampPKZoneIDList(self): return self._pkZoneInfo.keys()  | 
|     def GetChampPKZoneMgr(self, zoneID, addNew=False):  | 
|         pkZoneMgr = None  | 
|         if zoneID in self._pkZoneInfo:  | 
|             pkZoneMgr = self._pkZoneInfo[zoneID]  | 
|         elif addNew:  | 
|             pkZoneMgr = ChampionshipPKZoneMgr(zoneID)  | 
|             self._pkZoneInfo[zoneID] = pkZoneMgr  | 
|         if not pkZoneMgr:  | 
|             GameWorld.ErrLog("ÕÒ²»µ½¿ç·þÅÅλÈü·ÖÇø¹ÜÀí! zoneID=%s" % zoneID)  | 
|         return pkZoneMgr  | 
|       | 
|     def GetPlayerPKZoneID(self, playerID):  | 
|         ## »ñÈ¡Íæ¼ÒÅÅÎ»Íæ·¨ËùÊô·ÖÇø - ×Ó·þרÓà  | 
|         # @return: Èç¹ûÔÚÅÅλÖÐÔò·µ»ØËùÔÚÅÅλ·ÖÇø£¬·ñÔò·µ»Øµ±Ç°·þÎñÆ÷ËùÔÚ¿ç·þÆ¥ÅäPK·ÖÇø  | 
|         for zoneID in self._pkZoneInfo.keys():  | 
|             pkZoneMgr = self.GetChampPKZoneMgr(zoneID)  | 
|             if not pkZoneMgr:  | 
|                 continue  | 
|             if playerID in pkZoneMgr.GetBatPlayerIDList():  | 
|                 return zoneID  | 
|         return GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)  | 
|       | 
|     ##=============================================================================================  | 
|       | 
|     def ClearOfficialZone(self):  | 
|         self._officialZoneInfo = {}  | 
|         return  | 
|       | 
|     def GetChampOfficialZoneIDList(self): return self._officialZoneInfo.keys()  | 
|     def GetChampOfficialZoneMgr(self, zoneID):  | 
|         if zoneID in self._officialZoneInfo:  | 
|             offZoneMgr = self._officialZoneInfo[zoneID]  | 
|         else:  | 
|             offZoneMgr = ChampionshipOfficialZoneMgr(zoneID)  | 
|             self._officialZoneInfo[zoneID] = offZoneMgr  | 
|         return offZoneMgr  | 
|       | 
|     def GetPlayerOfficialZoneID(self, playerID):  | 
|         ## »ñÈ¡Íæ¼ÒÅÅÎ»Íæ·¨ËùÊô·ÖÇø - ×Ó·þרÓà  | 
|         # @return: Èç¹ûÔÚ·ÖÇøÈÎÖ°ÖÐÔò·µ»ØËùÔÚÅÅλ·ÖÇø£¬·ñÔò·µ»Øµ±Ç°·þÎñÆ÷ËùÔÚ¿ç·þÆ¥ÅäPK·ÖÇø  | 
|         for zoneID in self._officialZoneInfo.keys():  | 
|             offZoneMgr = self.GetChampOfficialZoneMgr(zoneID)  | 
|             if offZoneMgr.GetPlayerOfficial(playerID):  | 
|                 return zoneID  | 
|         return GameWorld.GetGameWorld().GetDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)  | 
|       | 
| def GetChampionshipMgr():  | 
|     mgr = PyGameData.g_championshipMgr  | 
|     if mgr == None:  | 
|         mgr = ChampionshipMgr()  | 
|         PyGameData.g_championshipMgr = mgr  | 
|     return mgr  | 
|   | 
| def OnServerStart():  | 
|       | 
|     if not GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|       | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|     groupRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipGroup)  | 
|     GameWorld.Log("¼ÓÔØ¿ç·þÅÅÎ»Íæ¼Ò·Ö×é¼Ç¼! %s" % groupRecDataList.Count())  | 
|     groupMarkList = ShareDefine.CrossChampionshipEnterStateInfo.values()  | 
|       | 
|     for index in xrange(groupRecDataList.Count()):  | 
|         recData = groupRecDataList.At(index)  | 
|         overTime = recData.GetTime()  | 
|         zoneID = recData.GetValue1()  | 
|         groupInfo = recData.GetValue2()  | 
|         playerIDA = recData.GetValue3()  | 
|         playerIDB = recData.GetValue4()  | 
|         winPlayerID = recData.GetValue5()  | 
|           | 
|         #if not playerIDA and not playerIDB:  | 
|         #    continue  | 
|           | 
|         groupMark = groupInfo / 100  | 
|         battleNum = groupInfo % 100  | 
|           | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|           | 
|         if groupMark in groupMarkList and battleNum:  | 
|             battle = ChampionshipBattle()  | 
|             battle.overTime = overTime  | 
|             battle.zoneID = zoneID  | 
|             battle.groupMark = groupMark  | 
|             battle.battleNum = battleNum  | 
|             battle.playerIDA = playerIDA  | 
|             battle.playerIDB = playerIDB  | 
|             battle.winPlayerID = winPlayerID  | 
|             pkZoneMgr.AddBattle(groupMark, battleNum, battle)  | 
|             GameWorld.Log("·Ö×éÍæ¼Ò: zoneID=%s,groupMark=%s,battleNum=%s,playerIDA=%s,playerIDB=%s,winPlayerID=%s"   | 
|                           % (zoneID, groupMark, battleNum, playerIDA, playerIDB, winPlayerID))  | 
|               | 
|         # ·Ç·Ö×éÊý¾ÝΪ²ÎÈüÍæ¼ÒÊý¾Ý  | 
|         elif playerIDA:  | 
|             playerID = playerIDA  | 
|             batPlayer = ChampionshipBatPlayer()  | 
|             batPlayer.zoneID = zoneID  | 
|             batPlayer.playerID = playerID  | 
|             pkZoneMgr.playerDict[playerID] = batPlayer  | 
|             GameWorld.Log("²ÎÈüÍæ¼Ò: zoneID=%s,playerID=%s" % (zoneID, playerID))  | 
|               | 
|     guessRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipGuess)  | 
|     GameWorld.Log("¼ÓÔØ¿ç·þÅÅÎ»Íæ¼Ò¾º²Â¼Ç¼! %s" % guessRecDataList.Count())  | 
|     for index in xrange(guessRecDataList.Count()):  | 
|         recData = guessRecDataList.At(index)  | 
|         zoneID = recData.GetValue1()  | 
|         guessInfo = recData.GetValue2()  | 
|         guessType = guessInfo / 100  | 
|         guessRank = guessInfo % 100  | 
|         guessPlayerID = recData.GetValue3()  | 
|         tagPlayerID = recData.GetValue4()  | 
|         moneyTotal = recData.GetValue5()  | 
|         isClose = GameWorld.ToIntDef(recData.GetStrValue1(), 0)  | 
|           | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         playerGuessList = pkZoneMgr.GetPlayerGuessList(guessPlayerID, guessType)  | 
|         guessObj = ChampionshipGuess()  | 
|         guessObj.zoneID = zoneID  | 
|         guessObj.guessType = guessType  | 
|         guessObj.guessRank = guessRank  | 
|         guessObj.guessPlayerID = guessPlayerID  | 
|         guessObj.tagPlayerID = tagPlayerID  | 
|         guessObj.moneyTotal = moneyTotal  | 
|         guessObj.isClose = isClose  | 
|         playerGuessList.append(guessObj)  | 
|           | 
|         if guessType not in pkZoneMgr.supportCountInfo:  | 
|             pkZoneMgr.supportCountInfo[guessType] = {}  | 
|         playerSupportCountDict = pkZoneMgr.supportCountInfo[guessType]  | 
|         playerSupportCountDict[tagPlayerID] = playerSupportCountDict.get(tagPlayerID, 0) + 1  | 
|           | 
|     officialRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipOfficial)  | 
|     GameWorld.Log("¼ÓÔØ¿ç·þÅÅÎ»Íæ¼Ò¹ÙÖ°ÐÅÏ¢! %s" % officialRecDataList.Count())  | 
|     for index in xrange(officialRecDataList.Count()):  | 
|         recData = officialRecDataList.At(index)  | 
|         lastDismissJuniorTime = recData.GetTime()  | 
|         value1 = recData.GetValue1()  | 
|         officialID = value1 / 10  | 
|         zoneID = value1 % 10  | 
|         playerID = recData.GetValue2()  | 
|         worshipValue = recData.GetValue3()  | 
|         worshipCount = worshipValue / 10  | 
|         worshipDouble = worshipValue % 10  | 
|         rank = recData.GetValue4()  | 
|         strValue3 = recData.GetStrValue3()  | 
|         try:  | 
|             applyPlayerIDList = eval(strValue3) if strValue3 else []  | 
|         except:  | 
|             applyPlayerIDList = []  | 
|               | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|           | 
|         offObj = ChampionshipOfficial()  | 
|         offObj.zoneID = zoneID  | 
|         offObj.officialID = officialID  | 
|         offObj.lastDismissJuniorTime = lastDismissJuniorTime  | 
|         offObj.playerID = playerID  | 
|         offObj.worshipCount = worshipCount  | 
|         offObj.worshipDouble = worshipDouble  | 
|         offObj.rank = rank  | 
|         offObj.applyPlayerInfo = {applyPlayerID:{} for applyPlayerID in applyPlayerIDList}  | 
|           | 
|         offZoneMgr.officialInfo[officialID] = offObj  | 
|         GameWorld.Log("    zoneID=%s,officialID=%s,playerID=%s,rank=%s" % (zoneID, officialID, playerID, rank))  | 
|           | 
|     challengeRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipOffChallenge)  | 
|     GameWorld.Log("¼ÓÔØ¿ç·þÅÅλ¹ÙÖ°ÌôÕ½¼Ç¼ÐÅÏ¢! %s" % challengeRecDataList.Count())  | 
|     for index in xrange(challengeRecDataList.Count()):  | 
|         recData = challengeRecDataList.At(index)  | 
|         value1 = recData.GetValue1()  | 
|         officialID = value1 / 10  | 
|         zoneID = value1 % 10  | 
|         strValue3 = recData.GetStrValue3()  | 
|         if not strValue3:  | 
|             continue  | 
|         try:  | 
|             challengeDict = eval(strValue3)  | 
|         except:  | 
|             continue  | 
|           | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|         if not offObj:  | 
|             continue  | 
|         offObj.challengeList.append(challengeDict)  | 
|         #GameWorld.Log("    zoneID=%s,officialID=%s,ÌôÕ½¼Ç¼=%s" % (zoneID, officialID, challengeDict))  | 
|           | 
|     return  | 
|   | 
| def OnServerClose():  | 
|     SaveChampionshipData()  | 
|     return  | 
|   | 
| def SaveChampionshipData():  | 
|     if not GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|       | 
|     pkZoneIDList = champMgr.GetChampPKZoneIDList()  | 
|     GameWorld.Log("±£´æ¿ç·þÅÅÎ»Íæ¼Ò·Ö×é¼Ç¼! pkZoneIDList=%s" % pkZoneIDList)  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipGroup)  | 
|     groupRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipGroup)  | 
|     for zoneID in pkZoneIDList:  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         # ±£´æ²ÎÈüÍæ¼ÒÃûµ¥  | 
|         batPlayerIDList = pkZoneMgr.GetBatPlayerIDList()  | 
|         GameWorld.Log("    zoneID=%s,batPlayerIDCount=%s, %s" % (zoneID, len(batPlayerIDList), batPlayerIDList))  | 
|         for playerID in batPlayerIDList:  | 
|             recData = groupRecDataList.AddRec()  | 
|             recData.SetValue1(zoneID)  | 
|             recData.SetValue2(0) # ÎÞ·Ö×éÍæ¼Ò£¬´ú±í²ÎÈüÍæ¼Ò·Ö×éÐÅÏ¢´æ0  | 
|             recData.SetValue3(playerID)  | 
|               | 
|         # ±£´æ·Ö×é¼Ç¼  | 
|         GameWorld.Log("    zoneID=%s,battleInfoKey=%s" % (zoneID, pkZoneMgr.battleInfo.keys()))  | 
|         for groupMark, groupDict in pkZoneMgr.battleInfo.items():  | 
|             GameWorld.Log("        zoneID=%s,groupMark=%s,count=%s" % (zoneID, groupMark, len(groupDict)))  | 
|             for battleNum, batObj in groupDict.items():  | 
|                 groupInfo = groupMark * 100 + battleNum # ·Ö×é±êʶ*100+¶ÔÕ½±àºÅ  | 
|                 recData = groupRecDataList.AddRec()  | 
|                 recData.SetTime(batObj.overTime)  | 
|                 recData.SetValue1(zoneID)  | 
|                 recData.SetValue2(groupInfo) # ÎÞ·Ö×éÍæ¼Ò£¬´ú±í²ÎÈüÍæ¼Ò·Ö×éÐÅÏ¢´æ0  | 
|                 recData.SetValue3(batObj.playerIDA)  | 
|                 recData.SetValue4(batObj.playerIDB)  | 
|                 recData.SetValue5(batObj.winPlayerID)  | 
|                   | 
|     GameWorld.Log("±£´æ¿ç·þÅÅÎ»Íæ¼Ò¾º²Â¼Ç¼!")  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipGuess)  | 
|     guessRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipGuess)  | 
|     for zoneID in pkZoneIDList:  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         for guessType, playerGuessDict in pkZoneMgr.guessInfo.items():  | 
|             for guessPlayerID, guessObjList in playerGuessDict.items():  | 
|                 #GameWorld.Log("    zoneID=%s,guessType=%s,guessPlayerID=%s,guessCount=%s" % (zoneID, guessType, guessPlayerID, len(guessObjList)))  | 
|                 for guessObj in guessObjList:  | 
|                     recData = guessRecDataList.AddRec()  | 
|                     recData.SetValue1(zoneID)  | 
|                     recData.SetValue2(guessType * 100 + guessObj.guessRank)  | 
|                     recData.SetValue3(guessPlayerID)  | 
|                     recData.SetValue4(guessObj.tagPlayerID)  | 
|                     recData.SetValue5(guessObj.moneyTotal)  | 
|                     recData.SetStrValue1("%s" % guessObj.isClose)  | 
|                       | 
|     offZoneIDList = champMgr.GetChampOfficialZoneIDList()  | 
|     GameWorld.Log("±£´æ¿ç·þÅÅÎ»Íæ¼Ò¹ÙÖ°ÐÅÏ¢! offZoneIDList=%s" % offZoneIDList)  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipOfficial)  | 
|     officialRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipOfficial)  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipOffChallenge)  | 
|     challengeRecDataList = universalRecMgr.GetTypeList(Def_RecType_CrossChampionshipOffChallenge)  | 
|     for zoneID in offZoneIDList:  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         #GameWorld.Log("    zoneID=%s,officialInfoKey=%s" % (zoneID, offZoneMgr.officialInfo.keys()))  | 
|         for officialID in offZoneMgr.officialInfo.keys():  | 
|             offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|             if not offObj:  | 
|                 continue  | 
|             value1 = offObj.officialID * 10 + zoneID  | 
|             recData = officialRecDataList.AddRec()  | 
|             recData.SetTime(offObj.lastDismissJuniorTime)  | 
|             recData.SetValue1(value1)  | 
|             recData.SetValue2(offObj.playerID)  | 
|             recData.SetValue3(offObj.worshipCount * 10 + offObj.worshipDouble)  | 
|             recData.SetValue4(offObj.rank)  | 
|             strValue3 = "%s" % offObj.applyPlayerInfo.keys()  | 
|             strValue3 = strValue3.replace(" ", "")  | 
|             recData.SetStrValue3(strValue3)  | 
|               | 
|             #GameWorld.Log("        zoneID=%s,officialID=%s,playerID=%s,rank=%s,challengeCount=%s"   | 
|             #              % (zoneID, officialID, offObj.playerID, offObj.rank, len(offObj.challengeList)))  | 
|             for challengeDict in offObj.challengeList:  | 
|                 challRecData = challengeRecDataList.AddRec()  | 
|                 challRecData.SetValue1(value1)  | 
|                 strValue3 = str(challengeDict)  | 
|                 strValue3 = strValue3.replace(" ", "")  | 
|                 challRecData.SetStrValue3(strValue3)  | 
|                   | 
|     return  | 
|   | 
| def DoOnDay():  | 
|       | 
|     if not GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     dailyOfficialInfo = {}  | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampOfficialZoneIDList():  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         for officialID in offZoneMgr.officialInfo.keys():  | 
|             offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|             if not offObj:  | 
|                 continue  | 
|             if not offObj.playerID:  | 
|                 continue  | 
|             dailyOfficialInfo[offObj.playerID] = officialID  | 
|               | 
|     if dailyOfficialInfo:  | 
|         serverGroupIDList = []  | 
|         CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ChampionshipDailyOfficial, dailyOfficialInfo, serverGroupIDList)  | 
|           | 
|     return  | 
|   | 
| def DoOnDayEx():  | 
|       | 
|     if not GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampOfficialZoneIDList():  | 
|         syncOfficialIDList = []  | 
|         mainOfficialList = [] # ½öÖ÷Ïɹٿɱ»Ä¤°Ý  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         for officialID in offZoneMgr.officialInfo.keys():  | 
|             offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|             if not offObj:  | 
|                 continue  | 
|             if not offObj.playerID:  | 
|                 continue  | 
|               | 
|             if offObj.worshipDouble:  | 
|                 offObj.worshipDouble = 0 # ÖØÖÃÿÈÕË«±¶Ä¤°Ý  | 
|                 syncOfficialIDList.append(officialID)  | 
|                 GameWorld.Log("ÖØÖýñÈÕË«±¶Ä¤°ÝÌØÈ¨ÏɹÙ: zoneID=%s,officialID=%s,playerID=%s"   | 
|                               % (zoneID, officialID, offObj.playerID), zoneID)  | 
|                   | 
|             mainIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", officialID)  | 
|             if mainIpyData and mainIpyData.GetJuniorOfficialIDList():  | 
|                 mainOfficialList.append(offObj)  | 
|                   | 
|         if mainOfficialList:  | 
|             offObj = random.choice(mainOfficialList)  | 
|             officialID = offObj.officialID  | 
|             offObj.worshipDouble = 1 # Ëæ»úij¸öÏɹٻñµÃ½ñÈÕË«±¶ÌØÈ¨  | 
|             GameWorld.Log("Ëæ»ú½ñÈÕË«±¶Ä¤°ÝÌØÈ¨ÏɹÙ: zoneID=%s,officialID=%s,playerID=%s"   | 
|                           % (zoneID, officialID, offObj.playerID), zoneID)  | 
|             if officialID not in syncOfficialIDList:  | 
|                 syncOfficialIDList.append(officialID)  | 
|                   | 
|         if syncOfficialIDList:  | 
|             Send_CrossServerMsg_ChampionshipOfficial(zoneID, syncOfficialIDList)  | 
|               | 
|     return  | 
|   | 
| def IsChampionshipPlayer(playerID):  | 
|     ## ÊÇ·ñÅÅλÈüÏà¹ØÍæ¼Ò  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         if playerID in pkZoneMgr.GetBatPlayerIDList():  | 
|             # ÊDzÎÈüÍæ¼Ò  | 
|             return True  | 
|           | 
|     for zoneID in champMgr.GetChampOfficialZoneIDList():  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         for offObj in offZoneMgr.officialInfo.values():  | 
|             if playerID == offObj.playerID:  | 
|                 # ÊÇÏɹ٠ | 
|                 return True  | 
|             if playerID in offObj.applyPlayerInfo:  | 
|                 # ÉêÇëÏɹÙÖÐ  | 
|                 return True  | 
|     return False  | 
|   | 
| def CrossServerMsg_ChampionshipDailyOfficial(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ÐÅÏ¢ - Ã¿ÈÕ¹Ù¾ôÍæ¼ÒÐÅÏ¢  | 
|       | 
|     for playerID, officialID in msgData.items():  | 
|         if not PlayerControl.GetDBPlayerAccIDByID(playerID):  | 
|             # ·Ç±¾·þÍæ¼Ò  | 
|             continue  | 
|         ipyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", officialID)  | 
|         if not ipyData:  | 
|             continue  | 
|         awardItemList = ipyData.GetDailyAwardItemList()  | 
|         if not awardItemList:  | 
|             continue  | 
|         paramList = [officialID]  | 
|         PlayerCompensation.SendMailByKey("CrossChampionshipOfficialDaily", [playerID], awardItemList, paramList)  | 
|           | 
|     return  | 
|   | 
| def DoChampionshipOpen(curPlayer):  | 
|     NotifyPlayerChampionshipInfo(curPlayer, GameWorld.GetGameWorld().GetTick())  | 
|     return  | 
|   | 
| def OnPlayerLogin(curPlayer, tick):  | 
|       | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|         return  | 
|       | 
|     NotifyPlayerChampionshipInfo(curPlayer, tick)  | 
|     return  | 
|   | 
| def NotifyPlayerChampionshipInfo(curPlayer, tick):  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     champMgr = GetChampionshipMgr()  | 
|     pkZoneIDList = champMgr.GetChampPKZoneIDList()  | 
|     for zoneID in pkZoneIDList:  | 
|         Sync_ChampionshipPKZoneGroupInfo(zoneID, curPlayer=curPlayer)  | 
|     for zoneID in champMgr.GetChampOfficialZoneIDList():  | 
|         Sync_ChampionshipOfficialInfo(zoneID, curPlayer=curPlayer)  | 
|           | 
|     if pkZoneIDList:  | 
|         playerZoneID = champMgr.GetPlayerPKZoneID(playerID)  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(playerZoneID)  | 
|         if not pkZoneMgr:  | 
|             return  | 
|         if playerID not in pkZoneMgr.syncGuessPlayerIDInfo:  | 
|             sendMsg = {"zoneID":playerZoneID, "playerID":playerID, "exDataType":"ChampionshipGuessQuery"}  | 
|             CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipGuess, sendMsg)  | 
|         else:  | 
|             Sync_ChampionshipGuessPriInfo(curPlayer)  | 
|             Sync_ChampionshipGuessPubInfo(playerZoneID, curPlayer)  | 
|               | 
|     return  | 
|   | 
| def ChampionshipErrorDo():  | 
|     ## ×´Ì¬Òì³£ºó´¦Àí  | 
|       | 
|     stateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)  | 
|     if not stateError:  | 
|         return "state is not error."  | 
|       | 
|     if PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipErrorDo):  | 
|         return "already done."  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|       | 
|     # ·µ»¹Î´½áËãµÄ¾º²ÂÏûºÄ  | 
|     moneyType, _ = IpyGameDataPY.GetFuncEvalCfg("CrossChamGuess", 1)  | 
|     moneyItemID = ChConfig.MoneyItemIDDict.get(moneyType)  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|           | 
|         backGuessTypeList = []  | 
|         playerGuessMoneyInfo = {}  | 
|         for guessType, playerGuessDict in pkZoneMgr.guessInfo.items():  | 
|             for guessPlayerID, guessObjList in playerGuessDict.items():  | 
|                 for guessObj in guessObjList:  | 
|                     if guessObj.isClose:  | 
|                         # ÒѾ½áËãµÄ²»´¦Àí  | 
|                         continue  | 
|                     guessObj.isClose = 1  | 
|                     if guessType not in backGuessTypeList:  | 
|                         backGuessTypeList.append(guessType)  | 
|                     playerGuessMoneyInfo[guessPlayerID] = playerGuessMoneyInfo.get(guessPlayerID, 0) + guessObj.moneyTotal  | 
|                       | 
|         GameWorld.Log("¾º²ÂÐèÒª·µ»¹Íæ¼ÒÐÅÏ¢: moneyItemID=%s,zoneID=%s,backGuessTypeList=%s, %s" % (moneyItemID, zoneID, backGuessTypeList, playerGuessMoneyInfo))  | 
|         if not moneyItemID or not playerGuessMoneyInfo:  | 
|             continue  | 
|           | 
|         for guessPlayerID, totalMoney in playerGuessMoneyInfo.items():  | 
|             paramList = []  | 
|             addItemList = [[moneyItemID, totalMoney, 0]]  | 
|             PlayerCompensation.SendMailByKey("CrossChampionshipGuessBack", [guessPlayerID], addItemList, paramList, crossMail=True)  | 
|               | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipErrorDo, 1)  | 
|     return "OK"  | 
|   | 
| def OnMinuteProcess(curMinute):  | 
|     if not GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     Dispose_CrossChampionshipState()  | 
|       | 
|     # Ã¿°ëСʱ´æµµÒ»´Î  | 
|     if curMinute % 30 == 0:  | 
|         SaveChampionshipData()  | 
|     return  | 
|   | 
| def __GetChampionshipStartDate():  | 
|     ## »ñÈ¡ÅÅλÈü¿ªÊ¼ÈÕÆÚ  | 
|       | 
|     key = "ChampionshipStartDate"  | 
|     openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1  | 
|     loadSign = openServerDay  | 
|     ChampionshipStartDateInfo = IpyGameDataPY.GetConfigEx(key)  | 
|     if ChampionshipStartDateInfo and ChampionshipStartDateInfo[0] == loadSign:  | 
|         GameWorld.DebugLog("ÒѾ¼ÓÔØ¹ý±¾ÈÕ¿ç·þÅÅλÕù°ÔÈü¿ªÊ¼ÈÕÆÚ£¡loadSign=%s" % loadSign)  | 
|         return False, ChampionshipStartDateInfo[1]  | 
|       | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     count = ipyDataMgr.GetChampionshipTimeCount()  | 
|     if count < 2:  | 
|         return True, ""  | 
|       | 
|     firstIpyData = ipyDataMgr.GetChampionshipTimeByIndex(0)  | 
|     lastIpyData = ipyDataMgr.GetChampionshipTimeByIndex(count - 1)  | 
|     if not firstIpyData or not lastIpyData:  | 
|         return False, ""  | 
|     fristDay, firstHour, firstMinute = firstIpyData.GetStartDay(), firstIpyData.GetStartHour(), firstIpyData.GetStartMinute()  | 
|     lastDay, lastHour, lastMinute = lastIpyData.GetEndDay(), lastIpyData.GetEndHour(), lastIpyData.GetEndMinute()  | 
|     startSeconds = ((fristDay - 1) * 24 + firstHour) * 3600 + firstMinute * 60  | 
|     endSeconds = ((lastDay - 1) * 24 + lastHour) * 3600 + lastMinute * 60  | 
|       | 
|     curDateTime = GameWorld.GetServerTime()  | 
|     GameWorld.Log("===== ¼ÓÔØ½ñÌì¿ç·þÅÅλÕù°ÔÈüʱ¼ä =====")  | 
|     CrossChamDateList = IpyGameDataPY.GetFuncEvalCfg("CrossChamFB", 1)      | 
|     GameWorld.Log("¿ªÆôÈÕÆÚÁбí: %s" % CrossChamDateList)  | 
|     GameWorld.Log("fristDay=%s,firstHour=%s,firstMinute=%s,startSeconds=%s" % (fristDay, firstHour, firstMinute, startSeconds))  | 
|     GameWorld.Log("lastDay=%s,lastHour=%s,lastMinute=%s,endSeconds=%s" % (lastDay, lastHour, lastMinute, endSeconds))  | 
|       | 
|     nowStartDate = ""  | 
|     for startDate in CrossChamDateList:  | 
|         startDateTime0 = datetime.datetime.strptime(startDate, ChConfig.TYPE_Time_YmdFormat) # ¿ªÊ¼ÈÕÆÚ0µã  | 
|         startDateTime = startDateTime0 + datetime.timedelta(seconds=startSeconds)  | 
|         endDateTime = startDateTime0 + datetime.timedelta(seconds=endSeconds)  | 
|         if curDateTime >= startDateTime and curDateTime <= endDateTime:  | 
|             nowStartDate = startDate # È«²¿±éÀúÍ꣬ÒÔ×îеÄÂú×ãÌõ¼þʱ¼äΪ׼  | 
|               | 
|     GameWorld.Log("nowStartDate=%s" % nowStartDate)  | 
|       | 
|     ChampionshipStartDateInfo = IpyGameDataPY.SetConfigEx(key, [loadSign, nowStartDate])  | 
|     GameWorld.Log("¿ç·þÅÅλÕù°ÔÈü¿ªÊ¼ÈÕÆÚ¼ÓÔØÍê±Ï! loadSign=%s,nowStartDate=%s" % (loadSign, nowStartDate))  | 
|     GameWorld.Log("=============================================================")  | 
|     return True, ChampionshipStartDateInfo[1]  | 
|   | 
| def Dispose_CrossChampionshipState(reloadRefresh=False):  | 
|       | 
|     isReload, startDate = __GetChampionshipStartDate()  | 
|     isReload = isReload or reloadRefresh  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     # ´Ë»î¶¯Ñϸñ°´ÕÕÁ÷³Ì״̬һ¸ö¸öÀ´£¬²»ÄÜÌø£¬ËùÒÔʹÓÃdb±£´æ×´Ì¬£¬·ÀÖ¹ÁÙʱά»¤µ¼ÖÂ״̬Ϊ0  | 
|     befState = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState)  | 
|     dbCrossChampionshipID = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID)  | 
|     stateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)  | 
|       | 
|     updState = 0  | 
|     crossChampionshipID = dbCrossChampionshipID  | 
|       | 
|     # ÕâÀïʱ¼äÐ辫ȷµ½·ÖÖÓ£¬²»È»ºóÃæµÄ±È½Ï»áÆ¥Åä²»µ½  | 
|     curDateTime = GameWorld.GetServerTime()  | 
|     curDateTime = datetime.datetime.strptime("%d-%d-%d %d:%d:00" % (curDateTime.year, curDateTime.month, curDateTime.day,  | 
|                                                                     curDateTime.hour, curDateTime.minute), ChConfig.TYPE_Time_Format)  | 
|       | 
|     serverGroupIDList = [] # È«·þͳһÂß¼  | 
|     if startDate:  | 
|         crossChampionshipID = GameWorld.ChangeTimeStrToNum(startDate, ChConfig.TYPE_Time_YmdFormat)  | 
|         startDateTime0 = datetime.datetime.strptime(startDate, ChConfig.TYPE_Time_YmdFormat) # ¿ªÊ¼ÈÕÆÚ0µã  | 
|         ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|         for index in xrange(ipyDataMgr.GetChampionshipTimeCount()):  | 
|             timeIpyData = ipyDataMgr.GetChampionshipTimeByIndex(index)  | 
|             #dataID = timeIpyData.GetID()  | 
|             startDay, startHour, startMinute = timeIpyData.GetStartDay(), timeIpyData.GetStartHour(), timeIpyData.GetStartMinute()  | 
|             endDay, endHour, endMinute = timeIpyData.GetEndDay(), timeIpyData.GetEndHour(), timeIpyData.GetEndMinute()  | 
|               | 
|             startSeconds = ((startDay - 1) * 24 + startHour) * 3600 + startMinute * 60  | 
|             endSeconds = ((endDay - 1) * 24 + endHour) * 3600 + endMinute * 60  | 
|             startDateTime = startDateTime0 + datetime.timedelta(seconds=startSeconds)  | 
|             endDateTime = startDateTime0 + datetime.timedelta(seconds=endSeconds)  | 
|             if curDateTime < startDateTime or curDateTime > endDateTime:  | 
|                 continue  | 
|               | 
|             updState = timeIpyData.GetStateValue()  | 
|             notifyInfoDict = timeIpyData.GetNotifyInfo()  | 
|             if not stateError and notifyInfoDict:  | 
|                 diffDateTime = curDateTime - startDateTime  | 
|                 diffMinute = (diffDateTime.days * 24 * 3600 + diffDateTime.seconds) / 60 # µ±Ç°Ê±¼äÓ뿪ʼʱ¼äÏà²î·ÖÖÓÊý  | 
|                 GameWorld.DebugLog("    ¹ã²¥ÅжÏ: curDateTime=%s,startDateTime=%s,diffDays=%s,diffSeconds=%s,diffMinute=%s"   | 
|                                    % (curDateTime, startDateTime, diffDateTime.days, diffDateTime.seconds, diffMinute))  | 
|                 if diffMinute in notifyInfoDict:  | 
|                     notifyKey, paramList = notifyInfoDict[diffMinute]  | 
|                     PlayerControl.WorldNotifyCross(serverGroupIDList, 0, notifyKey, paramList)  | 
|             break  | 
|           | 
|     if not isReload and befState == updState:  | 
|         #ÒѾÊÇÕâ¸ö״̬ÁË  | 
|         return  | 
|       | 
|     GameWorld.Log("¿ç·þÅÅλÕù°ÔÈü״̬±ä¸ü: befState=%s,updState=%s,stateError=%s" % (befState, updState, stateError))  | 
|       | 
|     # ÅÐ¶Ï»î¶¯ÖØÖ㬸ûֻ¿¼ÂÇÕý³£Á÷³Ì״̬£¬ÈκÎÁ÷³ÌÌø¹ýµÄ¶¼²»´¦Àí£»Òì³£Çé¿öά»¤·þÎñÆ÷µ¼ÖÂÌø¹ýÁ÷³ÌµÄ¿ÉÅäÖÃÐÂÈÕÆÚ¿ªÊ¼Ð»£¬²¢×ö²¹³¥  | 
|     GameWorld.Log("crossChampionshipID=%s,dbCrossChampionshipID=%s" % (crossChampionshipID, dbCrossChampionshipID))  | 
|     gameWorld.SetDict(PlayerDBGSEvent.Def_CrossChampionshipState, updState)  | 
|     gameWorld.SetDict(PlayerDBGSEvent.Def_CrossChampionshipID, crossChampionshipID)  | 
|       | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID, crossChampionshipID)  | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState, updState)  | 
|       | 
|     isNewStart = False  | 
|     if crossChampionshipID != dbCrossChampionshipID:              | 
|         # Ð» - ±ØÐë´ÓµÚÒ»¸ö״̬¿ªÊ¼²ÅËã  | 
|         if crossChampionshipID:  | 
|             if updState == ShareDefine.CrossChampionshipStateList[0]:  | 
|                 isNewStart = True  | 
|                 DoCrossChampionshipStart(crossChampionshipID, updState)  | 
|             else:  | 
|                 GameWorld.ErrLog("¿ç·þÅÅλÕù°ÔÈüÖØÖûʱ·ÇÊ׸ö״̬£¬Òì³£²»´¦Àí: crossChampionshipID=%s,dbCrossChampionshipID=%s,updState=%s"   | 
|                                  % (crossChampionshipID, dbCrossChampionshipID, updState))  | 
|                 PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError, 1)  | 
|                   | 
|     # ·Ç¿ªÆôÐÂÅÅλ»î¶¯µÄ£¬ÓÅÏÈͳһ¹ã²¥×Ó·þ״̬£¬ÔÙ×öºóÐø´¦Àí  | 
|     if not isNewStart:  | 
|         Send_CrossServerMsg_ChampionshipState()  | 
|           | 
|     if isNewStart:  | 
|         pass  | 
|     elif not crossChampionshipID:  | 
|         GameWorld.Log("¿ç·þÅÅλÕù°ÔÈü·Ç»î¶¯ÖУ¬²»´¦Àí!")  | 
|     elif stateError:  | 
|         GameWorld.ErrLog("¿ç·þÅÅλÕù°ÔÈü»î¶¯×´Ì¬ÒѾÒì³££¬²»´¦Àí!")  | 
|     elif crossChampionshipID == dbCrossChampionshipID:  | 
|         if befState == updState:  | 
|             GameWorld.Log("¿ç·þÅÅλÕù°ÔÈü״̬²»±ä²»´¦Àí: befState=%s,updState=%s" % (befState, updState))  | 
|               | 
|         elif befState and befState in ShareDefine.CrossChampionshipStateList \  | 
|             and updState and updState in ShareDefine.CrossChampionshipStateList:  | 
|             befStateIndex = ShareDefine.CrossChampionshipStateList.index(befState)  | 
|             updStateIndex = ShareDefine.CrossChampionshipStateList.index(updState)  | 
|             # ¸Ã»î¶¯±ØÐ밴״̬Á÷³ÌÒ»¸ö¸öÀ´£¬´æDBµÄÈ·±£Ã¿¸ö״ֵ̬Âß¼´¦ÀíÖ»»á´¥·¢Ò»´Î  | 
|             if befStateIndex + 1 == updStateIndex:  | 
|                 if updState == ShareDefine.CrossChampionshipState_Group64:  | 
|                     DoCrossChampionshipGroupRand(64)  | 
|                 elif updState == ShareDefine.CrossChampionshipState_Group32:  | 
|                     DoCrossChampionshipGroupRand(32)  | 
|                 elif updState == ShareDefine.CrossChampionshipState_Group16:  | 
|                     DoCrossChampionshipGroupRand(16)  | 
|                 elif updState == ShareDefine.CrossChampionshipState_Guess4:  | 
|                     DoCrossChampionshipTopPlayer8()  | 
|                 elif updState == ShareDefine.CrossChampionshipState_Group8:  | 
|                     DoCrossChampionshipGroupRand(8)  | 
|                 elif updState == ShareDefine.CrossChampionshipState_GroupSemi:  | 
|                     DoCrossChampionshipGroupByWF(4)  | 
|                 elif updState == ShareDefine.CrossChampionshipState_GroupFinal:  | 
|                     DoCrossChampionshipGroupByWF(2)  | 
|                 # ´¦Àí½ø³¡×´Ì¬  | 
|                 elif updState in ShareDefine.CrossChampionshipEnterStateInfo:  | 
|                     DoCrossChampionshipStartEnter(updState)  | 
|             else:  | 
|                 GameWorld.ErrLog("¿ç·þÅÅλÕù°ÔÈü״̬Á÷³ÌÒì³£: befState=%s,updState=%s,befStateIndex=%s,updStateIndex=%s"   | 
|                                  % (befState, updState, befStateIndex, updStateIndex))  | 
|                 PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError, 1)  | 
|                 Send_CrossServerMsg_ChampionshipState()  | 
|           | 
|         # ´Ó×îºóÒ»¸ö״̬µ½0£¬´ú±íÕû¸öÁ÷³Ì½áÊø£¬ÐèÒª´¦ÀíϽáËã  | 
|         elif befState == ShareDefine.CrossChampionshipStateList[-1] and not updState:  | 
|             DoCrossChampionshipFinalOver()  | 
|               | 
|         else:  | 
|             GameWorld.ErrLog("¿ç·þÅÅλÕù°ÔÈü״̬Òì³£: updState=%s" % updState)  | 
|             PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError, 1)  | 
|             Send_CrossServerMsg_ChampionshipState()  | 
|               | 
|     return  | 
|   | 
| def DoCrossChampionshipStart(crossChampionshipID, updState):  | 
|     ## Ð»¿ªÊ¼  | 
|     GameWorld.Log("=== ¿ç·þÅÅλÕù°ÔÈüл¿ªÊ¼ ===")  | 
|     GameWorld.Log("crossChampionshipID=%s,updState=%s" % (crossChampionshipID, updState))  | 
|       | 
|     hisZoneIDList = [] # ÒòΪ·ÖÇø¿ÉÄܵ÷ÕûÔöɾ£¬ÕâÀïҪȡÀúÊ·ÅäÖùýµÄËùÓзÖÇø  | 
|     championshipSeason = 0 # ÅÅλÈüÊý¾ÝÈ¡·Ç»î¶¯ÖеÄ×î¸ßÈü¼¾  | 
|     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()  | 
|         if zoneID not in hisZoneIDList:  | 
|             hisZoneIDList.append(zoneID)  | 
|               | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     for zoneID in hisZoneIDList:  | 
|         seasonID = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonID % zoneID)  | 
|         seasonState = gameWorld.GetDictByKey(ChConfig.Def_WorldKey_CrossPKZoneSeasonState % zoneID)  | 
|         if seasonState == 1:  | 
|             checkSeason = seasonID - 1 # Èü¼¾ÖеÄÈ¡ÉÏÒ»¸öÈü¼¾  | 
|         else:  | 
|             checkSeason = seasonID  | 
|         if championshipSeason < checkSeason:  | 
|             championshipSeason = checkSeason  | 
|     GameWorld.Log("hisZoneIDList=%s,championshipSeason=%s" % (hisZoneIDList, championshipSeason))  | 
|       | 
|     # Çå¿ÕÉϴλ¼Ç¼  | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipGroup)  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipGuess)  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipOfficial)  | 
|     universalRecMgr.Delete(Def_RecType_CrossChampionshipOffChallenge)  | 
|       | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID, crossChampionshipID)  | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState, updState)  | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError, 0)  | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipErrorDo, 0)  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     champMgr.ClearPKZone() # ½öÇåÀíPK·ÖÇøÐÅÏ¢£¬ÏɹÙÐÅÏ¢²»±ä  | 
|       | 
|     # Éú³É²ÎÈüÍæ¼ÒÃûµ¥: È¡¿ç·þPKËùÓзÖÇø championshipSeason Èü¼¾µÄÊý¾Ý  | 
|     if championshipSeason:  | 
|         crossPKBillboardMgr = PyDataManager.GetCrossPKBillboardManager()  | 
|         for zoneID in hisZoneIDList:  | 
|             billboardList = crossPKBillboardMgr.GetCrossPKBillboardInfo(zoneID, championshipSeason)[0]  | 
|             GameWorld.Log("zoneID=%s,billboardListLen=%s" % (zoneID, len(billboardList)))  | 
|             if not billboardList:  | 
|                 # Ã»ÓÐÍæ¼ÒÉϰñµÄ²»´¦Àí  | 
|                 continue  | 
|             pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|             battlePlayerList = billboardList[:Def_CrossChampionshipPlayerMax]  | 
|             for num, billboardData in enumerate(battlePlayerList, 1):  | 
|                 playerID = billboardData.PlayerID  | 
|                 batPlayer = ChampionshipBatPlayer()  | 
|                 batPlayer.zoneID = zoneID  | 
|                 batPlayer.playerID = playerID  | 
|                 batPlayer.playerName = billboardData.PlayerName  | 
|                 batPlayer.job = billboardData.Job  | 
|                 batPlayer.fightPower = billboardData.FightPower  | 
|                 batPlayer.realmLV = billboardData.RealmLV  | 
|                 pkZoneMgr.playerDict[playerID] = batPlayer  | 
|                   | 
|                 getPlayer = pkZoneMgr.GetBatPlayer(playerID)  | 
|                 dataDict = {"zoneID":zoneID, "playerID":playerID, "accID":getPlayer.accID, "fightPower":getPlayer.fightPower}  | 
|                 DR_CrossChampionshipPK("StartPlayer", dataDict)  | 
|                   | 
|                 GameWorld.Log("    AddBattlePlayer num=%s,playerID=%s,accID=%s,fightPower=%s" % (num, playerID, getPlayer.accID, getPlayer.fightPower))  | 
|                   | 
|     GameWorld.Log("=============================================================")  | 
|     Send_CrossServerMsg_ChampionshipState(newAct=True)  | 
|     Send_CrossServerMsg_ChampionshipPlayer(isSync=True)  | 
|     return  | 
|   | 
| def DoCrossChampionshipGroupRand(groupMark):  | 
|     ## Ëæ»úÁ½Á½·Ö×é  | 
|       | 
|     battleCount = int(groupMark / 2) # ¶ÔÕ½×éÊý  | 
|     preGroupMark = 0 if groupMark == 64 else groupMark * 2 # ÉÏÒ»ÂÖ·Ö×é±êʶ  | 
|       | 
|     GameWorld.Log("=== ¿ç·þÅÅλÕù°ÔÈüËæ»ú·Ö×é === groupMark=%s,battleCount=%s,preGroupMark=%s" % (groupMark, battleCount, preGroupMark))  | 
|       | 
|     syncPlayerIDList = []  | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         # Ê×ÂÖÈ¡ËùÓвÎÈüÍæ¼Ò  | 
|         if preGroupMark == 0:  | 
|             batPlayerIDList = pkZoneMgr.GetBatPlayerIDList()  | 
|         # È¡ÉÏÒ»ÂÖ»ñʤÕß  | 
|         else:  | 
|             batPlayerIDList = []  | 
|             battleNumList = pkZoneMgr.battleInfo.get(preGroupMark, {}).keys()  | 
|             for battleNum in battleNumList:  | 
|                 batObj = pkZoneMgr.GetBattle(preGroupMark, battleNum)  | 
|                 if not batObj:  | 
|                     continue  | 
|                 # Èç¹ûÉÏÒ»ÂÖÕ½¶·Ã»½áË㣬ÔòÇ¿ÖÆ½áËã  | 
|                 if not batObj.overTime:  | 
|                     GameWorld.ErrLog("ÉÏÒ»ÂÖÕ½¶·Î´½áË㣬ִÐÐÇ¿ÖÆ½áËã! zoneID=%s,preGroupMark=%s,battleNum=%s,mapID=%s,copyMapID=%s"   | 
|                                      % (zoneID, preGroupMark, battleNum, batObj.mapID, batObj.copyMapID), batObj.roomID)  | 
|                     DoBattleOverLogic(zoneID, preGroupMark, battleNum)  | 
|                       | 
|                 if not batObj.winPlayerID:  | 
|                     continue  | 
|                 if batObj.winPlayerID not in batPlayerIDList:  | 
|                     batPlayerIDList.append(batObj.winPlayerID)  | 
|                       | 
|         # ½øÈë¾öÈüµÄËæ»ú·Ö×é£¬Íæ¼Ò²»×ãµÄ²¹0£¬È·±£·Ö×éºó˳ÐòÒ»Ö  | 
|         if groupMark == 8 and len(batPlayerIDList) < Def_CrossChampionshipPlayerWFCount:  | 
|             batPlayerIDList += [0] * (Def_CrossChampionshipPlayerWFCount - len(batPlayerIDList))  | 
|         batPlayerCount = len(batPlayerIDList)  | 
|         GameWorld.Log("zoneID=%s,batPlayerCount=%s" % (zoneID, batPlayerCount), zoneID)  | 
|         if not batPlayerIDList:  | 
|             continue  | 
|           | 
|         # ´òÂÒ˳Ðò  | 
|         random.shuffle(batPlayerIDList)  | 
|         GameWorld.Log("batPlayerIDList=%s" % batPlayerIDList)  | 
|           | 
|         battleDict = {}  | 
|         for num, playerID in enumerate(batPlayerIDList, 1):  | 
|             if playerID and playerID not in syncPlayerIDList:  | 
|                 syncPlayerIDList.append(playerID)  | 
|             #batPlayer = zoneMgr.GetBatPlayer(playerID)  | 
|             # 1.ÏÈÈ·±£Ã¿×éÓÐÈË  | 
|             if num <= battleCount:  | 
|                 battle = ChampionshipBattle()  | 
|                 battle.zoneID = zoneID  | 
|                 battle.groupMark = groupMark  | 
|                 battle.battleNum = num  | 
|                 battle.playerIDA = playerID  | 
|                   | 
|                 battleDict[num] = battle  | 
|                 pkZoneMgr.battleInfo[groupMark] = battleDict  | 
|                   | 
|             else:  | 
|                 battle = pkZoneMgr.GetBattle(groupMark, num - battleCount)  | 
|                 # Ò»°ã²»¿ÉÄÜΪNone£¬·ÀһϠ | 
|                 if not battle:  | 
|                     continue  | 
|                 battle.playerIDB = playerID  | 
|                   | 
|         for battleNum in range(1, 1 + battleCount):  | 
|             batObj = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|             playerIDA = batObj.playerIDA  | 
|             playerIDB = batObj.playerIDB  | 
|             playerObjA = pkZoneMgr.GetBatPlayer(playerIDA)  | 
|             playerObjB = pkZoneMgr.GetBatPlayer(playerIDB)  | 
|             accIDA = "" if not playerObjA else playerObjA.accID  | 
|             accIDB = "" if not playerObjB else playerObjB.accID  | 
|             fightPowerA = 0 if not playerObjA else playerObjA.fightPower  | 
|             fightPowerB = 0 if not playerObjB else playerObjB.fightPower  | 
|             GameWorld.Log("    ¶ÔÕ½×éÐÅÏ¢: zoneID=%s,groupMark=%s,battleNum=%s,playerIDA=%s(%s),playerIDB=%s(%s),fightPowerA=%s,fightPowerB=%s"   | 
|                           % (zoneID, batObj.groupMark, batObj.battleNum, playerIDA, accIDA, playerIDB, accIDB, fightPowerA, fightPowerB), zoneID)  | 
|               | 
|             dataDict = {"zoneID":zoneID, "groupMark":groupMark, "battleNum":battleNum,   | 
|                         "playerIDA":playerIDA, "accIDA":accIDA, "fightPowerA":fightPowerA,  | 
|                         "playerIDB":playerIDB, "accIDB":accIDB, "fightPowerB":fightPowerB,  | 
|                         }  | 
|             DR_CrossChampionshipPK("Group", dataDict)  | 
|     GameWorld.Log("=============================================================")  | 
|       | 
|     # ¹ã²¥×Ó·þ  | 
|     Send_CrossServerMsg_ChampionshipPlayer(syncPlayerIDList)  | 
|     Send_CrossServerMsg_ChampionshipGroup(groupMark)  | 
|     return  | 
|   | 
| def DoCrossChampionshipGroupByWF(groupMark):  | 
|     ## °´Ê¤¸º×é·Ö×飬ÓÉÉÏÒ»ÂÖµÄʤ¸º·Ö×鼰˳Ðò¾ö¶¨±¾ÂִεķÖ×飬ÐèҪȷ±£Ë³ÐòÒ»Ö  | 
|       | 
|     if groupMark == 4:  | 
|         preGroupMark = 8  | 
|     elif groupMark == 2:  | 
|         preGroupMark = 4  | 
|     else:  | 
|         return  | 
|     battleCount = int(Def_CrossChampionshipPlayerWFCount / 2) # ¶ÔÕ½×éÊý£¬Ò²ÊÇʤ¸º×éÿ×éËùÐèÈËÊý  | 
|     GameWorld.Log("=== ¿ç·þÅÅλÕù°ÔÈüʤ¸º·Ö×é === groupMark=%s,battleCount=%s,preGroupMark=%s" % (groupMark, battleCount, preGroupMark))  | 
|       | 
|     syncPlayerIDList = []  | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         winPlayerIDList, losePlayerIDList = [], [] # Ê¤Õß×é¡¢°ÜÕß×é  | 
|         battleNumList = pkZoneMgr.battleInfo.get(preGroupMark, {}).keys()  | 
|         battleNumList.sort() # ¶ÔÕ½±àºÅ°´Ö®Ç°µÄ·Ö×é˳ÐòÅÅÐò£¬È·±£·Ö×é˳ÐòÒ»Ö  | 
|         for battleNum in battleNumList:  | 
|             batObj = pkZoneMgr.GetBattle(preGroupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|               | 
|             # Èç¹ûÉÏÒ»ÂÖÕ½¶·Ã»½áË㣬ÔòÇ¿ÖÆ½áËã  | 
|             if not batObj.overTime:  | 
|                 GameWorld.ErrLog("ÉÏÒ»ÂÖÕ½¶·Î´½áË㣬ִÐÐÇ¿ÖÆ½áËã! zoneID=%s,preGroupMark=%s,battleNum=%s,mapID=%s,copyMapID=%s"   | 
|                                  % (zoneID, preGroupMark, battleNum, batObj.mapID, batObj.copyMapID), batObj.roomID)  | 
|                 DoBattleOverLogic(zoneID, preGroupMark, battleNum)  | 
|                   | 
|             # ÎªÈ·±£¶àÂִζÔս˳ÐòÒ»Ö£¬µ±ÎÞʤÀûÍæ¼Òʱ£¨Ò»°ãÊÇûÓÐÍæ¼Ò»ò½áËãÒì³£µ¼ÖÂûÓÐʤÕߣ¬Ò»Âɵ±×öÎÞÍæ¼Ò´¦Àí£©£¬ÎÞÍæ¼ÒÐèÒª²¹0£¬È·±£ºóÐøÆ¥Åä·Ö×é˳ÐòÒ»Ö  | 
|             if not batObj.winPlayerID:  | 
|                 winPlayerIDList.append(0)  | 
|                 losePlayerIDList.append(0)  | 
|             else:  | 
|                 winPlayerID = batObj.playerIDA if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDB  | 
|                 losePlayerID = batObj.playerIDB if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDA  | 
|                 winPlayerIDList.append(winPlayerID)  | 
|                 losePlayerIDList.append(losePlayerID)  | 
|                   | 
|         if len(winPlayerIDList) < battleCount:  | 
|             winPlayerIDList += [0] * (battleCount - len(winPlayerIDList))  | 
|         winPlayerIDList = winPlayerIDList[:battleCount]  | 
|         if len(losePlayerIDList) < battleCount:  | 
|             losePlayerIDList += [0] * (battleCount - len(losePlayerIDList))  | 
|         losePlayerIDList = losePlayerIDList[:battleCount]  | 
|         GameWorld.Log("zoneID=%s,groupMark=%s,winPlayerIDList=%s,losePlayerIDList=%s"   | 
|                       % (zoneID, groupMark, winPlayerIDList, losePlayerIDList), zoneID)  | 
|           | 
|         battleNum = 0  | 
|         battleDict = {}  | 
|         batPlayerIDList = winPlayerIDList + losePlayerIDList  | 
|         for i in range(Def_CrossChampionshipPlayerWFCount)[::2]:  | 
|             playerIDA = batPlayerIDList[i]  | 
|             playerIDB = batPlayerIDList[i + 1]  | 
|             battleNum += 1  | 
|             battle = ChampionshipBattle()  | 
|             battle.zoneID = zoneID  | 
|             battle.groupMark = groupMark  | 
|             battle.battleNum = battleNum  | 
|             battle.playerIDA = playerIDA  | 
|             battle.playerIDB = playerIDB  | 
|               | 
|             battleDict[battleNum] = battle  | 
|             pkZoneMgr.battleInfo[groupMark] = battleDict  | 
|               | 
|             if playerIDA and playerIDA not in syncPlayerIDList:  | 
|                 syncPlayerIDList.append(playerIDA)  | 
|             if playerIDB and playerIDB not in syncPlayerIDList:  | 
|                 syncPlayerIDList.append(playerIDB)  | 
|                   | 
|             playerObjA = pkZoneMgr.GetBatPlayer(playerIDA)  | 
|             playerObjB = pkZoneMgr.GetBatPlayer(playerIDB)  | 
|             accIDA = "" if not playerObjA else playerObjA.accID  | 
|             accIDB = "" if not playerObjB else playerObjB.accID  | 
|             fightPowerA = 0 if not playerObjA else playerObjA.fightPower  | 
|             fightPowerB = 0 if not playerObjB else playerObjB.fightPower  | 
|             GameWorld.Log("    ¶ÔÕ½×éÐÅÏ¢: zoneID=%s,groupMark=%s,battleNum=%s,playerIDA=%s(%s),playerIDB=%s(%s),fightPowerA=%s,fightPowerB=%s"   | 
|                           % (zoneID, groupMark, battleNum, playerIDA, accIDA, playerIDB, accIDB, fightPowerA, fightPowerB), zoneID)  | 
|               | 
|             dataDict = {"zoneID":zoneID, "groupMark":groupMark, "battleNum":battleNum,   | 
|                         "playerIDA":playerIDA, "accIDA":accIDA, "fightPowerA":fightPowerA,  | 
|                         "playerIDB":playerIDB, "accIDB":accIDB, "fightPowerB":fightPowerB,  | 
|                         }  | 
|             DR_CrossChampionshipPK("Group", dataDict)  | 
|               | 
|     GameWorld.Log("=============================================================")  | 
|       | 
|     # ¹ã²¥×Ó·þ  | 
|     Send_CrossServerMsg_ChampionshipPlayer(syncPlayerIDList)  | 
|     Send_CrossServerMsg_ChampionshipGroup(groupMark)  | 
|     return  | 
|   | 
| def DoCrossChampionshipTopPlayer8():  | 
|     ## ²ú³öǰ8Ç¿  | 
|       | 
|     preGroupMark = 16  | 
|     GameWorld.Log("=== ¿ç·þÅÅλÕù°ÔÈü²ú³öǰ8Ç¿  === preGroupMark=%s" % preGroupMark)  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         battleNumList = pkZoneMgr.battleInfo.get(preGroupMark, {}).keys()  | 
|         battleNumList.sort() # ¶ÔÕ½±àºÅ°´Ö®Ç°µÄ·Ö×é˳ÐòÅÅÐò£¬È·±£·Ö×é˳ÐòÒ»Ö  | 
|         for battleNum in battleNumList:  | 
|             batObj = pkZoneMgr.GetBattle(preGroupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|               | 
|             # Èç¹ûÉÏÒ»ÂÖÕ½¶·Ã»½áË㣬ÔòÇ¿ÖÆ½áËã  | 
|             if not batObj.overTime:  | 
|                 GameWorld.ErrLog("ÉÏÒ»ÂÖÕ½¶·Î´½áË㣬ִÐÐÇ¿ÖÆ½áËã! zoneID=%s,preGroupMark=%s,battleNum=%s,mapID=%s,copyMapID=%s"   | 
|                                  % (zoneID, preGroupMark, battleNum, batObj.mapID, batObj.copyMapID), batObj.roomID)  | 
|                 DoBattleOverLogic(zoneID, preGroupMark, battleNum)  | 
|                   | 
|         top8PlayerIDList = pkZoneMgr.GetTop8PlayerIDList()  | 
|         GameWorld.Log("ÅÅλ·ÖÇø8Ç¿Íæ¼ÒIDÁбí: zoneID=%s, %s" % (zoneID, top8PlayerIDList), zoneID)  | 
|           | 
|         # ´¦Àí8Ç¿¾º²Â·¢½±Àø  | 
|         guessType = 8  | 
|         moneyType = ShareDefine.TYPE_Price_GongdePoint  | 
|         multiPrice = IpyGameDataPY.GetFuncCfg("CrossChamGuess", 3) # ²ÂÖн±Àø±¶Öµ  | 
|         moneyItemID = ChConfig.MoneyItemIDDict.get(moneyType)  | 
|         GameWorld.Log("¾º²Â·µÀû»õ±ÒÀàÐÍ: moneyType=%s,moneyItemID=%s,multiPrice=%s" % (moneyType, moneyItemID, multiPrice), zoneID)  | 
|         playerGuessDict = pkZoneMgr.guessInfo.get(guessType, {})  | 
|         for guessPlayerID, guessList in playerGuessDict.items():  | 
|             guessCorrectCount = 0 # ²ÂÖÐÈËÊý  | 
|             guessCorrectMoney = 0 # ²ÂÖÐ×ÜͶÈë»õ±Ò  | 
|             for guessObj in guessList:  | 
|                 if guessObj.guessType != guessType or guessObj.guessPlayerID != guessPlayerID:  | 
|                     continue  | 
|                 guessObj.isClose = 1  | 
|                 tagPlayerID = guessObj.tagPlayerID  | 
|                 moneyTotal = guessObj.moneyTotal  | 
|                 if not tagPlayerID or tagPlayerID not in top8PlayerIDList:  | 
|                     continue  | 
|                 guessCorrectCount += 1  | 
|                 guessCorrectMoney += moneyTotal  | 
|                   | 
|             if guessCorrectMoney <= 0 or multiPrice <= 0 or not moneyItemID:  | 
|                 continue  | 
|             moneyPriceTotal = guessCorrectMoney * multiPrice # ×ÜÊÕÒæ  | 
|             paramList = [guessCorrectCount, multiPrice]  | 
|             addItemList = [[moneyItemID, moneyPriceTotal, 0]]  | 
|             PlayerCompensation.SendMailByKey("CrossChampionshipGuess8", [guessPlayerID], addItemList, paramList, crossMail=True)  | 
|               | 
|     GameWorld.Log("=============================================================")  | 
|     return  | 
|   | 
| def DoCrossChampionshipStartEnter(state):  | 
|     ## ¿ªÆô½ø³¡´¦ÀíÂß¼  | 
|     if state not in ShareDefine.CrossChampionshipEnterStateInfo:  | 
|         return  | 
|     groupMark = ShareDefine.CrossChampionshipEnterStateInfo[state]  | 
|     mapIndex = 0  | 
|     mapIDList = IpyGameDataPY.GetFuncEvalCfg("CrossChamFB", 3)  | 
|     GameWorld.Log("¿ç·þÅÅλÕù°ÔÈü¿ªÆô½ø³¡¸±±¾: groupMark=%s,mapIDList=%s" % (groupMark, mapIDList))  | 
|     champMgr = GetChampionshipMgr()  | 
|     pkZoneIDList = champMgr.GetChampPKZoneIDList()  | 
|     for zoneID in pkZoneIDList:  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         if groupMark not in pkZoneMgr.battleInfo:  | 
|             GameWorld.Log("¸Ã¿ç·þÅÅλÕù°ÔÈü·ÖÇøÃ»ÓжÔÕ½×é! zoneID=%s,groupMark=%s" % (zoneID, groupMark), zoneID)  | 
|             continue  | 
|         if mapIndex >= len(mapIDList):  | 
|             GameWorld.ErrLog("¸Ã¿ç·þÅÅλÕù°ÔÈü·ÖÇøÃ»ÓзÖÅä¶ÔÕ½µØÍ¼! zoneID=%s,mapIndex=%s" % (zoneID, mapIndex), zoneID)  | 
|             continue  | 
|         mapID = mapIDList[mapIndex]  | 
|         mapIndex += 1  | 
|         copyMapID = 0  | 
|         copyPropertyList = []  | 
|         battleDict = pkZoneMgr.battleInfo[groupMark]  | 
|         for battleNum in battleDict.keys():  | 
|             batObj = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|             roomID = GetChampionshipPKRoomID(zoneID, groupMark, battleNum)  | 
|             copyPropertyList.append([copyMapID, roomID])  | 
|             batObj.mapID = mapID  | 
|             batObj.roomID = roomID  | 
|             batObj.copyMapID = copyMapID  | 
|               | 
|             # Ìí¼Ó¿ªÆô·ÖÏßÊý¾Ý  | 
|             realMapID = mapID  | 
|             copyMapObj = PlayerFB.CrossCopyMapInfo(zoneID, 0)  | 
|             copyMapObj.realMapID = realMapID  | 
|             copyMapObj.copyMapID = copyMapID  | 
|             key = (realMapID, copyMapID)  | 
|             PyGameData.g_crossDynamicLineCopyMapInfo[key] = copyMapObj  | 
|             GameWorld.Log("    ¶ÔÕ½·¿¼ä! zoneID=%s,groupMark=%s,battleNum=%s,playerIDA=%s,playerIDB=%s,roomID=%s,mapID=%s,copyMapID=%s"   | 
|                           % (zoneID, groupMark, battleNum, batObj.playerIDA, batObj.playerIDB, roomID, mapID, copyMapID))  | 
|             copyMapID += 1  | 
|               | 
|         PlayerFB.SendMapOpenFBEx(mapID, copyPropertyList)  | 
|           | 
|     return  | 
|   | 
| def Sync_CrossChampionshipDataToClientServer(serverGroupID=0):  | 
|     ''' Í¬²½¿ç·þÅÅλÕù°ÔÈüÊý¾Ýµ½×Ó·þÎñÆ÷  | 
|     @param serverGroupID: Îª0ʱͬ²½ËùÓÐ×Ó·þ  | 
|     '''  | 
|     GameWorld.Log("ͬ²½¸ø×Ó·þÅÅλÕù°ÔÈüÊý¾Ý: syncServerGroupID=%s" % (serverGroupID))  | 
|     # Í¨ÖªÈ«Çø  | 
|     Send_CrossServerMsg_ChampionshipState(serverGroupID)  | 
|     Send_CrossServerMsg_ChampionshipPlayer(serverGroupID=serverGroupID)  | 
|     Send_CrossServerMsg_ChampionshipGroup(serverGroupID=serverGroupID)  | 
|     Send_CrossServerMsg_ChampionshipGuess(serverGroupID=serverGroupID)  | 
|     Send_CrossServerMsg_ChampionshipOfficial(serverGroupID=serverGroupID)  | 
|     return  | 
|   | 
| def Send_CrossServerMsg_ChampionshipState(serverGroupID=0, newAct=False):  | 
|     # Í¨Öª×´Ì¬   | 
|     champMgr = GetChampionshipMgr()  | 
|     pkZoneIDList = champMgr.GetChampPKZoneIDList()  | 
|     ID = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID)  | 
|     State = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState)  | 
|     StateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)  | 
|     dataMsg = {"ID":ID, "State":State, "StateError":StateError, "PKZoneIDList":pkZoneIDList, "NewAct":newAct}  | 
|     serverGroupIDList = [serverGroupID] if serverGroupID else []  | 
|     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ChampionshipState, dataMsg, serverGroupIDList)  | 
|     return  | 
|   | 
| def Send_CrossServerMsg_ChampionshipPlayer(syncPlayerIDList=None, serverGroupID=0, isSync=False, clearPlayer=False):  | 
|     # Í¨Öª²ÎÈüÍæ¼Ò  | 
|       | 
|     zoneBatPlayerInfo = {}  | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         batPlayerList = []  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         playerIDList = pkZoneMgr.GetBatPlayerIDList() if syncPlayerIDList == None else syncPlayerIDList  | 
|         for playerID in playerIDList:  | 
|             batPlayer = pkZoneMgr.GetBatPlayer(playerID)  | 
|             if not batPlayer:  | 
|                 continue  | 
|             batPlayerList.append(batPlayer.GetString())  | 
|         zoneBatPlayerInfo[zoneID] = batPlayerList  | 
|           | 
|     dataMsg = {"isSync":isSync, "zoneBatPlayerInfo":zoneBatPlayerInfo, "clearPlayer":clearPlayer}  | 
|     serverGroupIDList = [serverGroupID] if serverGroupID else []  | 
|     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ChampionshipPlayer, dataMsg, serverGroupIDList)  | 
|     return  | 
|   | 
| def Send_CrossServerMsg_ChampionshipGroup(groupMark=None, battleObj=None, serverGroupID=0):  | 
|     # Í¨Öª·Ö×é  | 
|     dataMsg = []  | 
|     if battleObj != None:  | 
|         dataMsg.append(battleObj.GetString())  | 
|     else:  | 
|         syncGroupMarkList = [groupMark] if groupMark != None else ShareDefine.CrossChampionshipEnterStateInfo.values()  | 
|         champMgr = GetChampionshipMgr()  | 
|         for zoneID in champMgr.GetChampPKZoneIDList():  | 
|             pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|             if not pkZoneMgr:  | 
|                 continue  | 
|             for gMark in syncGroupMarkList:  | 
|                 battleDict = pkZoneMgr.battleInfo.get(gMark, {})  | 
|                 if not battleDict:  | 
|                     continue  | 
|                 for num in battleDict.keys():  | 
|                     battleObj = pkZoneMgr.GetBattle(gMark, num)  | 
|                     dataMsg.append(battleObj.GetString())  | 
|                       | 
|     serverGroupIDList = [serverGroupID] if serverGroupID else []  | 
|     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ChampionshipGroup, dataMsg, serverGroupIDList)  | 
|     return  | 
|   | 
| def Send_CrossServerMsg_ChampionshipGuess(syncZoneID=None, playerID=0, guessObj=None, serverGroupID=0, exData=None, syncPub=True):  | 
|     ## Í¨Öª¾º²Â  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|       | 
|     # ÒòΪ¾º²ÂÊÇÃæÏòÈ«·þµÄÍæ¼Ò£¬ËùÒÔÖ»ÄÜÕë¶Ôÿ¸öÍæ¼Òµ¥¶Àͬ²½×Ô¼º²ÎÓë¹ýµÄ¾º²Â  | 
|     guessList = []  | 
|     if syncZoneID and playerID:  | 
|         if guessObj != None and guessObj.guessPlayerID == playerID:  | 
|             guessList.append(guessObj.GetString())  | 
|         else:  | 
|             pkZoneMgr = champMgr.GetChampPKZoneMgr(syncZoneID)  | 
|             if pkZoneMgr:  | 
|                 for playerGuessDict in pkZoneMgr.guessInfo.values():  | 
|                     if playerID not in playerGuessDict:  | 
|                         continue  | 
|                     playerGuessList = playerGuessDict[playerID]  | 
|                     for guess in playerGuessList:  | 
|                         guessList.append(guess.GetString())  | 
|                       | 
|     dataMsg = {"exData":exData if exData else {}, "guessList":guessList}  | 
|     if syncPub:  | 
|         zoneSupportCountInfo = {}  | 
|         syncZoneIDList = [syncZoneID] if syncZoneID else champMgr.GetChampPKZoneIDList()  | 
|         for zoneID in syncZoneIDList:  | 
|             pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|             if not pkZoneMgr:  | 
|                 continue  | 
|             zoneSupportCountInfo[zoneID] = pkZoneMgr.supportCountInfo  | 
|         dataMsg["pubInfo"] = {"zoneSupportCountInfo":zoneSupportCountInfo}  | 
|           | 
|     serverGroupIDList = [serverGroupID] if serverGroupID else []  | 
|     if syncPub:  | 
|         serverGroupIDList = [] # Í¬²½¹«¹²ÐÅϢʱ£¬Ä¬ÈÏÈ«·þ¹ã²¥  | 
|     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ChampionshipGuess, dataMsg, serverGroupIDList)  | 
|     return  | 
|   | 
| def CrossServerMsg_ChampionshipState(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ͬ²½µÄÐÅÏ¢  - ¿ç·þÅÅλÕù°ÔÈü״̬  | 
|       | 
|     ID = msgData["ID"]  | 
|     State = msgData["State"]  | 
|     StateError = msgData["StateError"]  | 
|     PKZoneIDList = msgData["PKZoneIDList"]  | 
|     newAct = msgData["NewAct"]  | 
|       | 
|     dbID = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID)  | 
|       | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID, ID)  | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState, State)  | 
|     PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError, StateError)  | 
|       | 
|     # ×Ó·þÊý¾ÝÖØÖà  | 
|     if dbID != ID or newAct:  | 
|         champMgr = GetChampionshipMgr()  | 
|         prePKZoneIDList = champMgr.GetChampPKZoneIDList()  | 
|         champMgr.ClearPKZone()  | 
|         GameWorld.Log("×Ó·þÖØÖÿç·þÅÅλÕù°ÔÈü¶ÔÕ½Êý¾Ý! dbID=%s,ID=%s,PKZoneIDList=%s,prePKZoneIDList=%s" % (dbID, ID, PKZoneIDList, prePKZoneIDList))  | 
|         for zoneID in PKZoneIDList:  | 
|             champMgr.GetChampPKZoneMgr(zoneID)  | 
|     return  | 
|   | 
| def CrossServerMsg_ChampionshipPlayer(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ͬ²½µÄÐÅÏ¢  - ²ÎÈüÍæ¼ÒÐÅÏ¢  | 
|       | 
|     isSync = msgData["isSync"]  | 
|     clearPlayer = msgData["clearPlayer"]  | 
|     zoneBatPlayerInfo = msgData["zoneBatPlayerInfo"]  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID, batPlayerList in zoneBatPlayerInfo.items():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|           | 
|         if not batPlayerList:  | 
|             if clearPlayer:  | 
|                 pkZoneMgr.playerDict = {}  | 
|         else:  | 
|             for attrDict in batPlayerList:  | 
|                 zoneID = attrDict["zoneID"]  | 
|                 playerID = attrDict["playerID"]  | 
|                 batPlayer = pkZoneMgr.GetBatPlayer(playerID)  | 
|                 if not batPlayer:  | 
|                     batPlayer = ChampionshipBatPlayer()  | 
|                     pkZoneMgr.playerDict[playerID] = batPlayer  | 
|                 batPlayer.SetAttr(attrDict)  | 
|                   | 
|         if isSync:  | 
|             Sync_ChampionshipPKZoneGroupInfo(zoneID)  | 
|               | 
|     return  | 
|   | 
| def CrossServerMsg_ChampionshipGroup(msgData):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ͬ²½µÄÐÅÏ¢  - ·Ö×éÐÅÏ¢  | 
|       | 
|     syncGroupInfo = {}  | 
|     champMgr = GetChampionshipMgr()  | 
|     for attrDict in msgData:  | 
|         zoneID = attrDict["zoneID"]  | 
|         groupMark = attrDict["groupMark"]  | 
|         battleNum = attrDict["battleNum"]  | 
|           | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|         battle = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|         if not battle:  | 
|             battle = ChampionshipBattle()  | 
|             pkZoneMgr.AddBattle(groupMark, battleNum, battle)  | 
|         battle.SetAttr(attrDict)  | 
|           | 
|         if zoneID not in syncGroupInfo:  | 
|             syncGroupInfo[zoneID] = {}  | 
|         groupMarkDict = syncGroupInfo[zoneID]  | 
|         if groupMark not in groupMarkDict:  | 
|             groupMarkDict[groupMark] = []  | 
|         battleNumList = groupMarkDict[groupMark]  | 
|         if battleNum not in battleNumList:  | 
|             battleNumList.append(battleNum)  | 
|               | 
|     for zoneID, groupMarkDict in syncGroupInfo.items():  | 
|         Sync_ChampionshipPKZoneGroupInfo(zoneID, groupMarkDict)  | 
|           | 
|     return  | 
|   | 
| def CrossServerMsg_ChampionshipGuess(msgData, tick):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷ͬ²½µÄÐÅÏ¢  - ¾º²ÂÐÅÏ¢  | 
|       | 
|     exData = msgData["exData"]  | 
|     guessList = msgData["guessList"]  | 
|     pubInfo = msgData.get("pubInfo", None)  | 
|       | 
|     if not exData or not isinstance(exData, dict):  | 
|         exData = {}  | 
|     exDataType = exData.get("exDataType", "")  | 
|     playerID = exData.get("playerID", 0)  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|       | 
|     syncKeyInfo = {}  | 
|     for attrDict in guessList:  | 
|         zoneID = attrDict["zoneID"]  | 
|         guessType = attrDict["guessType"]  | 
|         guessPlayerID = attrDict["guessPlayerID"]  | 
|         tagPlayerID = attrDict["tagPlayerID"]  | 
|           | 
|         if guessType not in syncKeyInfo:  | 
|             syncKeyInfo[guessType] = []  | 
|         syncTagPlayerIDList = syncKeyInfo[guessType]  | 
|         syncTagPlayerIDList.append(tagPlayerID)  | 
|           | 
|         # ¾º²ÂÁбí½öÕë¶ÔÍæ¼Ò¸öÈË£¬ËùÒÔ²»ÊÇÇëÇó·½Íæ¼Ò»ò±¾·þÍæ¼ÒÔò²»´¦Àí¸öÈËÐÅÏ¢£¬½ö´¦Àí¹«¹²ÐÅÏ¢  | 
|         if playerID != guessPlayerID:  | 
|             continue  | 
|           | 
|         if not PlayerControl.GetDBPlayerAccIDByID(guessPlayerID):  | 
|             # ·Ç±¾·þÍæ¼Ò  | 
|             continue  | 
|           | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|           | 
|         guessObj = None  | 
|         playerGuessList = pkZoneMgr.GetPlayerGuessList(guessPlayerID, guessType)  | 
|         for guess in playerGuessList:  | 
|             if guess.tagPlayerID == tagPlayerID:  | 
|                 guessObj = guess  | 
|                 break  | 
|               | 
|         if not guessObj:  | 
|             guessObj = ChampionshipGuess()  | 
|             playerGuessList.append(guessObj)  | 
|         guessObj.SetAttr(attrDict)  | 
|           | 
|     pubZoneIDList = []  | 
|     if pubInfo != None:  | 
|         zoneSupportCountInfo = pubInfo["zoneSupportCountInfo"]  | 
|         for zoneID, supportCountInfo in zoneSupportCountInfo.items():  | 
|             pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|             pkZoneMgr.supportCountInfo = supportCountInfo  | 
|             pubZoneIDList.append(zoneID)  | 
|               | 
|     if exDataType == "ChampionshipGuessQuery":  | 
|         # ²éѯµÄÖ»´¦Àí±¾·þÍæ¼Ò  | 
|         if not playerID:  | 
|             return  | 
|         if not PlayerControl.GetDBPlayerAccIDByID(playerID):  | 
|             # ·Ç±¾·þÍæ¼Ò  | 
|             return  | 
|         zoneID = exData.get("zoneID", 0)  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID, True)  | 
|         pkZoneMgr.syncGuessPlayerIDInfo[playerID] = tick  | 
|         curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|         if curPlayer == None:  | 
|             return  | 
|         Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyInfo)  | 
|         Sync_ChampionshipGuessPubInfo(zoneID, curPlayer, syncKeyInfo)  | 
|         return  | 
|       | 
|     if exDataType == "ChampionshipGuess":  | 
|         # ¾º²ÂµÄÈç¹ûÓй«¹²ÐÅÏ¢ÐèÒª¹ã²¥È«·þÍæ¼Ò£¬¸öÈËÐÅϢֻͬ²½¸Ã¾º²ÂÍæ¼Ò  | 
|         zoneID = exData.get("zoneID", 0)  | 
|         if pubInfo != None:  | 
|             Sync_ChampionshipGuessPubInfo(zoneID, None, syncKeyInfo)  | 
|         if not playerID:  | 
|             return  | 
|         if not PlayerControl.GetDBPlayerAccIDByID(playerID):  | 
|             # ·Ç±¾·þÍæ¼Ò  | 
|             return  | 
|         msgInfo = [exDataType, exData]  | 
|         curPlayer = CrossRealmPlayer.MapServer_QueryCrossPlayerResult(playerID, "Championship", msgInfo, True)  | 
|         if curPlayer:  | 
|             Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyInfo)  | 
|         return  | 
|       | 
|     return  | 
|   | 
| def OnRequestChampionshipVSRoom(playerID, serverGroupID):  | 
|     ## ÇëÇó½øÈëÅÅλ¶ÔÕ½·¿¼ä  | 
|       | 
|     stateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)  | 
|     if stateError:  | 
|         GameWorld.ErrLog("¿ç·þÅÅλ״̬ÒѾÒì³£ÎÞ·¨½øÈë! stateError=%s" % stateError, playerID)  | 
|         return  | 
|       | 
|     state = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState)  | 
|     if state not in ShareDefine.CrossChampionshipEnterStateInfo:  | 
|         GameWorld.ErrLog("µ±Ç°×´Ì¬·Ç¿ç·þÅÅλս¶·×´Ì¬ÎÞ·¨½øÈë: state=%s" % state, playerID)  | 
|         return  | 
|     groupMark = ShareDefine.CrossChampionshipEnterStateInfo[state]  | 
|       | 
|     mapPosList = IpyGameDataPY.GetFuncEvalCfg("CrossChamFB", 2)  | 
|     if not mapPosList:  | 
|         GameWorld.ErrLog("ûÓÐÅäÖÿç·þÅÅλ¶ÔÕ½µØÍ¼½øÈë×ø±ê£¡ CrossChamFB ÊýÖµ2")  | 
|         return  | 
|       | 
|     roomID = 0  | 
|     vsRoomDict = {}  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampPKZoneIDList():  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         if groupMark not in pkZoneMgr.battleInfo:  | 
|             continue  | 
|         battleDict = pkZoneMgr.battleInfo[groupMark]  | 
|         for battleNum in battleDict.keys():  | 
|             batObj = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|               | 
|             if playerID == batObj.playerIDA:# or batObj.playerIDA == 496607:  | 
|                 factionIndex = 0  | 
|             elif playerID == batObj.playerIDB:# or batObj.playerIDB == 489566:  | 
|                 factionIndex = 1  | 
|             else:  | 
|                 continue  | 
|               | 
|             if not batObj.mapID:  | 
|                 GameWorld.ErrLog("¸Ã¿ç·þÅÅλ¶ÔսûÓзÖÅä¶ÔÕ½µØÍ¼£¬ÎÞ·¨½øÈë! groupMark=%s,battleNum=%s" % (groupMark, battleNum), playerID)  | 
|                 return  | 
|             roomID = batObj.roomID  | 
|             realMapID = batObj.mapID  | 
|             copyMapID = batObj.copyMapID  | 
|             key = (realMapID, copyMapID)  | 
|             if key not in PyGameData.g_crossDynamicLineCopyMapInfo:  | 
|                 GameWorld.ErrLog("¸Ã¿ç·þÅÅλ¶ÔսûÓзÖÅä¶ÔÕ½µØÍ¼Ïß·£¬ÎÞ·¨½øÈë! groupMark=%s,battleNum=%s,realMapID=%s,copyMapID=%s"   | 
|                                  % (groupMark, battleNum, realMapID, copyMapID), playerID)  | 
|                 return  | 
|             copyMapObj = PyGameData.g_crossDynamicLineCopyMapInfo[key]  | 
|             if copyMapObj.openState != IPY_PlayerDefine.fbosOpen:  | 
|                 GameWorld.Log("¸Ã¿ç·þÅÅλ¶ÔÕ½·ÖÅäµÄµØÍ¼Ïß··Ç¿ªÆô״̬£¬ÎÞ·¨½øÈë! groupMark=%s,battleNum=%s,realMapID=%s,copyMapID=%s,openState=%s"   | 
|                               % (groupMark, battleNum, realMapID, copyMapID, copyMapObj.openState), playerID)  | 
|                 return  | 
|               | 
|             posX, posY = mapPosList[factionIndex] if len(mapPosList) > factionIndex else mapPosList[0]  | 
|               | 
|             registerMap = ChConfig.Def_FBMapID_CrossChampionship  | 
|             dataMapID = realMapID  | 
|               | 
|             vsRoomDict = {roomID:{playerID:{"regMapInfo":[registerMap, realMapID, dataMapID, copyMapID, posX, posY]}}}  | 
|             GameWorld.Log("Íæ¼ÒÇëÇó¿ç·þÅÅλ¶ÔÕ½×é: zoneID=%s,groupMark=%s,battleNum=%s,roomID=%s"   | 
|                           % (zoneID, groupMark, battleNum, roomID), playerID)  | 
|             break  | 
|           | 
|     if not roomID or not vsRoomDict:  | 
|         GameWorld.ErrLog("ÕÒ²»µ½Íæ¼Ò¿ç·þÅÅλ¶ÔÕ½×é: state=%s,groupMark=%s" % (state, groupMark), playerID)  | 
|         return  | 
|     PlayerFB.Send_CrossServerMsg_EnterVSRoomRet(vsRoomDict, [serverGroupID])  | 
|     return  | 
|   | 
| def GetChampionshipPKRoomID(zoneID, groupMark, battleNum): return int("%d%03d%02d" % (zoneID, groupMark, battleNum))  | 
| def MapServer_CrossChampionshipPKOver(infoList, tick):  | 
|     ## ÊÕµ½MapServer¸±±¾¿ç·þÅÅλPK½á¹ûͬ²½  | 
|       | 
|     roomID, winnerID, loserID, roundWinnerIDList, overType = infoList  | 
|     zoneID = roomID / 100000  | 
|     groupMark = roomID % 100000 / 100  | 
|     battleNum = roomID % 100  | 
|     GameWorld.Log("=== ÊÕµ½MapServer_¿ç·þÅÅλPKÕ½¶·½á¹û: zoneID=%s,groupMark=%s,battleNum=%s,roomID=%s,winnerID=%s,loserID=%s,roundWinnerIDList=%s,overType=%s"   | 
|                   % (zoneID, groupMark, battleNum, roomID, winnerID, loserID, roundWinnerIDList, overType), roomID)  | 
|     DoBattleOverLogic(zoneID, groupMark, battleNum, winnerID, loserID, roundWinnerIDList, overType)  | 
|     return  | 
|   | 
| def DoBattleOverLogic(zoneID, groupMark, battleNum, winnerID=0, loserID=0, roundWinnerIDList=None, overType=0):  | 
|     ## Ö´ÐжÔÕ½½áËãÂß¼  | 
|       | 
|     if not zoneID:  | 
|         return  | 
|       | 
|     groupMarkList = ShareDefine.CrossChampionshipEnterStateInfo.values()  | 
|     if groupMark not in groupMarkList:  | 
|         GameWorld.ErrLog("¿ç·þÅÅλ½áËã·Ö×éÒì³£! groupMark=%s" % groupMark)  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|     if not pkZoneMgr:  | 
|         return  | 
|     battleObj = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|     if not battleObj:  | 
|         return  | 
|       | 
|     if roundWinnerIDList == None:  | 
|         roundWinnerIDList = []  | 
|           | 
|     roomID = battleObj.roomID  | 
|     if battleObj.overTime:  | 
|         GameWorld.ErrLog("¿ç·þÅÅλPK¶ÔÕ½ÒѾ½áËã¹ýÁË£¬²»Öظ´½áËã! zoneID=%s,groupMark=%s,battleNum=%s,winPlayerID=%s,overTime=%s"   | 
|                          % (zoneID, groupMark, battleNum, battleObj.winPlayerID, GameWorld.ChangeTimeNumToStr(battleObj.overTime)), roomID)  | 
|         return  | 
|       | 
|     playerIDA = battleObj.playerIDA  | 
|     playerIDB = battleObj.playerIDB  | 
|     roomPlayerIDList = [playerIDA, playerIDB]  | 
|     GameWorld.Log("½áËã¿ç·þÅÅλPKÕ½¶·½á¹û: zoneID=%s,groupMark=%s,battleNum=%s,playerIDA=%s,playerIDB=%s,roomPlayerIDList=%s"   | 
|                   % (zoneID, groupMark, battleNum, playerIDA, playerIDB, roomPlayerIDList), roomID)  | 
|       | 
|     if playerIDA and playerIDB:  | 
|         if not winnerID and not loserID:  | 
|             playerA = pkZoneMgr.GetBatPlayer(playerIDA)  | 
|             playerB = pkZoneMgr.GetBatPlayer(playerIDB)  | 
|             fightPowerA = playerA.fightPower if playerA else 0  | 
|             fightPowerB = playerB.fightPower if playerB else 0  | 
|             if fightPowerA > fightPowerB:  | 
|                 winnerID, loserID = playerIDA, playerIDB  | 
|                 GameWorld.Log("    ¿ç·þÅÅλÈü¶ÔÕ½µØÍ¼Ã»ÓÐÍæ¼Ò²ÎÓë»òûÓÐʤ¸ºÍæ¼Ò£¬Õ½Á¦¸ß»ñʤ! fightPowerA=%s(%s) > fightPowerB=%s(%s),winnerID=%s,loserID=%s"   | 
|                               % (fightPowerA, playerIDA, fightPowerB, playerIDB, winnerID, loserID), roomID)  | 
|             elif fightPowerA < fightPowerB:  | 
|                 winnerID, loserID = playerIDB, playerIDA  | 
|                 GameWorld.Log("    ¿ç·þÅÅλÈü¶ÔÕ½µØÍ¼Ã»ÓÐÍæ¼Ò²ÎÓë»òûÓÐʤ¸ºÍæ¼Ò£¬Õ½Á¦¸ß»ñʤ! fightPowerA=%s(%s) < fightPowerB=%s(%s),winnerID=%s,loserID=%s"   | 
|                               % (fightPowerA, playerIDA, fightPowerB, playerIDB, winnerID, loserID), roomID)  | 
|             else:  | 
|                 random.shuffle(roomPlayerIDList)  | 
|                 winnerID, loserID = roomPlayerIDList  | 
|                 GameWorld.Log("    ¿ç·þÅÅλÈü¶ÔÕ½µØÍ¼Ã»ÓÐÍæ¼Ò²ÎÓë»òûÓÐʤ¸ºÍæ¼Ò£¬Õ½Á¦ÏàÍ¬Ëæ»úÍæ¼Ò»ñʤ! fightPowerA=%s(%s) = fightPowerB=%s(%s),winnerID=%s,loserID=%s"   | 
|                               % (fightPowerA, playerIDA, fightPowerB, playerIDB, winnerID, loserID), roomID)  | 
|         elif not loserID:  | 
|             for roomPlayerID in roomPlayerIDList:  | 
|                 if roomPlayerID != winnerID:  | 
|                     loserID = roomPlayerID  | 
|                     GameWorld.Log("    ¿ç·þÅÅλÈü¶ÔÕ½µØÍ¼Ã»ÓÐʧ°ÜÍæ¼Ò£¬Ä¬È϶Է½ÎªÊ§°ÜÍæ¼Ò! loserID=%s" % loserID, roomID)  | 
|                     break  | 
|                   | 
|         if not winnerID or winnerID not in roomPlayerIDList or loserID not in roomPlayerIDList:  | 
|             GameWorld.ErrLog("¿ç·þÅÅλÈüPK·¿¼äʤ¸ºÍæ¼ÒÒì³££¬²»½áË㣡 roomID=%s,winnerID=%s,loserID=%s,roomPlayerIDList=%s"   | 
|                              % (roomID, winnerID, loserID, roomPlayerIDList), roomID)  | 
|             return  | 
|           | 
|     elif playerIDA:  | 
|         winnerID = playerIDA  | 
|         loserID = playerIDB  | 
|         GameWorld.Log("    ¿ç·þÅÅλÈü¶ÔÕ½Íæ¼ÒÂÖ¿Õ£¬Ä¬ÈÏ»ñʤ! winner is playerIDA=%s,loserID=%s" % (playerIDA, loserID), roomID)  | 
|     elif playerIDB:  | 
|         winnerID = playerIDB  | 
|         loserID = playerIDA  | 
|         GameWorld.Log("    ¿ç·þÅÅλÈü¶ÔÕ½Íæ¼ÒÂÖ¿Õ£¬Ä¬ÈÏ»ñʤ! winner is playerIDB=%s,loserID=%s" % (playerIDB, loserID), roomID)  | 
|     else:  | 
|         GameWorld.Log("    ¿ç·þÅÅλÈüPK·¿¼äÎÞÍæ¼Ò! roomID=%s,winnerID=%s,loserID=%s,roomPlayerIDList=%s"   | 
|                              % (roomID, winnerID, loserID, roomPlayerIDList), roomID)  | 
|           | 
|     # ¸üлñÊ¤Íæ¼ÒID¡¢½áÊøÊ±¼ä  | 
|     battleObj.winPlayerID = winnerID  | 
|     battleObj.overTime = int(time.time())  | 
|       | 
|     winner = pkZoneMgr.GetBatPlayer(winnerID)  | 
|     loser = pkZoneMgr.GetBatPlayer(loserID)  | 
|       | 
|     winnerName = winner.playerName if winner else str(winnerID)  | 
|     loserName = loser.playerName if loser else str(loserID)  | 
|       | 
|     # ¾öÈü¿É»ñÈ¡×îÖÕÃû´Î  | 
|     playerRankInfo = {}  | 
|     if groupMark == 2:  | 
|         playerRankInfo = GetZoneIDRankInfo(zoneID, [winnerID, loserID])  | 
|           | 
|     if groupMark == 64:  | 
|         wfAwardItemList = IpyGameDataPY.GetFuncEvalCfg("CrossChamWFAward", 1)  | 
|     elif groupMark == 32:  | 
|         wfAwardItemList = IpyGameDataPY.GetFuncEvalCfg("CrossChamWFAward", 2)  | 
|     elif groupMark == 16:  | 
|         wfAwardItemList = IpyGameDataPY.GetFuncEvalCfg("CrossChamWFAward", 3)  | 
|     else:  | 
|         wfAwardItemList = IpyGameDataPY.GetFuncEvalCfg("CrossChamWFAward", 4)  | 
|           | 
|     wAwardItemList, fAwardItemList = [], []  | 
|     if wfAwardItemList and len(wfAwardItemList) == 2:  | 
|         wAwardItemList, fAwardItemList = wfAwardItemList  | 
|                   | 
|     timeStr = GameWorld.GetCurrentDataTimeStr()  | 
|     # ½áËã  | 
|     for playerID in [winnerID, loserID]:  | 
|         if not playerID:  | 
|             continue  | 
|           | 
|         if playerID == winnerID:  | 
|             addItemList = wAwardItemList  | 
|             mailTypeKey = "CrossChampionshipPKWin%s" % groupMark  | 
|             tagPlayerID, tagPlayerName = loserID, loserName  | 
|         else:  | 
|             addItemList = fAwardItemList  | 
|             mailTypeKey = "CrossChampionshipPKLose%s" % groupMark  | 
|             tagPlayerID, tagPlayerName = winnerID, winnerName  | 
|               | 
|         rank = playerRankInfo.get(playerID, 0)  | 
|         GameWorld.Log("    ½áËã¿ç·þÅÅλÈüÍæ¼Ò½±Àø: zoneID=%s,roomID=%s,groupMark=%s,battleNum=%s,rank=%s,tagPlayerID=%s"   | 
|                            % (zoneID, roomID, groupMark, battleNum, rank, tagPlayerID), playerID)  | 
|         if rank:  | 
|             paramList = [rank]  | 
|         else:  | 
|             paramList = []  | 
|         playerIDList = [playerID]  | 
|         PlayerCompensation.SendMailByKey(mailTypeKey, playerIDList, addItemList, paramList, crossMail=True)  | 
|           | 
|         player = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|         if player:  | 
|             overPack = ChPyNetSendPack.tagGCCrossChampionshipPKOver()  | 
|             overPack.GroupMark = groupMark  | 
|             overPack.TimeStr = timeStr  | 
|             overPack.OverType = overType  | 
|             overPack.WinnerID = winnerID  | 
|             overPack.LoserID = loserID  | 
|             overPack.RoundWinnerID = roundWinnerIDList  | 
|             overPack.RoundCount = len(overPack.RoundWinnerID)  | 
|             overPack.TagName = tagPlayerName  | 
|             overPack.TagNameLen = len(overPack.TagName)  | 
|             overPack.Rank = rank  | 
|             NetPackCommon.SendFakePack(player, overPack)  | 
|               | 
|     # Í¬²½×Ó·þ  | 
|     Send_CrossServerMsg_ChampionshipGroup(battleObj=battleObj)  | 
|       | 
|     # ¼Ç¼Á÷Ïò  | 
|     winnerInfo = winner.GetString() if winner else {}  | 
|     loserInfo = loser.GetString() if loser else {}  | 
|     dataDict = {"roundWinnerIDList":roundWinnerIDList, "overType":overType, "winner":winnerInfo, "loser":loserInfo,   | 
|                 "battle":battleObj.GetString(), "playerRankInfo":playerRankInfo}  | 
|     DR_CrossChampionshipPK("PKRoomOver", dataDict)      | 
|     return  | 
|   | 
| def DoCrossChampionshipFinalOver():  | 
|     ## Ö´ÐнáËã×îÖÕ½á¹û£¬ËùÓзÖÇøÍ¬Ò»Ê±¼äµã´¦Àí  | 
|       | 
|     GameWorld.Log("===================== Ö´Ðпç·þÅÅλ×îÖÕ½áËã ===========================")  | 
|       | 
|     finalGroupMark = 2  # ¾öÈü·Ö×é  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     champMgr.ClearOfficialZone() # ×îÖÕ½áËãÖØÖÃÏɹÙÐÅÏ¢£¬Ìæ»»×îÐÂÏɹ٠ | 
|       | 
|     pkZoneIDList = champMgr.GetChampPKZoneIDList()  | 
|     GameWorld.Log("pkZoneIDList=%s" % pkZoneIDList)  | 
|       | 
|     for zoneID in pkZoneIDList:  | 
|         GameWorld.Log("=== ½áËãÅÅλ·ÖÇø: zoneID=%s ===" % zoneID, zoneID)  | 
|         finalPlayerIDList = []  | 
|         pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|         if not pkZoneMgr:  | 
|             continue  | 
|         battleNumList = pkZoneMgr.battleInfo.get(finalGroupMark, {}).keys()  | 
|         for battleNum in battleNumList:  | 
|             batObj = pkZoneMgr.GetBattle(finalGroupMark, battleNum)  | 
|             if not batObj:  | 
|                 continue  | 
|             if not batObj.overTime:  | 
|                 GameWorld.ErrLog("×îÖÕÕ½¶·Î´½áË㣬ִÐÐÇ¿ÖÆ½áËã! zoneID=%s,finalGroupMark=%s,battleNum=%s,mapID=%s,copyMapID=%s"   | 
|                                  % (zoneID, finalGroupMark, battleNum, batObj.mapID, batObj.copyMapID), batObj.roomID)  | 
|                 DoBattleOverLogic(zoneID, finalGroupMark, battleNum)  | 
|                   | 
|             if batObj.playerIDA and batObj.playerIDA not in finalPlayerIDList:  | 
|                 finalPlayerIDList.append(batObj.playerIDA)  | 
|                   | 
|             if batObj.playerIDB and batObj.playerIDB not in finalPlayerIDList:  | 
|                 finalPlayerIDList.append(batObj.playerIDB)  | 
|                   | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         playerRankInfo = GetZoneIDRankInfo(zoneID, finalPlayerIDList)  | 
|         for playerID, rank in playerRankInfo.items():  | 
|             batPlayer = pkZoneMgr.GetBatPlayer(playerID)  | 
|             accID = "" if not batPlayer else batPlayer.accID  | 
|             fightPower = 0 if not batPlayer else batPlayer.fightPower  | 
|             rankIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipRank", rank)  | 
|             officialID = rankIpyData.GetMainOfficialID() if rankIpyData else 0  | 
|             rankAwardItemList = rankIpyData.GetRankAwardItemList() if rankIpyData else []  | 
|             GameWorld.Log("    ×îÖÕÅÅÃû: zoneID=%s,rank=%s,playerID=%s,officialID=%s,rankAwardItemList=%s,accID=%s,fightPower=%s"   | 
|                           % (zoneID, rank, playerID, officialID, rankAwardItemList, accID, fightPower), zoneID)  | 
|               | 
|             if officialID:  | 
|                 offObj = ChampionshipOfficial()  | 
|                 offObj.zoneID = zoneID  | 
|                 offObj.officialID = officialID  | 
|                 offObj.rank = rank  | 
|                 offObj.playerID = playerID  | 
|                   | 
|                 offZoneMgr.officialInfo[officialID] = offObj  | 
|                   | 
|             # Ãû´Î½±Àø  | 
|             paramList = [rank]  | 
|             PlayerCompensation.SendMailByKey("CrossChampionshipPKRank", [playerID], rankAwardItemList, paramList, crossMail=True)  | 
|               | 
|         # ´¦Àí4Ç¿¾º²Â·¢½±Àø  | 
|         guessType = 4  | 
|         moneyType = ShareDefine.TYPE_Price_GongdePoint  | 
|         multiPriceDict = IpyGameDataPY.GetFuncEvalCfg("CrossChamGuess", 4, {}) # ²ÂÖн±Àø±¶Öµ×Öµä  | 
|         moneyItemID = ChConfig.MoneyItemIDDict.get(moneyType)  | 
|         GameWorld.Log("¾º²Â·µÀû»õ±ÒÀàÐÍ: moneyType=%s,moneyItemID=%s,multiPriceDict=%s" % (moneyType, moneyItemID, multiPriceDict), zoneID)  | 
|         playerGuessDict = pkZoneMgr.guessInfo.get(guessType, {})  | 
|         for guessPlayerID, guessList in playerGuessDict.items():  | 
|             guessCorrectCount = 0 # ²ÂÖÐÈËÊý  | 
|             guessCorrectMoney = 0 # ²ÂÖÐ×ÜͶÈë»õ±Ò  | 
|             for guessObj in guessList:  | 
|                 if guessObj.guessType != guessType or guessObj.guessPlayerID != guessPlayerID:  | 
|                     continue  | 
|                 guessObj.isClose = 1  | 
|                 tagPlayerID = guessObj.tagPlayerID  | 
|                 guessRank = guessObj.guessRank  | 
|                 moneyTotal = guessObj.moneyTotal  | 
|                 if not tagPlayerID or tagPlayerID not in playerRankInfo:  | 
|                     continue  | 
|                 playerRank = playerRankInfo[tagPlayerID]  | 
|                 if playerRank != guessRank:  | 
|                     continue  | 
|                 guessCorrectCount += 1  | 
|                 guessCorrectMoney += moneyTotal  | 
|                   | 
|             multiPrice = multiPriceDict.get(str(guessCorrectCount), 0)  | 
|             if guessCorrectMoney <= 0 or multiPrice <= 0 or not moneyItemID:  | 
|                 continue  | 
|             moneyPriceTotal = guessCorrectMoney * multiPrice # ×ÜÊÕÒæ  | 
|             paramList = [guessCorrectCount, multiPrice]  | 
|             addItemList = [[moneyItemID, moneyPriceTotal, 0]]  | 
|             PlayerCompensation.SendMailByKey("CrossChampionshipGuess4", [guessPlayerID], addItemList, paramList, crossMail=True)  | 
|               | 
|     exData = {"exDataType":"OfficialReset"}  | 
|     Send_CrossServerMsg_ChampionshipOfficial(exData=exData)  | 
|       | 
|     serverGroupIDList = [] # È«·þͳһÂß¼  | 
|     PlayerControl.WorldNotifyCross(serverGroupIDList, 0, "ChampionshipOver")  | 
|     GameWorld.Log("===================================================================")  | 
|     return  | 
|   | 
| def GetZoneIDRankInfo(zoneID, playerIDList):  | 
|     ## »ñÈ¡·ÖÇøÍæ¼ÒÅÅÃû  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|     if not pkZoneMgr:  | 
|         return {}  | 
|       | 
|     # ¾öÈü  | 
|     finalGroupMark = 2  | 
|     finalWinPlayerIDList, finalLosePlayerIDList = [], []  | 
|     battleNumList = pkZoneMgr.battleInfo.get(finalGroupMark, {}).keys()  | 
|     for battleNum in battleNumList:  | 
|         batObj = pkZoneMgr.GetBattle(finalGroupMark, battleNum)  | 
|         if not batObj:  | 
|             continue  | 
|         if not batObj.overTime or not batObj.winPlayerID:  | 
|             continue  | 
|         winPlayerID = batObj.playerIDA if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDB  | 
|         losePlayerID = batObj.playerIDB if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDA  | 
|         finalWinPlayerIDList.append(winPlayerID)  | 
|         finalLosePlayerIDList.append(losePlayerID)  | 
|           | 
|     # °ë¾öÈü  | 
|     semiGroupMark = 4  | 
|     semiWinPlayerIDList, semiLosePlayerIDList = [], []  | 
|     battleNumList = pkZoneMgr.battleInfo.get(semiGroupMark, {}).keys()  | 
|     for battleNum in battleNumList:  | 
|         batObj = pkZoneMgr.GetBattle(semiGroupMark, battleNum)  | 
|         if not batObj:  | 
|             continue  | 
|         if not batObj.overTime or not batObj.winPlayerID:  | 
|             continue  | 
|         winPlayerID = batObj.playerIDA if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDB  | 
|         losePlayerID = batObj.playerIDB if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDA  | 
|         semiWinPlayerIDList.append(winPlayerID)  | 
|         semiLosePlayerIDList.append(losePlayerID)  | 
|           | 
|     # 1/4¾öÈü  | 
|     wlGroupMark = 8  | 
|     winGroupPlayerIDList, loseGroupPlayerIDList = [], [] # Ê¤Õß×é¡¢°ÜÕß×é  | 
|     battleNumList = pkZoneMgr.battleInfo.get(wlGroupMark, {}).keys()  | 
|     for battleNum in battleNumList:  | 
|         batObj = pkZoneMgr.GetBattle(wlGroupMark, battleNum)  | 
|         if not batObj:  | 
|             continue  | 
|         if not batObj.overTime or not batObj.winPlayerID:  | 
|             continue  | 
|         winPlayerID = batObj.playerIDA if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDB  | 
|         losePlayerID = batObj.playerIDB if batObj.winPlayerID == batObj.playerIDA else batObj.playerIDA  | 
|         winGroupPlayerIDList.append(winPlayerID)  | 
|         loseGroupPlayerIDList.append(losePlayerID)  | 
|           | 
|     GameWorld.Log("     8Ç¿Èüʤ¸º: zoneID=%s,ʤÕßID=%s,°ÜÕßID=%s" % (zoneID, winGroupPlayerIDList, loseGroupPlayerIDList), zoneID)  | 
|     GameWorld.Log("    °ë¾öÈüʤ¸º: zoneID=%s,ʤÕßID=%s,°ÜÕßID=%s" % (zoneID, semiWinPlayerIDList, semiLosePlayerIDList), zoneID)  | 
|     GameWorld.Log("    ×ܾöÈüʤ¸º: zoneID=%s,ʤÕßID=%s,°ÜÕßID=%s" % (zoneID, finalWinPlayerIDList, finalLosePlayerIDList), zoneID)  | 
|       | 
|     playerRankInfo = {}  | 
|     for playerID in playerIDList:  | 
|         if not playerID:  | 
|             continue  | 
|         if playerID in winGroupPlayerIDList:  | 
|             if playerID in semiWinPlayerIDList:  | 
|                 if playerID in finalWinPlayerIDList:  | 
|                     playerRankInfo[playerID] = 1  | 
|                 elif playerID in finalLosePlayerIDList:  | 
|                     playerRankInfo[playerID] = 2  | 
|             elif playerID in semiLosePlayerIDList:  | 
|                 if playerID in finalWinPlayerIDList:  | 
|                     playerRankInfo[playerID] = 3  | 
|                 elif playerID in finalLosePlayerIDList:  | 
|                     playerRankInfo[playerID] = 4  | 
|         elif playerID in loseGroupPlayerIDList:  | 
|             if playerID in semiWinPlayerIDList:  | 
|                 if playerID in finalWinPlayerIDList:  | 
|                     playerRankInfo[playerID] = 5  | 
|                 elif playerID in finalLosePlayerIDList:  | 
|                     playerRankInfo[playerID] = 6  | 
|             elif playerID in semiLosePlayerIDList:  | 
|                 if playerID in finalWinPlayerIDList:  | 
|                     playerRankInfo[playerID] = 7  | 
|                 elif playerID in finalLosePlayerIDList:  | 
|                     playerRankInfo[playerID] = 8  | 
|                       | 
|     GameWorld.Log("    zoneID=%s,playerRankInfo=%s" % (zoneID, playerRankInfo), zoneID)  | 
|     return playerRankInfo  | 
|   | 
| def Send_CrossServerMsg_ChampionshipOfficial(syncZonID=None, syncOfficialIDList=None, serverGroupID=0, exData=None):  | 
|     officialList = []  | 
|     champMgr = GetChampionshipMgr()  | 
|     for zoneID in champMgr.GetChampOfficialZoneIDList():  | 
|         if syncZonID != None and zoneID != syncZonID:  | 
|             continue  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         officialIDList = offZoneMgr.officialInfo.keys() if syncOfficialIDList == None else syncOfficialIDList  | 
|         for officialID in officialIDList:  | 
|             offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|             if not offObj:  | 
|                 continue  | 
|             officialList.append(offObj.GetString())  | 
|               | 
|     dataMsg = {"exData":exData if exData else {}, "officialList":officialList}  | 
|     serverGroupIDList = [serverGroupID] if serverGroupID else []  | 
|     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_ChampionshipOfficial, dataMsg, serverGroupIDList)  | 
|     return  | 
|   | 
| def CrossServerMsg_ChampionshipOfficial(msgData):  | 
|     ## ÊÕµ½¿ç·þͬ²½µÄ¹Ù¾ôÍæ¼ÒÐÅÏ¢  | 
|       | 
|     exData = msgData["exData"]  | 
|     officialList = msgData["officialList"]  | 
|       | 
|     if not exData or not isinstance(exData, dict):  | 
|         exData = {}  | 
|     exDataType = exData.get("exDataType", "")  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     ## ¹ÙÖ°ÖØÖÃ  | 
|     if exDataType == "OfficialReset":  | 
|         champMgr.ClearOfficialZone()  | 
|           | 
|     syncZoneOfficialInfo = {}  | 
|     for attrDict in officialList:  | 
|         zoneID = attrDict["zoneID"]  | 
|         officialID = attrDict["officialID"]  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|         if not offObj:  | 
|             offObj = ChampionshipOfficial()  | 
|             offZoneMgr.officialInfo[officialID] = offObj  | 
|         offObj.SetAttr(attrDict)  | 
|           | 
|         if zoneID not in syncZoneOfficialInfo:  | 
|             syncZoneOfficialInfo[zoneID] = []  | 
|         officialIDList = syncZoneOfficialInfo[zoneID]  | 
|         if officialID not in officialIDList:  | 
|             officialIDList.append(officialID)  | 
|               | 
|     for zoneID, officialIDList in syncZoneOfficialInfo.items():  | 
|         Sync_ChampionshipOfficialInfo(zoneID, officialIDList)  | 
|       | 
|     if not exData:  | 
|         return  | 
|       | 
|     ## ¹ÙÖ°ÉêÇë»ØÓ¦  | 
|     if exDataType == "OfficialApplyReply":  | 
|         mainPlayerName = exData["mainPlayerName"]  | 
|         mainOfficialID = exData["mainOfficialID"]  | 
|         officialID = exData["officialID"]  | 
|         replyDict = exData["replyDict"]  | 
|         for playerID, isOK in replyDict.items():  | 
|             curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|             if curPlayer == None or not curPlayer.GetInitOK():  | 
|                 continue  | 
|             clientPack = ChPyNetSendPack.tagGCChampionshipOfficialApplyReplyRet()  | 
|             clientPack.PlayerName = mainPlayerName  | 
|             clientPack.NameLen = len(clientPack.PlayerName)  | 
|             clientPack.MainOfficialID = mainOfficialID  | 
|             clientPack.OfficialID = officialID  | 
|             clientPack.IsOK = 1 if isOK else 0  | 
|             NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|               | 
|     ## ¹ÙÖ°ÌôÕ½½á¹û  | 
|     elif exDataType == "OfficialChallenge":  | 
|         playerID = exData["playerID"]  | 
|         tagPlayerName = exData["tagPlayerName"]  | 
|         mainOfficialID = exData["mainOfficialID"]  | 
|         officialID = exData["officialID"]  | 
|         Ret = exData["Ret"]  | 
|         curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)  | 
|         if curPlayer:  | 
|             clientPack = ChPyNetSendPack.tagGCChampionshipOfficialChallengeRet()  | 
|             clientPack.PlayerName = tagPlayerName  | 
|             clientPack.NameLen = len(clientPack.PlayerName)  | 
|             clientPack.MainOfficialID = mainOfficialID  | 
|             clientPack.OfficialID = officialID  | 
|             clientPack.Ret = Ret  | 
|             NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|               | 
|     ## Ä¤°Ý  | 
|     elif exDataType == "OfficialWorship":  | 
|         playerID = exData["playerID"]  | 
|         if not playerID:  | 
|             return  | 
|         if not PlayerControl.GetDBPlayerAccIDByID(playerID):  | 
|             # ·Ç±¾·þÍæ¼Ò  | 
|             return  | 
|         msgInfo = [exDataType, exData]  | 
|         CrossRealmPlayer.MapServer_QueryCrossPlayerResult(playerID, "Championship", msgInfo, True)  | 
|           | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipGuess(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ¿ç·þÅÅλ¾º²Â  | 
|       | 
|     if "exDataType" not in msgData:  | 
|         return  | 
|     exDataType = msgData["exDataType"]  | 
|       | 
|     # ²éÑ¯Íæ¼ÒËùÓвÎÓëµÄ¾º²Â  | 
|     if exDataType == "ChampionshipGuessQuery":  | 
|         zoneID = msgData["zoneID"]  | 
|         playerID = msgData["playerID"]  | 
|         Send_CrossServerMsg_ChampionshipGuess(zoneID, playerID, serverGroupID=serverGroupID, exData=msgData)  | 
|         return  | 
|       | 
|     if exDataType != "ChampionshipGuess":  | 
|         return  | 
|       | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     guessType = msgData["guessType"]  | 
|     tagPlayerID = msgData["tagPlayerID"]  | 
|     guessRank = msgData["guessRank"]  | 
|     guessMoney = msgData["guessMoney"]  | 
|     moneyType = msgData["moneyType"]  | 
|       | 
|     if not tagPlayerID or not guessMoney:  | 
|         return  | 
|       | 
|     stateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)  | 
|     if stateError:  | 
|         GameWorld.ErrLog("¿ç·þÅÅλ״̬ÒѾÒì³£ÎÞ·¨¾º²Â! stateError=%s" % stateError, playerID)  | 
|         return  | 
|           | 
|     guessTypeStateDict = {8:ShareDefine.CrossChampionshipState_Guess8,  | 
|                           4:ShareDefine.CrossChampionshipState_Guess4,  | 
|                           }  | 
|     state = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipState)  | 
|     if guessType not in guessTypeStateDict or state != guessTypeStateDict[guessType]:  | 
|         GameWorld.ErrLog("¾º²ÂÀàÐÍ´íÎó»òµ±Ç°×´Ì¬ÎÞ·¨½øÐиÃÀàÐ;º²Â! guessType=%s,state=%s" % (guessType, state), playerID)  | 
|         return  | 
|       | 
|     curMoneyType, moneyValue = IpyGameDataPY.GetFuncEvalCfg("CrossChamGuess", 1)  | 
|     guessCountMax = IpyGameDataPY.GetFuncCfg("CrossChamGuess", 2)  | 
|     guessMoneyMax = moneyValue * guessCountMax  | 
|     if moneyType != curMoneyType:  | 
|         GameWorld.ErrLog("¾º²Â»õ±ÒÀàÐͲ»Ò»ÖÂ! moneyType=%s != curMoneyType=%s" % (moneyType, curMoneyType), playerID)  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|     if not pkZoneMgr:  | 
|         return  | 
|     tagBatPlayer = pkZoneMgr.GetBatPlayer(tagPlayerID)  | 
|     if not tagBatPlayer:  | 
|         GameWorld.ErrLog("¸Ã·ÖÇø²»´æÔڸòÎÈüÍæ¼Ò£¬ÎÞ·¨ÅÅλ¾º²Â! zoneID=%s,tagPlayerID=%s" % (zoneID, tagPlayerID), playerID)  | 
|         return  | 
|       | 
|     guessTagPlayerCountMax = guessType  | 
|     # 4Ç¿¾º²Â  | 
|     if guessType == 4:  | 
|         if guessRank <= 0 or guessRank > guessTagPlayerCountMax:  | 
|             GameWorld.ErrLog("¾º²ÂÃû´Î´íÎó! zoneID=%s,guessType=%s,guessRank=%s" % (zoneID, guessType, guessRank), playerID)  | 
|             return  | 
|         top8PlayerIDList = pkZoneMgr.GetTop8PlayerIDList()  | 
|         if tagPlayerID not in top8PlayerIDList:  | 
|             GameWorld.ErrLog("Ä¿Ç°Íæ¼Ò·Ç¸Ã·ÖÇø8Ç¿Íæ¼Ò£¬ÎÞ·¨¾º²Â! zoneID=%s,tagPlayerID=%s not in %s"   | 
|                              % (zoneID, tagPlayerID, top8PlayerIDList), playerID)  | 
|             return  | 
|           | 
|     guessObj = None  | 
|     playerGuessList = pkZoneMgr.GetPlayerGuessList(playerID, guessType)  | 
|     for guess in playerGuessList:  | 
|         if guess.tagPlayerID == tagPlayerID:  | 
|             if guessType == 4:  | 
|                 if guess.guessRank != guessRank:  | 
|                     GameWorld.ErrLog("ÒѾ´æÔڸþº²Â£¬µ«ÊDz»ÄÜÐ޸ľº²ÂÃû´Î£¬ÎÞ·¨¾º²Â! zoneID=%s,guessType=%s,tagPlayerID=%s, guessRank(%s) != guess.guessRank(%s)"   | 
|                          % (zoneID, guessType, tagPlayerID, guessRank, guess.guessRank), playerID)  | 
|                     return  | 
|             guessObj = guess  | 
|             GameWorld.Log("ÒѾ´æÔڸþº²Â£¬Íæ¼Ò½øÐмÓ×¢!  guessInfo=%s" % guess.GetString(), playerID)  | 
|         else:  | 
|             if guessType == 4:  | 
|                 if guess.guessRank == guessRank:  | 
|                     GameWorld.ErrLog("¸ÃÃû´ÎÒѾ¾º²ÂÁËÆäËûÍæ¼Ò£¬ÎÞ·¨Öظ´¾º²ÂͬһÃû´Î! zoneID=%s,guessType=%s,tagPlayerID=%s,guessRank=%s,ÒѾ¾º²Â¹ýµÄÍæ¼ÒID=%s"   | 
|                          % (zoneID, guessType, tagPlayerID, guessRank, guess.tagPlayerID), playerID)  | 
|                     return  | 
|                   | 
|     guessMoneyAlready = 0 if not guessObj else guessObj.moneyTotal # ÒѾ¾º²ÂµÄ¶î¶È  | 
|     if guessMoneyAlready + guessMoney > guessMoneyMax:  | 
|         GameWorld.ErrLog("³¬³ö×î´ó¿ÉͶע·ÝÊý¶î¶È£¬ÎÞ·¨¾º²Â! zoneID=%s,guessType=%s,tagPlayerID=%s,guessMoneyAlready=%s,guessMoney=%s,guessMoneyMax=%s"   | 
|                          % (zoneID, guessType, tagPlayerID, guessMoneyAlready, guessMoney, guessMoneyMax), playerID)  | 
|         return  | 
|       | 
|     syncPub = False # Í¬²½¹«¹²ÐÅÏ¢  | 
|     if not guessObj:  | 
|         if len(playerGuessList) >= guessTagPlayerCountMax:  | 
|             GameWorld.ErrLog("³¬³öÿ¸öÍæ¼Ò×î´ó¾º²ÂÈËÊý£¬ÎÞ·¨¾º²Â! zoneID=%s,guessType=%s,playerGuessListLen=%s >= guessTagPlayerCountMax=%s"   | 
|                              % (zoneID, guessType, len(playerGuessList), guessTagPlayerCountMax), playerID)  | 
|             return  | 
|         guessObj = ChampionshipGuess()  | 
|         guessObj.zoneID = zoneID  | 
|         guessObj.guessType = guessType  | 
|         guessObj.guessRank = guessRank  | 
|         guessObj.guessPlayerID = playerID  | 
|         guessObj.tagPlayerID = tagPlayerID  | 
|         guessObj.moneyTotal = 0 # Í¶×¢×Ü»õ±ÒÖµ  | 
|         playerGuessList.append(guessObj)  | 
|           | 
|         syncPub = True  | 
|         if guessType not in pkZoneMgr.supportCountInfo:  | 
|             pkZoneMgr.supportCountInfo[guessType] = {}  | 
|         playerSupportCountDict = pkZoneMgr.supportCountInfo[guessType]  | 
|         playerSupportCountDict[tagPlayerID] = playerSupportCountDict.get(tagPlayerID, 0) + 1  | 
|         superPlayerCount = playerSupportCountDict.get(tagPlayerID, 0)  | 
|         GameWorld.Log("¸üб»¾º²ÂÍæ¼ÒÖ§³ÖÈËÊýÖµ! zoneID=%s,guessType=%s,tagPlayerID=%s,superPlayerCount=%s"   | 
|                       % (zoneID, guessType, tagPlayerID, superPlayerCount), playerID)  | 
|           | 
|     guessObj.moneyTotal += guessMoney  | 
|     GameWorld.Log("¸üоº²Â! zoneID=%s,guessType=%s,tagPlayerID=%s,guessRank=%s,moneyTotal=%s"   | 
|                   % (zoneID, guessType, tagPlayerID, guessRank, guessObj.moneyTotal), playerID)  | 
|       | 
|     Send_CrossServerMsg_ChampionshipGuess(zoneID, playerID, guessObj, serverGroupID, msgData, syncPub=syncPub)  | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipWorship(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ¿ç·þÅÅλĤ°Ý  | 
|           | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     tagPlayerID = msgData["tagPlayerID"]  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     officialObj = offZoneMgr.GetPlayerOfficial(tagPlayerID)  | 
|     if not officialObj:  | 
|         GameWorld.ErrLog("¸Ã·ÖÇøÄ¿±êÍæ¼ÒûÓйÙÖ°£¬ÎÞ·¨Ä¤°Ý! zoneID=%s,tagPlayerID=%s" % (zoneID, tagPlayerID), playerID)  | 
|         return  | 
|     tagOfficialID = officialObj.officialID  | 
|     mainIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", tagOfficialID)  | 
|     if not mainIpyData:  | 
|         return  | 
|     juniorOfficialIDList = mainIpyData.GetJuniorOfficialIDList()  | 
|     if not juniorOfficialIDList:  | 
|         GameWorld.ErrLog("¸Ã¹ÙÖ°ÎÞϼ¶Ïɹ٣¬ÎÞ·¨Ä¤°Ý! zoneID=%s,tagPlayerID=%s,tagOfficialID=%s" % (zoneID, tagPlayerID, tagOfficialID), playerID)  | 
|         return  | 
|       | 
|     officialObj.worshipCount += 1  | 
|       | 
|     if officialObj.worshipDouble:  | 
|         msgData["worshipDouble"] = 1  | 
|               | 
|     syncOfficialIDList = [tagOfficialID]  | 
|     Send_CrossServerMsg_ChampionshipOfficial(zoneID, syncOfficialIDList, exData=msgData)  | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipOfficialApply(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ¿ç·þÅÅλÏɹÙÉêÇë  | 
|       | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     mainOfficialID = msgData["mainOfficialID"]  | 
|     officialID = msgData["officialID"]  | 
|     cancel = msgData["cancel"]  | 
|     PropData = msgData["PropData"]  | 
|       | 
|     if cancel:  | 
|         champMgr = GetChampionshipMgr()  | 
|         offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|         officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|         if not officialObj:  | 
|             return  | 
|         if playerID not in officialObj.applyPlayerInfo:  | 
|             GameWorld.ErrLog("²»ÔÚÏɹÙÉêÇëÁбíÀï! zoneID=%s,mainOfficialID=%s,officialID=%s" % (zoneID, mainOfficialID, officialID), playerID)  | 
|             return  | 
|         officialObj.applyPlayerInfo.pop(playerID, None)  | 
|         Send_CrossServerMsg_ChampionshipOfficial(zoneID, [officialID])  | 
|         return  | 
|       | 
|     mainIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", mainOfficialID)  | 
|     if not mainIpyData:  | 
|         return  | 
|     juniorOfficialIDList = mainIpyData.GetJuniorOfficialIDList()  | 
|     if officialID not in juniorOfficialIDList:  | 
|         GameWorld.ErrLog("ÉêÇë¹ÙÖ°ID·Ç¸Ã½çÖ÷ϼ¶¹ÙÖ°£¬ÎÞ·¨ÉêÇë! mainOfficialID=%s,officialID=%s not in %s"   | 
|                          % (mainOfficialID, officialID, juniorOfficialIDList), playerID)  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", officialID)  | 
|     if not ipyData:  | 
|         return  | 
|     canBeReplace = ipyData.GetCanBeReplace()  | 
|     if canBeReplace:  | 
|         GameWorld.ErrLog("¿É±»ÌôÕ½µÄ¹ÙÖ°ÎÞ·¨ÉêÇë! mainOfficialID=%s,officialID=%s" % (mainOfficialID, officialID), playerID)  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     mainOffObj = offZoneMgr.GetOfficialObj(mainOfficialID)  | 
|     officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|     if not mainOffObj or not officialObj:  | 
|         return  | 
|       | 
|     if not mainOffObj.playerID:  | 
|         GameWorld.Log("ÏɹÙËùÊô½çÖ÷ÎÞÍæ¼Ò£¬ÎÞ·¨ÉêÇë! zoneID=%s,mainOfficialID=%s,officialID=%s" % (zoneID, mainOfficialID, officialID), playerID)  | 
|         return  | 
|       | 
|     if officialObj.playerID:  | 
|         GameWorld.Log("ÏɹÙÒÑÓÐÍæ¼ÒÈÎÖ°£¬ÎÞ·¨ÉêÇë! zoneID=%s,mainOfficialID=%s,officialID=%s,offPlayerID=%s"   | 
|                       % (zoneID, mainOfficialID, officialID, officialObj.playerID), playerID)  | 
|         return  | 
|       | 
|     if playerID in officialObj.applyPlayerInfo:  | 
|         GameWorld.Log("ÒѾÉêÇë¹ý¸Ã¹ÙÖ°! zoneID=%s,mainOfficialID=%s,officialID=%s" % (zoneID, mainOfficialID, officialID), playerID)  | 
|         return  | 
|       | 
|     applyPlayerCountMax = IpyGameDataPY.GetFuncCfg("CrossChamOfficial", 1) # Ã¿¸ö¹ÙÖ°×î´óÉêÇëÍæ¼ÒÊý  | 
|     if applyPlayerCountMax and len(officialObj.applyPlayerInfo) >= applyPlayerCountMax:  | 
|         GameWorld.Log("¸Ã¹ÙÖ°ÒÑ´ïµ½×î´óÉêÇëÍæ¼ÒÊý! zoneID=%s,mainOfficialID=%s,officialID=%s,applyPlayerIDList=%s,applyPlayerCountMax=%s"   | 
|                       % (zoneID, mainOfficialID, officialID, officialObj.applyPlayerInfo.keys(), applyPlayerCountMax), playerID)  | 
|         PlayerControl.NotifyCodeCross(serverGroupID, playerID, "ChampionshipOfficialApplyFull")  | 
|         return  | 
|       | 
|     playerApplyOfficialIDList = []  | 
|     for offID in offZoneMgr.officialInfo.keys():  | 
|         offObj = offZoneMgr.GetOfficialObj(offID)  | 
|         if not offObj:  | 
|             continue  | 
|         if offObj.playerID == playerID:  | 
|             GameWorld.ErrLog("Íæ¼ÒÒѾÓÐÈÎÖ°¹ÙÖ°£¬ÎÞ·¨ÉêÇëÆäËû¹ÙÖ°! zoneID=%s,player officialID=%s" % (zoneID, offID), playerID)  | 
|             PlayerControl.NotifyCodeCross(serverGroupID, playerID, "ChampionshipAlreadyHasOfficial")  | 
|             return  | 
|         if playerID in offObj.applyPlayerInfo:  | 
|             playerApplyOfficialIDList.append(offID)  | 
|               | 
|     playerApplyCountMax = IpyGameDataPY.GetFuncCfg("CrossChamOfficial", 2) # Ã¿¸öÍæ¼Ò×î´ó¿ÉͬʱÉêÇë¹ÙÖ°Êý  | 
|     if playerApplyCountMax and len(playerApplyOfficialIDList) >= playerApplyCountMax:  | 
|         GameWorld.Log("Íæ¼ÒÒѴﵽͬʱÉêÇë¹ÙÖ°×î´óÊý! zoneID=%s,mainOfficialID=%s,officialID=%s,playerApplyOfficialIDList=%s,playerApplyCountMax=%s"   | 
|                       % (zoneID, mainOfficialID, officialID, playerApplyOfficialIDList, playerApplyCountMax), playerID)  | 
|         PlayerControl.NotifyCodeCross(serverGroupID, playerID, "ChampionshipOfficialApplyMax")  | 
|         return  | 
|       | 
|     # ¸üÐÂû½øÈë¿ç·þµÄÍæ¼Ò»º´æÐÅÏ¢  | 
|     PlayerViewCache.FindViewCache(playerID, True, PropData)  | 
|     officialObj.applyPlayerInfo[playerID] = PropData  | 
|       | 
|     Send_CrossServerMsg_ChampionshipOfficial(zoneID, [officialID])  | 
|       | 
|     PlayerControl.NotifyCodeCross(serverGroupID, playerID, "ChampionshipOfficialApplyOK")  | 
|     return  | 
|   | 
| #// C0 21 ¿ç·þÅÅλÏɹÙÉêÇë»ØÓ¦ #tagCGChampionshipOfficialApplyReply  | 
| #  | 
| #struct    tagCGChampionshipOfficialApplyReply  | 
| #{  | 
| #    tagHead        Head;  | 
| #    WORD        MainOfficialID;    //½çÖ÷¹ÙÖ°ID  | 
| #    WORD        OfficialID;    //ÉêÇë¹ÙÖ°ID  | 
| #    DWORD        PlayerID;        //ÉêÇëµÄÍæ¼ÒID  | 
| #    BYTE        IsOK;        //ÊÇ·ñͬÒ⣻1-ÊÇ£»0-·ñ  | 
| #};  | 
| def OnChampionshipOfficialApplyReply(index, clientData, tick):  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     mainOfficialID = clientData.MainOfficialID  | 
|     officialID = clientData.OfficialID  | 
|     applyPlayerID = clientData.PlayerID  | 
|     isOK = clientData.IsOK  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     zoneID = champMgr.GetPlayerOfficialZoneID(playerID)  | 
|     if not zoneID:  | 
|         return  | 
|       | 
|     sendMsg = {"zoneID":zoneID, "playerID":playerID, "mainOfficialID":mainOfficialID, "officialID":officialID,  | 
|                "applyPlayerID":applyPlayerID, "isOK":isOK}  | 
|     CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipOfficialApplyReply, sendMsg)  | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipOfficialApplyReply(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ¿ç·þÅÅλÏɹÙÉêÇë»ØÓ¦  | 
|       | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     mainOfficialID = msgData["mainOfficialID"]  | 
|     officialID = msgData["officialID"]  | 
|     applyPlayerID = msgData["applyPlayerID"]  | 
|     isOK = msgData["isOK"]  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     mainOffObj = offZoneMgr.GetOfficialObj(mainOfficialID)  | 
|     officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|     if not mainOffObj:  | 
|         return  | 
|     if not officialObj:  | 
|         return  | 
|       | 
|     if mainOffObj.playerID != playerID:  | 
|         GameWorld.ErrLog("·Ç½çÖ÷£¬ÎÞ·¨»ØÓ¦ÏɹÙÉêÇë! zoneID=%s,mainOfficialID=%s,mainOffPlayerID=%s"   | 
|                          % (zoneID, mainOfficialID, mainOffObj.playerID), playerID)  | 
|         return  | 
|       | 
|     if applyPlayerID not in officialObj.applyPlayerInfo:  | 
|         GameWorld.Log("Íæ¼ÒûÓÐÔÚ¸ÃÏɹÙÉêÇëÁбíÀ²»ÐèÒª»ØÓ¦! zoneID=%s,mainOfficialID=%s,officialID=%s,applyPlayerID=%s not in applyPlayerIDList=%s"   | 
|                       % (zoneID, mainOfficialID, officialID, applyPlayerID, officialObj.applyPlayerInfo.keys()), playerID)  | 
|         return  | 
|       | 
|     replyDict = {applyPlayerID:isOK} # »ØÓ¦½á¹û {playerID:isOK, ...}  | 
|     syncOfficialIDList = [officialID]  | 
|     officialObj.applyPlayerInfo.pop(applyPlayerID)  | 
|       | 
|     # Í¬Òâ  | 
|     if isOK:  | 
|         applyPlayerOffID = 0  | 
|         # ÒƳý¸ÃÍæ¼ÒµÄÆäËûÏɹÙÉêÇë  | 
|         for offID in offZoneMgr.officialInfo.keys():  | 
|             offObj = offZoneMgr.GetOfficialObj(offID)  | 
|             if not offObj:  | 
|                 continue  | 
|               | 
|             if offObj.playerID == applyPlayerID:  | 
|                 applyPlayerOffID = offID  | 
|                 syncOfficialIDList.append(offID)  | 
|                   | 
|             if applyPlayerID in offObj.applyPlayerInfo:  | 
|                 offObj.applyPlayerInfo.pop(applyPlayerID)  | 
|                 syncOfficialIDList.append(offID)  | 
|                   | 
|         if applyPlayerOffID:  | 
|             GameWorld.ErrLog("ͬÒâÍæ¼Ò¹ÙÖ°ÉêÇëʱ£¬ÉêÇë¹ÙÖ°Íæ¼ÒÒѾÈÎÖ°ÆäËû¹ÙÖ°£¬²»´¦Àí£¡ zoneID=%s,applyPlayerID=%s,applyPlayerOffID=%s"   | 
|                              % (zoneID, applyPlayerID, applyPlayerOffID), playerID)  | 
|         else:  | 
|             officialObj.playerID = applyPlayerID  | 
|             # Ä¬ÈϾܾøÆäËûÉêÇëÕß  | 
|             for refusePlayerID in officialObj.applyPlayerInfo.keys():  | 
|                 replyDict[refusePlayerID] = 0  | 
|             officialObj.applyPlayerInfo = {}  | 
|     else:  | 
|         pass  | 
|       | 
|     exData = {"exDataType":"OfficialApplyReply", "mainPlayerName":mainOffObj.playerName, "replyDict":replyDict,  | 
|               "mainOfficialID":mainOfficialID, "officialID":officialID}  | 
|     Send_CrossServerMsg_ChampionshipOfficial(zoneID, syncOfficialIDList, exData=exData)  | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipOfficialChallenge(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ÏɹÙÌôÕ½  | 
|       | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     mainOfficialID = msgData["mainOfficialID"]  | 
|     officialID = msgData["officialID"]  | 
|     tagPlayerID = msgData["tagPlayerID"]  | 
|     PropData = msgData["PropData"]  | 
|       | 
|     if playerID == tagPlayerID:  | 
|         GameWorld.ErrLog("ÌôÕ½Ïɹٲ»ÄÜÌôÕ½×Ô¼º! mainOfficialID=%s,officialID=%s" % (mainOfficialID, officialID), playerID)  | 
|         return  | 
|       | 
|     mainIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", mainOfficialID)  | 
|     if not mainIpyData:  | 
|         return  | 
|     juniorOfficialIDList = mainIpyData.GetJuniorOfficialIDList()  | 
|     if officialID not in juniorOfficialIDList:  | 
|         GameWorld.ErrLog("ÉêÇë¹ÙÖ°ID·Ç¸Ã½çÖ÷ϼ¶¹ÙÖ°£¬ÎÞ·¨ÌôÕ½! mainOfficialID=%s,officialID=%s not in %s"   | 
|                          % (mainOfficialID, officialID, juniorOfficialIDList), playerID)  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", officialID)  | 
|     if not ipyData:  | 
|         return  | 
|     canBeReplace = ipyData.GetCanBeReplace()  | 
|     if not canBeReplace:  | 
|         GameWorld.ErrLog("¸ÃÏɹÙÎÞ·¨±»ÌôÕ½Ìæ»»! mainOfficialID=%s,officialID=%s" % (mainOfficialID, officialID), playerID)  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     mainOffObj = offZoneMgr.GetOfficialObj(mainOfficialID)  | 
|     officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|     if not mainOffObj or not officialObj:  | 
|         return  | 
|       | 
|     if not mainOffObj.playerID:  | 
|         GameWorld.Log("ÏɹÙËùÊô½çÖ÷ÎÞÍæ¼Ò£¬ÎÞ·¨ÌôÕ½! zoneID=%s,mainOfficialID=%s,officialID=%s" % (zoneID, mainOfficialID, officialID), playerID)  | 
|         return  | 
|       | 
|     for offID in offZoneMgr.officialInfo.keys():  | 
|         offObj = offZoneMgr.GetOfficialObj(offID)  | 
|         if not offObj:  | 
|             continue  | 
|         if offObj.playerID == playerID:  | 
|             GameWorld.ErrLog("Íæ¼ÒÒѾÓÐÈÎÖ°¹ÙÖ°£¬ÎÞ·¨ÌôÕ½ÆäËû¹ÙÖ°!  zoneID=%s, player officialID=%s" % (zoneID, offID), playerID)  | 
|             PlayerControl.NotifyCodeCross(serverGroupID, playerID, "ChampionshipAlreadyHasOfficial")  | 
|             return  | 
|           | 
|     Ret = 0 # ÌôÕ½½á¹û£»0-ʧ°Ü£»1-»ñʤ£»2-Ä¿±êÏɹÙÍæ¼ÒIDÒѱä¸ü£¬¿ÉˢкóÖØÊÔ  | 
|     offPlayerID = officialObj.playerID  | 
|     if not offPlayerID:  | 
|         GameWorld.Log("ÌôսĿ±êÏɹÙÎÞÍæ¼ÒÈÎÖ°£¬Ö±½Ó»ñʤ! zoneID=%s,mainOfficialID=%s,officialID=%s" % (zoneID, mainOfficialID, officialID), playerID)  | 
|         Ret = 1  | 
|     elif offPlayerID != tagPlayerID:  | 
|         GameWorld.Log("ÌôսĿ±êÏɹÙÍæ¼ÒIDÒѱä¸ü£¬ÐèҪˢкóÖØÐÂÌôÕ½! zoneID=%s,mainOfficialID=%s,officialID=%s,offPlayerID(%s) != tagPlayerID(%s)"   | 
|                       % (zoneID, mainOfficialID, officialID, offPlayerID, tagPlayerID), playerID)  | 
|         Ret = 2  | 
|     else:  | 
|         fightPower = PropData.get("FightPower", 0)  | 
|         tagFightPower = officialObj.fightPower  | 
|         Ret = 1 if fightPower > tagFightPower else 0  | 
|         GameWorld.Log("ÌôսĿ±êÏɹÙÍæ¼ÒID½á¹û! zoneID=%s,mainOfficialID=%s,officialID=%s,fightPower=%s,tagFightPower=%s,tagPlayerID=%s,Ret=%s"   | 
|                       % (zoneID, mainOfficialID, officialID, fightPower, tagFightPower, tagPlayerID, Ret), playerID)  | 
|           | 
|     syncOfficialIDList = [officialID]  | 
|     playerName = PropData.get("Name", str(playerID))  | 
|     # ÔÝʱֻ¼Ç¼ÌôսʤÀûµÄ  | 
|     if Ret == 1:  | 
|         officialObj.challengeList.append({"Time":int(time.time()), "Ret":Ret,  | 
|                                           "Name":playerName,  | 
|                                           "AccID":PropData.get("AccID", ""),  | 
|                                           })  | 
|         # Ö»±£Áô×î½ü5Ìõ¼þ¼Ç¼  | 
|         if len(officialObj.challengeList) > 5:  | 
|             officialObj.challengeList.pop(0)  | 
|               | 
|         # ¸üÐÂû½øÈë¿ç·þµÄÍæ¼Ò»º´æÐÅÏ¢  | 
|         PlayerViewCache.FindViewCache(playerID, True, PropData)  | 
|           | 
|         # ¸üÐÂÈÎÖ°Íæ¼ÒID  | 
|         officialObj.ResetPlayer()  | 
|         officialObj.playerID = playerID  | 
|           | 
|         # ÒƳý¸ÃÍæ¼ÒµÄÆäËûÏɹÙÉêÇë  | 
|         for offID in offZoneMgr.officialInfo.keys():  | 
|             offObj = offZoneMgr.GetOfficialObj(offID)  | 
|             if not offObj:  | 
|                 continue  | 
|             if playerID in offObj.applyPlayerInfo:  | 
|                 offObj.applyPlayerInfo.pop(playerID)  | 
|                 syncOfficialIDList.append(offID)  | 
|                   | 
|         # Óʼþ֪ͨ¶Ô·½£¬¹ÙÖ°±»ÌôÕ½ÁË  | 
|         if offPlayerID:  | 
|             PlayerCompensation.SendMailByKey("CrossChampionshipOfficialBeChallenge", [offPlayerID], [], [playerName, officialID], crossMail=True)  | 
|               | 
|     exData = {"exDataType":"OfficialChallenge", "playerID":playerID, "tagPlayerName":officialObj.playerName,  | 
|               "mainOfficialID":mainOfficialID, "officialID":officialID, "Ret":Ret}  | 
|     Send_CrossServerMsg_ChampionshipOfficial(zoneID, syncOfficialIDList, exData=exData)  | 
|     return  | 
|   | 
| #// C0 23 ¿ç·þÅÅλÏɹÙÌôÕ½¼Ç¼²éѯ #tagCGChampionshipOfficialChallengeQuery  | 
| #  | 
| #struct    tagCGChampionshipOfficialChallengeQuery  | 
| #{  | 
| #    tagHead        Head;  | 
| #    WORD        MainOfficialID;    //½çÖ÷¹ÙÖ°ID  | 
| #    WORD        OfficialID;    //²éѯ¹ÙÖ°ID  | 
| #};  | 
| def OnChampionshipOfficialChallengeQuery(index, clientData, tick):  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     mainOfficialID = clientData.MainOfficialID  | 
|     officialID = clientData.OfficialID  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     zoneID = champMgr.GetPlayerOfficialZoneID(playerID)  | 
|     if not zoneID:  | 
|         return  | 
|       | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|     challengeList = officialObj.challengeList if officialObj else []  | 
|       | 
|     clientPack = ChPyNetSendPack.tagGCChampionshipOfficialChallengeRecordInfo()  | 
|     clientPack.ZoneID = zoneID  | 
|     clientPack.MainOfficialID = mainOfficialID  | 
|     clientPack.OfficialID = officialID  | 
|     clientPack.RecordList = []  | 
|     for challengeDict in challengeList:  | 
|         recordPack = ChPyNetSendPack.tagGCChampionshipOfficialChallengeRecord()  | 
|         recordPack.PlayerName = challengeDict.get("Name", "")  | 
|         recordPack.NameLen = len(recordPack.PlayerName)  | 
|         recordPack.ChallengeTime = challengeDict.get("Time", 0)  | 
|         recordPack.Ret = challengeDict.get("Ret", 0)  | 
|         clientPack.RecordList.append(recordPack)  | 
|     clientPack.RecordCount = len(clientPack.RecordList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| #// C0 24 ¿ç·þÅÅλ´ÇÍËϼ¶Ïɹ٠#tagCGChampionshipOfficialKick  | 
| #  | 
| #struct    tagCGChampionshipOfficialKick  | 
| #{  | 
| #    tagHead        Head;  | 
| #    WORD        MainOfficialID;    //½çÖ÷¹ÙÖ°ID  | 
| #    WORD        OfficialID;    //Ä¿±ê¹ÙÖ°ID  | 
| #    DWORD        PlayerID;        //Ä¿±êÍæ¼ÒID  | 
| #};  | 
| def OnChampionshipOfficialKick(index, clientData, tick):  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     mainOfficialID = clientData.MainOfficialID  | 
|     officialID = clientData.OfficialID  | 
|     tagPlayerID = clientData.PlayerID  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     zoneID = champMgr.GetPlayerOfficialZoneID(playerID)  | 
|     if not zoneID:  | 
|         return  | 
|       | 
|     sendMsg = {"zoneID":zoneID, "playerID":playerID, "mainOfficialID":mainOfficialID, "officialID":officialID,  | 
|                "tagPlayerID":tagPlayerID, "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer)}  | 
|     CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipOfficialKick, sendMsg)  | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipOfficialKick(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ¿ç·þÅÅλ´ÇÍËϼ¶Ïɹ٠ | 
|       | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     playerName = msgData["playerName"]  | 
|     mainOfficialID = msgData["mainOfficialID"]  | 
|     officialID = msgData["officialID"]  | 
|     tagPlayerID = msgData["tagPlayerID"]  | 
|       | 
|     mainIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", mainOfficialID)  | 
|     if not mainIpyData:  | 
|         return  | 
|     juniorOfficialIDList = mainIpyData.GetJuniorOfficialIDList()  | 
|     if officialID not in juniorOfficialIDList:  | 
|         GameWorld.ErrLog("¹ÙÖ°ID·Ç¸Ã½çÖ÷ϼ¶¹ÙÖ°£¬ÎÞ·¨´ÇÍË! mainOfficialID=%s,officialID=%s not in %s"   | 
|                          % (mainOfficialID, officialID, juniorOfficialIDList), playerID)  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     mainOffObj = offZoneMgr.GetOfficialObj(mainOfficialID)  | 
|     officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|     if not mainOffObj:  | 
|         return  | 
|     if not officialObj:  | 
|         return  | 
|       | 
|     if mainOffObj.playerID != playerID:  | 
|         GameWorld.ErrLog("·Ç½çÖ÷£¬ÎÞ·¨´ÇÍËϼ¶ÏɹÙ! zoneID=%s,mainOfficialID=%s,mainOffPlayerID=%s"   | 
|                          % (zoneID, mainOfficialID, mainOffObj.playerID), playerID)  | 
|         return  | 
|       | 
|     if not officialObj.playerID or officialObj.playerID != tagPlayerID:  | 
|         GameWorld.Log("µ±Ç°ÏɹÙÍæ¼ÒID·ÇÄ¿±êÍæ¼ÒID£¬ÎÞ·¨´ÇÍË! zoneID=%s,mainOfficialID=%s,officialID=%s,offPlayerID(%s) != tagPlayerID(%s)"   | 
|                       % (zoneID, mainOfficialID, officialID, officialObj.playerID, tagPlayerID), playerID)  | 
|         return  | 
|       | 
|     kickCD = IpyGameDataPY.GetFuncCfg("CrossChamOfficial", 4) # ´ÇÍËϼ¶Ïɹٹ«¹²CD£¬Ãë  | 
|     if kickCD:  | 
|         curTime = int(time.time())  | 
|         passSeconds = curTime - mainOffObj.lastDismissJuniorTime  | 
|         if passSeconds < kickCD:  | 
|             GameWorld.ErrLog("½çÖ÷´ÇÍËϼ¶ÏɹÙCDÖÐ! zoneID=%s,mainOfficialID=%s,passSeconds(%s) < %s"   | 
|                              % (zoneID, mainOfficialID, passSeconds, kickCD), playerID)  | 
|             return  | 
|         mainOffObj.lastDismissJuniorTime = curTime  | 
|           | 
|     officialObj.ResetPlayer() # ´ÇÍËÖØÖÃ  | 
|       | 
|     if tagPlayerID:  | 
|         # Óʼþ֪ͨ¶Ô·½£¬¹ÙÖ°±»´ÇÍËÁË  | 
|         PlayerCompensation.SendMailByKey("CrossChampionshipOfficialBeKick", [tagPlayerID], [], [playerName, officialID], crossMail=True)  | 
|           | 
|     syncOfficialIDList = [mainOfficialID, officialID]  | 
|     Send_CrossServerMsg_ChampionshipOfficial(zoneID, syncOfficialIDList)  | 
|     return  | 
|   | 
|   | 
| #// C0 25 ¿ç·þÅÅλÖ÷¶¯ÀëÈÎÏɹ٠#tagCGChampionshipOfficialLeave  | 
| #  | 
| #struct    tagCGChampionshipOfficialLeave  | 
| #{  | 
| #    tagHead        Head;  | 
| #    WORD        MainOfficialID;    //½çÖ÷¹ÙÖ°ID  | 
| #    WORD        OfficialID;    //ÀëÈιÙÖ°ID  | 
| #};  | 
| def OnChampionshipOfficialLeave(index, clientData, tick):  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     mainOfficialID = clientData.MainOfficialID  | 
|     officialID = clientData.OfficialID  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     zoneID = champMgr.GetPlayerOfficialZoneID(playerID)  | 
|     if not zoneID:  | 
|         return  | 
|       | 
|     sendMsg = {"zoneID":zoneID, "playerID":playerID, "mainOfficialID":mainOfficialID, "officialID":officialID}  | 
|     CrossRealmMsg.SendMsgToCrossServer(ShareDefine.ClientServerMsg_ChampionshipOfficialLeave, sendMsg)  | 
|     return  | 
|   | 
| def ClientServerMsg_ChampionshipOfficialLeave(serverGroupID, msgData):  | 
|     ## ÊÕµ½×Ó·þÐÅÏ¢ - ¿ç·þÅÅλÖ÷¶¯ÀëÈÎÏɹ٠ | 
|       | 
|     zoneID = msgData["zoneID"]  | 
|     playerID = msgData["playerID"]  | 
|     mainOfficialID = msgData["mainOfficialID"]  | 
|     officialID = msgData["officialID"]  | 
|       | 
|     mainIpyData = IpyGameDataPY.GetIpyGameData("ChampionshipOfficial", mainOfficialID)  | 
|     if not mainIpyData:  | 
|         return  | 
|     juniorOfficialIDList = mainIpyData.GetJuniorOfficialIDList()  | 
|     if officialID not in juniorOfficialIDList:  | 
|         GameWorld.ErrLog("¹ÙÖ°ID·Ç¸Ã½çÖ÷ϼ¶¹ÙÖ°£¬ÎÞ·¨Ö÷¶¯ÀëÈÎÏɹÙ! mainOfficialID=%s,officialID=%s not in %s"   | 
|                          % (mainOfficialID, officialID, juniorOfficialIDList), playerID)  | 
|         return  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     officialObj = offZoneMgr.GetOfficialObj(officialID)  | 
|     if not officialObj:  | 
|         return  | 
|       | 
|     if not officialObj.playerID or officialObj.playerID != playerID:  | 
|         GameWorld.Log("·Ç±¾ÏɹÙÍæ¼ÒID£¬ÎÞ·¨Ö÷¶¯ÀëÈÎÏɹÙ! zoneID=%s,mainOfficialID=%s,officialID=%s,offPlayerID(%s) != playerID(%s)"   | 
|                       % (zoneID, mainOfficialID, officialID, officialObj.playerID, playerID), playerID)  | 
|         return  | 
|       | 
|     officialObj.ResetPlayer() # ÀëÈÎÖØÖà  | 
|       | 
|     syncOfficialIDList = [officialID]  | 
|     Send_CrossServerMsg_ChampionshipOfficial(zoneID, syncOfficialIDList)  | 
|     return  | 
|   | 
| def Sync_ChampionshipPKZoneGroupInfo(zoneID, groupMarkDict=None, curPlayer=None):  | 
|     ## Í¬²½ÅÅλ·ÖÇø·Ö×éÐÅÏ¢  | 
|     # @param groupMarkDict: {groupMark:[battleNum, ...], ...}  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     if curPlayer:  | 
|         playerZoneID = champMgr.GetPlayerPKZoneID(curPlayer.GetPlayerID())  | 
|         if playerZoneID != zoneID:  | 
|             return  | 
|         if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|             return  | 
|           | 
|     pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|     if not pkZoneMgr:  | 
|         return  | 
|       | 
|     if groupMarkDict == None:  | 
|         groupMarkDict = {}  | 
|         for groupMark, groupDict in pkZoneMgr.battleInfo.items():  | 
|             groupMarkDict[groupMark] = groupDict.keys()  | 
|         playerIDList = pkZoneMgr.GetBatPlayerIDList()  | 
|     else:  | 
|         playerIDList = []  | 
|         for groupMark, battleNumList in groupMarkDict.items():  | 
|             for battleNum in battleNumList:  | 
|                 battleObj = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|                 if not battleObj:  | 
|                     continue  | 
|                 if battleObj.playerIDA not in playerIDList:  | 
|                     playerIDList.append(battleObj.playerIDA)  | 
|                 if battleObj.playerIDB not in playerIDList:  | 
|                     playerIDList.append(battleObj.playerIDB)  | 
|                       | 
|     clientPack = ChPyNetSendPack.tagGCCrossChampionshipPKZoneGroupInfo()  | 
|     clientPack.ActID = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipID)  | 
|     clientPack.StateError = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_CrossChampionshipStateError)  | 
|     clientPack.ZoneID = zoneID  | 
|     clientPack.GroupList = []  | 
|     for groupMark, battleNumList in groupMarkDict.items():  | 
|         groupPack = ChPyNetSendPack.tagGCCrossChampionshipPKGroup()  | 
|         groupPack.GroupMark = groupMark  | 
|         groupPack.BattleList = []  | 
|         for battleNum in battleNumList:  | 
|             battleObj = pkZoneMgr.GetBattle(groupMark, battleNum)  | 
|             if not battleObj:  | 
|                 continue  | 
|             battlePack = ChPyNetSendPack.tagGCCrossChampionshipPKBattle()  | 
|             battlePack.BattleNum = battleNum  | 
|             battlePack.WinPlayerID = battleObj.winPlayerID  | 
|             battlePack.PlayerIDA = battleObj.playerIDA  | 
|             battlePack.PlayerIDB = battleObj.playerIDB  | 
|             groupPack.BattleList.append(battlePack)  | 
|         groupPack.BattleCount = len(groupPack.BattleList)  | 
|         clientPack.GroupList.append(groupPack)  | 
|     clientPack.GroupCount = len(clientPack.GroupList)  | 
|       | 
|     clientPack.PlayerList = []  | 
|     for playerID in playerIDList:  | 
|         batPlayer = pkZoneMgr.GetBatPlayer(playerID)  | 
|         if not batPlayer:  | 
|             continue  | 
|         playerPack = ChPyNetSendPack.tagGCCrossChampionshipPKPlayer()  | 
|         playerPack.PlayerID = playerID  | 
|         playerPack.PlayerName = batPlayer.playerName  | 
|         playerPack.NameLen = len(playerPack.PlayerName)  | 
|         playerPack.Job = batPlayer.job  | 
|         playerPack.LV = batPlayer.lv  | 
|         playerPack.FightPower = batPlayer.fightPower % ShareDefine.Def_PerPointValue  | 
|         playerPack.FightPowerEx = batPlayer.fightPower / ShareDefine.Def_PerPointValue  | 
|         playerPack.RealmLV = batPlayer.realmLV  | 
|         clientPack.PlayerList.append(playerPack)  | 
|     clientPack.PlayerCount = len(clientPack.PlayerList)  | 
|       | 
|     if curPlayer != None:  | 
|         NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     else:  | 
|         playerManager = GameWorld.GetPlayerManager()  | 
|         for i in xrange(playerManager.GetPlayerCount()):  | 
|             curPlayer = playerManager.GetPlayerByIndex(i)  | 
|             if curPlayer == None or not curPlayer.GetInitOK():  | 
|                 continue  | 
|             playerZoneID = champMgr.GetPlayerPKZoneID(curPlayer.GetPlayerID())  | 
|             if playerZoneID != zoneID:  | 
|                 continue  | 
|             if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|                 continue  | 
|             NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|               | 
|     return  | 
|   | 
| def Sync_ChampionshipGuessPriInfo(curPlayer, syncKeyInfo=None):  | 
|     ## Í¬²½ÅÅλ·ÖÇø¾º²Â¸öÈËÐÅÏ¢  | 
|     # @param syncKeyInfo: Ö¸¶¨Í¬²½µÄ {guessType:[tagPlayerID, ...], ...}  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     champMgr = GetChampionshipMgr()  | 
|     playerZoneID = champMgr.GetPlayerPKZoneID(playerID)  | 
|     if not playerZoneID:  | 
|         return  | 
|     if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|         return  | 
|       | 
|     pkZoneMgr = champMgr.GetChampPKZoneMgr(playerZoneID)  | 
|     if not pkZoneMgr:  | 
|         return  | 
|       | 
|     clientPack = ChPyNetSendPack.tagGCChampionshipGuessPriInfo()  | 
|     clientPack.ZoneID = playerZoneID  | 
|     clientPack.GuessList = []  | 
|       | 
|     for guessType, playerGuessDict in pkZoneMgr.guessInfo.items():  | 
|         if syncKeyInfo and guessType not in syncKeyInfo:  | 
|             continue  | 
|         syncTagPlayerIDList = [] if not syncKeyInfo else syncKeyInfo.get(guessType, [])  | 
|           | 
|         priListPack = ChPyNetSendPack.tagGCChampionshipGuessPriList()  | 
|         priListPack.GuessType = guessType  | 
|         priListPack.GuessPlayerList = []  | 
|           | 
|         playerGuessList = playerGuessDict.get(playerID, [])  | 
|         for guess in playerGuessList:  | 
|             tagPlayerID = guess.tagPlayerID  | 
|             if syncTagPlayerIDList and tagPlayerID not in syncTagPlayerIDList:  | 
|                 continue  | 
|             priPlayerPack = ChPyNetSendPack.tagGCChampionshipGuessPlayerPri()  | 
|             priPlayerPack.PlayerID = tagPlayerID  | 
|             priPlayerPack.MoneyTotal = guess.moneyTotal  | 
|             priPlayerPack.GuessRank = guess.guessRank  | 
|             priListPack.GuessPlayerList.append(priPlayerPack)  | 
|         priListPack.PlayerCount = len(priListPack.GuessPlayerList)  | 
|           | 
|         clientPack.GuessList.append(priListPack)  | 
|           | 
|     clientPack.Count = len(clientPack.GuessList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def Sync_ChampionshipGuessPubInfo(zoneID, curPlayer=None, syncKeyInfo=None):  | 
|     ## Í¬²½ÅÅλ·ÖÇø¾º²Â¹«¹²ÐÅÏ¢  | 
|     # @param syncKeyInfo: Ö¸¶¨Í¬²½µÄ {guessType:[tagPlayerID, ...], ...}  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     if curPlayer:  | 
|         playerZoneID = champMgr.GetPlayerPKZoneID(curPlayer.GetPlayerID())  | 
|         if playerZoneID != zoneID:  | 
|             return  | 
|         if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|             return  | 
|           | 
|     pkZoneMgr = champMgr.GetChampPKZoneMgr(zoneID)  | 
|     if not pkZoneMgr:  | 
|         return  | 
|       | 
|     # ¹«¹²¾º²ÂÐÅÏ¢  | 
|     clientPack = ChPyNetSendPack.tagGCChampionshipGuessPubInfo()  | 
|     clientPack.ZoneID = zoneID  | 
|     clientPack.GuessList = []  | 
|       | 
|     for guessType, playerSupportCountDict in pkZoneMgr.supportCountInfo.items():  | 
|         if syncKeyInfo and guessType not in syncKeyInfo:  | 
|             continue  | 
|         syncTagPlayerIDList = [] if not syncKeyInfo else syncKeyInfo.get(guessType, [])  | 
|           | 
|         pubListPack = ChPyNetSendPack.tagGCChampionshipGuessPubList()  | 
|         pubListPack.GuessType = guessType  | 
|         pubListPack.GuessPlayerList = []  | 
|           | 
|         for tagPlayerID, supportCount in playerSupportCountDict.items():  | 
|             if syncTagPlayerIDList and tagPlayerID not in syncTagPlayerIDList:  | 
|                 continue  | 
|             pubPlayerPack = ChPyNetSendPack.tagGCChampionshipGuessPlayerPub()  | 
|             pubPlayerPack.PlayerID = tagPlayerID  | 
|             pubPlayerPack.SupportCount = supportCount  | 
|             pubListPack.GuessPlayerList.append(pubPlayerPack)  | 
|         pubListPack.PlayerCount = len(pubListPack.GuessPlayerList)  | 
|           | 
|         clientPack.GuessList.append(pubListPack)  | 
|                   | 
|     clientPack.Count = len(clientPack.GuessList)  | 
|       | 
|     if curPlayer != None:  | 
|         NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     else:  | 
|         playerManager = GameWorld.GetPlayerManager()  | 
|         for i in xrange(playerManager.GetPlayerCount()):  | 
|             curPlayer = playerManager.GetPlayerByIndex(i)  | 
|             if curPlayer == None or not curPlayer.GetInitOK():  | 
|                 continue  | 
|             playerZoneID = champMgr.GetPlayerPKZoneID(curPlayer.GetPlayerID())  | 
|             if playerZoneID != zoneID:  | 
|                 continue  | 
|             if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|                 continue  | 
|             NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def Sync_ChampionshipOfficialInfo(zoneID, officialIDList=None, curPlayer=None):  | 
|     ## Í¬²½ÅÅλ·ÖÇø¹ÙÖ°ÐÅÏ¢  | 
|     # @param officialIDList: [officialID, ...]  | 
|       | 
|     champMgr = GetChampionshipMgr()  | 
|     if curPlayer:  | 
|         playerZoneID = champMgr.GetPlayerOfficialZoneID(curPlayer.GetPlayerID())  | 
|         if playerZoneID != zoneID:  | 
|             return  | 
|         if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|             return  | 
|           | 
|     clientPack = ChPyNetSendPack.tagGCChampionshipOfficialInfo()  | 
|     clientPack.ZoneID = zoneID  | 
|     clientPack.OfficialList = []  | 
|       | 
|     offZoneMgr = champMgr.GetChampOfficialZoneMgr(zoneID)  | 
|     if officialIDList == None:  | 
|         officialIDList = offZoneMgr.officialInfo.keys()  | 
|           | 
|     for officialID in officialIDList:  | 
|         offObj = offZoneMgr.GetOfficialObj(officialID)  | 
|         if not offObj:  | 
|             continue  | 
|         offPlayer = ChPyNetSendPack.tagGCChampionshipOfficialPlayer()  | 
|         offPlayer.PlayerID = offObj.playerID  | 
|         offPlayer.PlayerName = offObj.playerName  | 
|         offPlayer.NameLen = len(offPlayer.PlayerName)  | 
|         offPlayer.Job = offObj.job  | 
|         offPlayer.LV = offObj.lv  | 
|         offPlayer.FightPower = offObj.fightPower % ShareDefine.Def_PerPointValue  | 
|         offPlayer.FightPowerEx = offObj.fightPower / ShareDefine.Def_PerPointValue  | 
|         offPlayer.RealmLV = offObj.realmLV  | 
|           | 
|         offPack = ChPyNetSendPack.tagGCChampionshipOfficial()  | 
|         offPack.OfficialID = officialID  | 
|         offPack.LastDismissJuniorTime = offObj.lastDismissJuniorTime  | 
|         offPack.WorshipCount = offObj.worshipCount  | 
|         offPack.WorshipDouble = offObj.worshipDouble  | 
|         offPack.OfficialPlayer = offPlayer  | 
|         offPack.ApplyPlayerList = []  | 
|         for applyPlayerID, playerInfo in offObj.applyPlayerInfo.items():  | 
|             applyPlayer = ChPyNetSendPack.tagGCChampionshipOfficialPlayer()  | 
|             applyPlayer.PlayerID = applyPlayerID  | 
|             applyPlayer.PlayerName = playerInfo.get("Name", "")  | 
|             applyPlayer.NameLen = len(applyPlayer.PlayerName)  | 
|             applyPlayer.Job = playerInfo.get("Job", 1)  | 
|             applyPlayer.LV = playerInfo.get("LV", 1)  | 
|             fightPower = playerInfo.get("FightPower", 0)  | 
|             applyPlayer.FightPower = fightPower % ShareDefine.Def_PerPointValue  | 
|             applyPlayer.FightPowerEx = fightPower / ShareDefine.Def_PerPointValue  | 
|             applyPlayer.RealmLV = playerInfo.get("RealmLV", 1)  | 
|               | 
|             offPack.ApplyPlayerList.append(applyPlayer)  | 
|         offPack.ApplyPlayerCount = len(offPack.ApplyPlayerList)  | 
|         clientPack.OfficialList.append(offPack)  | 
|           | 
|     clientPack.OfficialCount = len(clientPack.OfficialList)  | 
|       | 
|     if curPlayer != None:  | 
|         NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     else:  | 
|         playerManager = GameWorld.GetPlayerManager()  | 
|         for i in xrange(playerManager.GetPlayerCount()):  | 
|             curPlayer = playerManager.GetPlayerByIndex(i)  | 
|             if curPlayer == None or not curPlayer.GetInitOK():  | 
|                 continue  | 
|             playerZoneID = champMgr.GetPlayerOfficialZoneID(curPlayer.GetPlayerID())  | 
|             if playerZoneID != zoneID:  | 
|                 continue  | 
|             if not PlayerControl.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Championship):  | 
|                 continue  | 
|             NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|               | 
|     return  | 
|   | 
| def DR_CrossChampionshipPK(eventName, dataDict={}):  | 
|     drDataDict = {}  | 
|     drDataDict.update(dataDict)  | 
|     DataRecordPack.SendEventPack("CrossChampionship_%s" % eventName, drDataDict)  | 
|     return  | 
|   |