| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerCrossRealmPK  | 
| #  | 
| # @todo:¿ç·þPK¾º¼¼³¡  | 
| # @author hxp  | 
| # @date 2018-12-21  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ¿ç·þPK¾º¼¼³¡  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2018-12-21 18:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import ShareDefine  | 
| import PlayerControl  | 
| import NetPackCommon  | 
| import IpyGameDataPY  | 
| import PlayerActivity  | 
| import ChPyNetSendPack  | 
| import CrossRealmPlayer  | 
| import FunctionNPCCommon  | 
| import DataRecordPack  | 
| import PlayerWeekParty  | 
| import IPY_GameWorld  | 
| import ItemControler  | 
| import PlayerSuccess  | 
| import ItemCommon  | 
| import GameWorld  | 
| import ChConfig  | 
|   | 
| ## ÊÇ·ñÆ¥ÅäÖÐ  | 
| def SetIsCrossPKMatching(curPlayer, isMatching):  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_IsCrossPKMatching, isMatching)  | 
|     return  | 
| def GetIsCrossPKMatching(curPlayer):  | 
|     return curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_IsCrossPKMatching) and IsCrossRealmPKMatchState()  | 
|   | 
| def DoPlayerOnDay(curPlayer):  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|     totalScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)  | 
|     if not totalScore:  | 
|         return  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_OnDayScore, totalScore)  | 
|       | 
|     zoneID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ZoneID)  | 
|     seasonID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonID)  | 
|       | 
|     # Óʼþ·¢·ÅδÁìÈ¡µÄÿÈÕPK´ÎÊý½±Àø  | 
|     dayPKCountAwardDict = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKAward", 1, {})  | 
|     dayPKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)  | 
|     dayPKCountAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DayPKCountAwardState)  | 
|     SendDayPKAwardByMail(curPlayer, zoneID, seasonID, "PKCount", dayPKCount, dayPKCountAwardState, dayPKCountAwardDict, "CrossServer1")  | 
|       | 
|     # Óʼþ·¢·ÅδÁìÈ¡µÄÿÈÕʤÀû´ÎÊý½±Àø  | 
|     dayWinCountAwardDict = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKAward", 2, {})  | 
|     dayWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayWinCount)  | 
|     dayWinCountAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DayWinCountAwardState)  | 
|     SendDayPKAwardByMail(curPlayer, zoneID, seasonID, "WinCount", dayWinCount, dayWinCountAwardState, dayWinCountAwardDict, "CrossServer2")  | 
|       | 
|     # ÖØÖÃÿÈÕ½±Àø×´Ì¬  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_ItemAddCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayPKCountAwardState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayWinCountAwardState, 0)  | 
|     SyncCrossRealmPKPlayerInfo(curPlayer)  | 
|     SyncCrossRealmPKAwardState(curPlayer)  | 
|     return  | 
|   | 
| def DoPlayerLogin(curPlayer):  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     mapZoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)  | 
|     mapSeasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|     if not mapZoneID or not mapSeasonID:  | 
|         return  | 
|       | 
|     if not __CheckResetPlayerCrossPKData(curPlayer, mapZoneID, mapSeasonID):  | 
|         SyncCrossRealmPKPlayerInfo(curPlayer)  | 
|         SyncCrossRealmPKAwardState(curPlayer)  | 
|         SyncCrossRealmPKHisSeasonInfo(curPlayer)  | 
|     return  | 
|   | 
| def IsCrossRealmPKMatchState():  | 
|     ## ¿ç·þPKÆ¥ÅäÈüÊÇ·ñ¿ªÆô  | 
|     return GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossDailyActionState \  | 
|                                                           % ShareDefine.DailyActionID_CrossReamPK) == ChConfig.Def_Action_Open  | 
|   | 
| def GetCrossPKDanAwardIpyData(seasonID, awardDanLV, isLog):  | 
|     ## »ñÈ¡¿ç·þ¶Îλ½±ÀøÅäÖÃÐÅÏ¢  | 
|     crossZoneName = GameWorld.GetCrossZoneName()  | 
|     danLVAwardIpyData = IpyGameDataPY.GetIpyGameDataNotLog("CrossRealmPKDanAward", crossZoneName, seasonID, awardDanLV)  | 
|     if not danLVAwardIpyData:  | 
|         danLVAwardIpyData = IpyGameDataPY.GetIpyGameDataNotLog("CrossRealmPKDanAward", "", seasonID, awardDanLV)  | 
|     if not danLVAwardIpyData and isLog:  | 
|         GameWorld.ErrLog("ÕÒ²»µ½¶Îλ½±ÀøÅäÖÃ: seasonID=%s, awardDanLV=%s" % (seasonID, awardDanLV))  | 
|     return danLVAwardIpyData  | 
|   | 
| def OnCrossRealmPKSeasonChange(value):  | 
|     ## ÈüÇøÈü¼¾×´Ì¬±ä¸ü£¬¹æ¶¨ËùÓÐÈüÇøµÄÈü¼¾ID¶¼Ò»Ñù£¬ÇÒÈü¼¾IDÒ»¶¨ÊÇ×ÔÔöµÄ£¬ËùÒÔÕâÀïÖ»ÅжÏÈü¼¾ID±ä¸ü¼´¿É  | 
|       | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     mapZoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)  | 
|     mapSeasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|       | 
|     if mapSeasonID == value:  | 
|         GameWorld.DebugLog("¿ç·þPKÈü¼¾ÐÅÏ¢ÓëµØÍ¼µ±Ç°ÖµÏàͬ£¬²»´¦Àí£¡")  | 
|         return  | 
|     GameWorld.Log("¿ç·þPKÈü¼¾ÐÅÏ¢±ä¸ü: mapSeasonID=%s,value=%s" % (mapSeasonID, value))  | 
|     mapSeasonID = value  | 
|       | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     for i in xrange(playerManager.OnlineCount()):  | 
|         curPlayer = playerManager.OnlineAt(i)  | 
|         if not curPlayer or curPlayer.IsEmpty():  | 
|             continue  | 
|           | 
|         #¼ì²éÖØÖÃÍæ¼ÒÐÅÏ¢  | 
|         __CheckResetPlayerCrossPKData(curPlayer, mapZoneID, mapSeasonID)  | 
|           | 
|     return  | 
|   | 
| def __CheckResetPlayerCrossPKData(curPlayer, mapZoneID, mapSeasonID):  | 
|     ## ¼ì²éÍæ¼ÒÈüÇøÈü¼¾×´Ì¬Êý¾Ý  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     zoneID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ZoneID)  | 
|     seasonID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonID)  | 
|     if mapSeasonID == seasonID:  | 
|         GameWorld.DebugLog("Íæ¼Ò¿ç·þPKÈü¼¾ÐÅÏ¢Ïàͬ£¬²»´¦Àí! mapSeasonID=%s,seasonID=%s" % (mapSeasonID, seasonID), playerID)  | 
|         return  | 
|     GameWorld.Log("Íæ¼Ò¿ç·þPKÈüÇøÈü¼¾ÐÅÏ¢²»Í¬! ´¦ÀíÏà¹ØÊý¾Ý! mapSeasonID=%s,seasonID=%s" % (mapSeasonID, seasonID), playerID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonID, mapSeasonID)  | 
|       | 
|     playerDanLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)  | 
|     danLVAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLVAwardState)  | 
|   | 
|     GameWorld.Log("¿ªÊ¼ÐÂÈü¼¾£¬·¢·ÅÉÏÈü¼¾Î´ÁìÈ¡µÄ½±Àø£¬ÖØÖÃÈü¼¾Êý¾Ý! zoneID=%s,seasonID=%s,newSeasonID=%s,playerDanLV=%s,danLVAwardState=%s"   | 
|                   % (zoneID, seasonID, mapSeasonID, playerDanLV, danLVAwardState), playerID)  | 
|       | 
|     # Óʼþ·¢·ÅÉÏÈü¼¾Î´ÁìÈ¡µÄ¶Îλ½±Àø¡¢Èü¼¾½±Àø£¨ÅÅÃû»ò¶Î룩  | 
|     for awardDanLV in xrange(playerDanLV + 1):  | 
|         danLVAwardIpyData = GetCrossPKDanAwardIpyData(seasonID, awardDanLV, False)  | 
|         if not danLVAwardIpyData:  | 
|             continue  | 
|         awardItemList = danLVAwardIpyData.GetDanLVAwardList()  | 
|         if not awardItemList:  | 
|             continue  | 
|         if pow(2, awardDanLV) & danLVAwardState:  | 
|             GameWorld.DebugLog("    ÒѾÁìÈ¡¹ý¸Ã¶Îλ´ï±ê½±Àø!awardDanLV=%s,danLVAwardState=%s" % (awardDanLV, danLVAwardState), playerID)  | 
|             continue  | 
|         eventName = "DanLV"  | 
|         GameWorld.Log("    Óʼþ²¹·¢Î´ÁìÈ¡µÄ¶Îλ´ï±ê½±Àø!awardDanLV=%s,danLVAwardState=%s,awardItemList=%s"   | 
|                       % (awardDanLV, danLVAwardState, awardItemList), playerID)  | 
|         mailDetail = {"EventName":eventName, "zoneID":zoneID, "seasonID":seasonID, "awardDanLV":awardDanLV,   | 
|                       "danLVAwardState":danLVAwardState, "mapSeasonID":mapSeasonID}  | 
|         PlayerControl.SendMailByKey("CrossServer3", [playerID], awardItemList, [seasonID, awardDanLV], detail=mailDetail)  | 
|         DR_GetCrossPKAward(curPlayer, zoneID, seasonID, eventName, True, mailDetail)  | 
|           | 
|     # ²éѯ GameServer Íæ¼ÒÈü¼¾ÅÅÃû  | 
|     if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardState) and playerDanLV:  | 
|         OnQueryCrossPKSeasonOrderAward(curPlayer, zoneID, seasonID, True)  | 
|           | 
|     # ÖØÖÃ״̬  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_OnDayScore, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_WinCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_ItemAddCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayPKCountAwardState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DayWinCountAwardState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLVAwardState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonAwardState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_ZoneID, mapZoneID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonID, mapSeasonID)  | 
|       | 
|     SyncCrossRealmPKPlayerInfo(curPlayer)  | 
|     SyncCrossRealmPKAwardState(curPlayer)  | 
|       | 
|     # ÖØÖÃÉ̵êÎïÆ·  | 
|     FunctionNPCCommon.ShopItemOnCrossPKSeasonChange(curPlayer)  | 
|     return True  | 
|   | 
| #// C1 01 ¿ç·þPKÆ¥Åä #tagCMCrossRealmPKMatch  | 
| #  | 
| #struct    tagCMCrossRealmPKMatch  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        Type;    // 0-È¡ÏûÆ¥Åä; 1-½øÐÐÆ¥Åä  | 
| #};  | 
| def OnCrossRealmPKMatch(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     accID = curPlayer.GetAccID()  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     requestType = clientData.Type  | 
|       | 
|     if GameWorld.IsCrossServer():  | 
|         GameWorld.DebugLog("¿ç·þ·þÎñÆ÷ÎÞ·¨·¢ÆðÆ¥Åä!", playerID)  | 
|         return  | 
|       | 
|     if not CrossRealmPlayer.IsCrossServerOpen():  | 
|         PlayerControl.NotifyCode(curPlayer, "CrossMatching18")  | 
|         return  | 
|       | 
|     if GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:  | 
|         GameWorld.DebugLog("¸±±¾ÖУ¬ÎÞ·¨½øÐпç·þÆ¥Åä!", playerID)  | 
|         return  | 
|       | 
|     if curPlayer.GetPlayerAction() == IPY_GameWorld.paDie or curPlayer.GetHP() == 0:  | 
|         #GameWorld.DebugLog("ÒÑËÀÍö£¬ÎÞ·¨½øÐпç·þÆ¥Åä!", playerID)  | 
|         return  | 
|       | 
|     if GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState) != 1:  | 
|         GameWorld.DebugLog("OnCrossRealmPKMatch ¿ç·þÈü¼¾Î´¿ªÆô£¬²»¿É½øÐÐÆ¥Å䣡", playerID)  | 
|         #PlayerControl.NotifyCode(curPlayer, "SeasonIsNotOpen")  | 
|         return  | 
|       | 
|     if not IsCrossRealmPKMatchState():  | 
|         GameWorld.DebugLog("OnCrossRealmPKMatch ¿ç·þÆ¥Åä먦Æô£¬²»¿É½øÐÐÆ¥Å䣡", playerID)  | 
|         #PlayerControl.NotifyCode(curPlayer, "MatchIsNotOpen")  | 
|         return  | 
|       | 
|     GameWorld.Log("ÊÕµ½¿ç·þPKÆ¥Åä: type=%s,accID=%s" % (requestType, accID), playerID)  | 
|       | 
|     # ½øÐÐÆ¥Åä  | 
|     if requestType == 1:  | 
|         dayFreeMatchCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 1)  | 
|         if dayFreeMatchCountMax:  | 
|             todayPKCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)  | 
|             todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)  | 
|             todayItemAddCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)  | 
|               | 
|             if todayPKCount >= (dayFreeMatchCountMax + todayBuyCount + todayItemAddCount):  | 
|                 GameWorld.DebugLog("PK´ÎÊý²»×㣬ÎÞ·¨·¢ÆðÆ¥Åä! todayPKCount=%s >= (dayFreeMatchCountMax=%s + todayBuyCount=%s + todayItemAddCount=%s)"   | 
|                                    % (todayPKCount, dayFreeMatchCountMax, todayBuyCount, todayItemAddCount), playerID)  | 
|                 return  | 
|               | 
|         dataMsg = {  | 
|                    "seasonID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID), # Èü¼¾ID  | 
|                    "pkZoneID":GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID), # PKÈüÇø  | 
|                    "accID":accID,  | 
|                    "playerID":playerID,  | 
|                    "playerName":CrossRealmPlayer.GetCrossPlayerName(curPlayer),  | 
|                    "playerJob":curPlayer.GetJob(),  | 
|                    "playerLV":curPlayer.GetLV(),  | 
|                    "maxHP":curPlayer.GetMaxHP(),  | 
|                    "maxProDef":PlayerControl.GetMaxProDef(curPlayer),  | 
|                    "fightPower":curPlayer.GetFightPower(),  | 
|                    "realmLV":curPlayer.GetOfficialRank(),  | 
|                    "pkScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore), # µ±Ç°»ý·Ö  | 
|                    "danLV":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV), # µ±Ç°¶Îλ  | 
|                    "cWinCount":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount), # Á¬Ê¤´ÎÊý  | 
|                    "ondayScore":curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore), # ¹ýÌìʱµÄ»ý·Ö  | 
|                    }  | 
|         GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_PKMatch, dataMsg)  | 
|         GameWorld.Log("    ·¢ËÍÇëÇóÆ¥Åäµ½¿ç·þ·þÎñÆ÷ dataMsg=%s" % str(dataMsg), playerID)  | 
|           | 
|     # È¡ÏûÆ¥Åä  | 
|     else:  | 
|         sendMsg = "ClientCancel"  | 
|         GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "CrossRealmPKCancel", sendMsg, len(sendMsg))  | 
|         GameWorld.Log("    ·¢ËÍÈ¡ÏûÆ¥Åäµ½GameServer sendMsg=%s" % str(sendMsg), playerID)  | 
|           | 
|     return  | 
|   | 
| def CrossServerMsg_PKOverInfo(curPlayer, overInfo):  | 
|     ## ÊÕµ½¿ç·þ·þÎñÆ÷µÄPK½áËãÐÅÏ¢  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, tagPlayerName, notifyState = overInfo  | 
|     isWinner = winnerID == playerID  | 
|     GameWorld.Log("µØÍ¼ÊÕµ½¿ç·þPK½áËã: isWinner=%s,roomID=%s,zoneID=%s,seasonID=%s,timeStr=%s,overType=%s,winnerID=%s,roundWinnerIDList=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s,tagPlayerID=%s,notifyState=%s"   | 
|                   % (isWinner, roomID, zoneID, seasonID, timeStr, overType, winnerID, roundWinnerIDList, pkScore, danLV, cWinCount, addScore, tagPlayerID, notifyState), playerID)  | 
|       | 
|     isToday = GameWorld.CheckTimeIsSameServerDayEx(GameWorld.ChangeTimeStrToNum(timeStr))  | 
|     if not __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):  | 
|         return  | 
|       | 
|     ## ¿ç·þÒѾ֪ͨ¹ýÁË£¬Ö¤Ã÷»¹ÔÚ¿ç·þ·þÎñÆ÷£¬²»×öÒÔϵĴ¦Àí  | 
|     if notifyState:  | 
|         return  | 
|       | 
|     overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()  | 
|     overPack.TimeStr = timeStr  | 
|     overPack.OverType = overType  | 
|     overPack.WinnerID = winnerID  | 
|     overPack.RoundWinnerID = roundWinnerIDList  | 
|     overPack.RoundCount = len(overPack.RoundWinnerID)  | 
|     overPack.AddScore = addScore  | 
|     overPack.Score = pkScore  | 
|     overPack.DanLV = danLV  | 
|     overPack.CWinCnt = cWinCount  | 
|     overPack.TagName = tagPlayerName  | 
|     overPack.TagNameLen = len(overPack.TagName)  | 
|     NetPackCommon.SendFakePack(curPlayer, overPack)  | 
|     return  | 
|   | 
| def __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday):  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     curSeasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|     if curSeasonID != seasonID:  | 
|         GameWorld.Log("    ·Ç±¾Èü¼¾µÄ½áËãÐÅÏ¢£¬²»´¦Àí£¡curSeasonID=%s,seasonID=%s" % (curSeasonID, seasonID), playerID)  | 
|         return  | 
|       | 
|     # Èü¼¾ÒÑ¹Ø±Õ  | 
|     if GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState) != 1:  | 
|         GameWorld.Log("    Èü¼¾Òѹرգ¬²»´¦Àí£¡seasonID=%s" % (seasonID), playerID)  | 
|         return  | 
|       | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_ZoneID, zoneID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonID, seasonID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonDanLV % seasonID, danLV)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonScore % seasonID, pkScore)  | 
|       | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TotalScore, pkScore)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_DanLV, danLV)  | 
|       | 
|     pkCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_PKCount) + 1  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_PKCount, pkCount)  | 
|     GameWorld.Log("    ¸üÐÂÊý¾Ý: danLV=%s,pkScore=%s,pkCount=%s" % (danLV, pkScore, pkCount), playerID)  | 
|     if isWinner:  | 
|         winCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_WinCount) + 1  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_WinCount, winCount)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, cWinCount)  | 
|         GameWorld.Log("    winner winCount=%s,cWinCount=%s" % (winCount, cWinCount), playerID)  | 
|     else:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_CWinCount, 0)  | 
|         GameWorld.Log("    loser cWinCount=0", playerID)  | 
|           | 
|     # Í¬Ò»ÌìµÄ»°Ôö¼Óµ±ÈÕPK´ÎÊý  | 
|     if isToday:  | 
|         todayPKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount) + 1  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayPKCount, todayPKCount)  | 
|         GameWorld.Log("    Í¬Ò»ÌìµÄPK½áËãÔö¼Ó½ñÈÕPK´ÎÊý: todayPKCount=%s" % todayPKCount, playerID)  | 
|         if isWinner:  | 
|             todayWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayWinCount) + 1  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayWinCount, todayWinCount)  | 
|             GameWorld.Log("    Ôö¼Ó½ñÈÕÒÑ»ñʤ´ÎÊý: todayWinCount=%s" % todayWinCount, playerID)  | 
|         PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_CrossReamPK)  | 
|         PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_CrossPK, 1)  | 
|         PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_CrossPK, 1)  | 
|     else:  | 
|         GameWorld.Log("    ²»Í¬ÌìµÄPK½áËã²»Ôö¼Ó½ñÈÕPK´ÎÊý! ", playerID)  | 
|           | 
|     SyncCrossRealmPKPlayerInfo(curPlayer)  | 
|     return True  | 
|   | 
| #// C1 08 ¿ç·þPKÌôÕ½»úÆ÷È˽áËã #tagCMCrossRealmPKRobotOver  | 
| #  | 
| #struct    tagCMCrossRealmPKRobotOver  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        IsWin;    //ÊÇ·ñ»ñʤ  | 
| #};  | 
| def OnCrossRealmPKRobotOver(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     isWinner = clientData.IsWin  | 
|     billboardCfg = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKCfg", 1, [])  | 
|     if not billboardCfg or len(billboardCfg) != 2:  | 
|         GameWorld.ErrLog("¿ç·þ¾º¼¼³¡ÅÅÐаñÅäÖôíÎó£¡")  | 
|         return  | 
|     danLVLimit = billboardCfg[1]  | 
|     playerDanLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)  | 
|     #²ß»®Éè¼Æ¸Ã»úÆ÷ÈËÄ¿µÄΪÁËǰÆÚÌåÑ飬ÕâÀïÖ»ÑéÖ¤ÊÇ·ñ³¬¹ýÉϰñ¶Îλ¼´¿É£¬¼´Ê¹×÷±×Ò²²»¹Ü£¬Ö»ÒªÓдÎÊý¼´¿É  | 
|     if playerDanLV >= danLVLimit:  | 
|         GameWorld.ErrLog("¸Ã¶Îλ²»ÔÊÐíÓë»úÆ÷ÈËÆ¥ÅäPK!playerDanLV=%s,danLVLimit=%s" % (playerDanLV, danLVLimit), playerID)  | 
|         return  | 
|       | 
|     zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)  | 
|     seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|     pkScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)  | 
|     danLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)  | 
|     cWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount)  | 
|       | 
|     ondayScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_OnDayScore)  | 
|     dayScore = max(0, pkScore - ondayScore) # ½ñÈÕÒÑ»ñµÃ»ý·Ö£¬Õý»ý·Ö  | 
|       | 
|     baseScoreList = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKScore", 2) # Ê¤¸º±£µ×·Ö  | 
|     wBaseScore = baseScoreList[0] if len(baseScoreList) > 0 else 0  | 
|     lBaseScore = baseScoreList[1] if len(baseScoreList) > 1 else 0  | 
|     wExScore = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKScore", 3)) # Ê¤·½¸½¼Ó·Ö  | 
|     lExScore = 0  | 
|       | 
|     if isWinner:  | 
|         addScore = wBaseScore + wExScore  | 
|         cWinCount += 1  | 
|     else:  | 
|         addScore = lBaseScore + lExScore  | 
|         cWinCount = 0  | 
|           | 
|     dayMaxScore = IpyGameDataPY.GetFuncCfg("CrossRealmPKScore", 1) # Ã¿ÈÕ»ñµÃ»ý·ÖÉÏÏÞ£¬0Ϊ²»ÏÞÖÆ  | 
|     if dayMaxScore and addScore:  | 
|         addScore = min(dayMaxScore - dayScore, addScore)  | 
|           | 
|     GameWorld.Log("»úÆ÷ÈË¿ç·þPK½áËã: isWinner=%s,zoneID=%s,seasonID=%s,pkScore=%s,danLV=%s,cWinCount=%s,addScore=%s"   | 
|                   % (isWinner, zoneID, seasonID, pkScore, danLV, cWinCount, addScore), playerID)  | 
|       | 
|     pkScore += addScore  | 
|     winIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKDan", danLV)  | 
|     if winIpyData and winIpyData.GetLVUpScore() and pkScore >= winIpyData.GetLVUpScore():  | 
|         danLV += 1  | 
|           | 
|     # Ö»Í¬²½ÒÔÏÂÐÅÏ¢£¬ÆäËûÐÅϢǰ¶Ë×ÔÐв¹È«  | 
|     overPack = ChPyNetSendPack.tagGCCrossRealmPKOverInfo()  | 
|     overPack.AddScore = addScore  | 
|     overPack.Score = pkScore  | 
|     overPack.DanLV = danLV  | 
|     overPack.CWinCnt = cWinCount  | 
|     NetPackCommon.SendFakePack(curPlayer, overPack)  | 
|       | 
|     isToday = True # »úÆ÷È˽áËãµÄĬÈϵ±Ìì  | 
|     __DoAddPKOverData(curPlayer, zoneID, seasonID, danLV, pkScore, cWinCount, isWinner, isToday)  | 
|     return  | 
|   | 
|   | 
| #// C1 02 ¿ç·þPK¹ºÂò´ÎÊý #tagCMCrossRealmPKBuy  | 
| #  | 
| #struct    tagCMCrossRealmPKBuy  | 
| #{  | 
| #    tagHead        Head;  | 
| #};  | 
| def OnCrossRealmPKBuy(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if not CrossRealmPlayer.IsCrossServerOpen():  | 
|         PlayerControl.NotifyCode(curPlayer, "CrossMatching18")  | 
|         return  | 
|     if not IsCrossRealmPKMatchState():  | 
|         GameWorld.DebugLog("¿ç·þÆ¥Åä먦Æô£¬²»¿É½øÐйºÂò´ÎÊý£¡", playerID)  | 
|         return  | 
|     dayFreeMatchCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 1)  | 
|     if not dayFreeMatchCountMax:  | 
|         GameWorld.DebugLog("ÿÈÕÆ¥Åä´ÎÊýûÓÐÏÞÖÆ£¬²»ÐèÒª¹ºÂò´ÎÊý£¡", playerID)  | 
|         return  | 
|     todayPKCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)  | 
|     todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)  | 
|     todayItemAddCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)  | 
|     canPKCount = dayFreeMatchCountMax + todayBuyCount + todayItemAddCount - todayPKCount  | 
|     if canPKCount >= dayFreeMatchCountMax:  | 
|         GameWorld.DebugLog("¿ÉPK´ÎÊý²»ÄÜ´óÓÚÿÈÕÃâ·Ñ´ÎÊý!", playerID)  | 
|         return  | 
|     dayBuyCountMax = IpyGameDataPY.GetFuncCfg("CrossRealmPKMatchCount", 2)  | 
|     #todayBuyCount  = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)  | 
|     if dayBuyCountMax and todayBuyCount >= dayBuyCountMax:  | 
|         GameWorld.DebugLog("½ñÈÕ¹ºÂò´ÎÊýÒÑÂú£¬ÎÞ·¨¹ºÂò£¡todayBuyCount=%s" % (todayBuyCount), playerID)  | 
|         return  | 
|       | 
|     costGold = eval(IpyGameDataPY.GetFuncCompileCfg("CrossRealmPKMatchCount", 3))  | 
|     costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costGold)  | 
|     if not costMoneyList:  | 
|         GameWorld.DebugLog("ÏÉÓñ°óÓñ²»×ã: todayBuyCount=%s,costGold=%s" % (todayBuyCount, costGold), playerID)  | 
|         return  | 
|       | 
|     infoDict = {"Event":"BuyPKCount", "todayBuyCount":todayBuyCount}  | 
|     for moneyType, moneyNum in costMoneyList:  | 
|         PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_CrossRealmPK, infoDict)  | 
|           | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_TodayBuyCount, todayBuyCount + 1)  | 
|     GameWorld.DebugLog("¹ºÂò¿ç·þPK´ÎÊý: todayBuyCount=%s" % (todayBuyCount), playerID)  | 
|     SyncCrossRealmPKPlayerInfo(curPlayer)  | 
|     return  | 
|   | 
|   | 
| #// C1 03 ¿ç·þPKÁìÈ¡½±Àø #tagCMCrossRealmPKGetAward  | 
| #  | 
| #struct    tagCMCrossRealmPKGetAward  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        AwardType;    // ½±ÀøÀàÐÍ£»1-ÿÈÕÆ¥Åä½±Àø£¬2-ÿÈÕʤÀû½±Àø£¬3-¶Îλ´ï±ê½±Àø£¬4-Èü¼¾½áËã½±Àø  | 
| #    BYTE        AwardData;    // ½±ÀøÀàÐͶÔÓ¦Áìȡֵ£»Ã¿ÈÕÆ¥Åä½±ÀøÊ±ÎªÆ¥Åä´ÎÊý£¬Ã¿ÈÕʤÀû½±ÀøÊ±ÎªÊ¤Àû´ÎÊý£¬¶Îλ´ï±ê½±ÀøÊ±ÎªÁìÈ¡µÄ¶Îλ  | 
| #};  | 
| def OnCrossRealmPKGetAward(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     if not curPlayer:  | 
|         return  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     awardType = clientData.AwardType  | 
|     awardData = clientData.AwardData  | 
|     zoneID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKZoneID)  | 
|     seasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|     if not zoneID or not seasonID:  | 
|         GameWorld.DebugLog("µ±Ç°Ã»Óпç·þPKÈü¼¾, ÎÞ·¨ÁìÈ¡½±Àø! zoneID=%s,seasonID=%s" % (zoneID, seasonID))  | 
|         return  | 
|       | 
|     if awardType == 1:  | 
|         awardPKCount = awardData  | 
|         playerTodayPKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)  | 
|         GameWorld.DebugLog("Íæ¼ÒÁìȡÿÈÕÆ¥Åä´ÎÊý½±Àø! awardPKCount=%s,playerTodayPKCount=%s" % (awardPKCount, playerTodayPKCount), playerID)  | 
|         if playerTodayPKCount < awardPKCount:  | 
|             GameWorld.DebugLog("    PK´ÎÊý²»×㣬ÎÞ·¨ÁìÈ¡£¡", playerID)  | 
|             return  | 
|         dayPKCountAwardDict = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKAward", 1, {}) # {"´ÎÊý":[[ÎïÆ·ID,¸öÊý,ÊÇ·ñ°ó¶¨], ...], ...}  | 
|         awardPKCountList = dayPKCountAwardDict.keys()  | 
|         awardPKCountList = [int(k) for k in awardPKCountList]  | 
|         awardPKCountList.sort()  | 
|         GameWorld.DebugLog("    awardPKCountList=%s" % awardPKCountList, playerID)  | 
|         if awardPKCount not in awardPKCountList:  | 
|             GameWorld.DebugLog("    Ã»ÓиÃPK´ÎÊý½±Àø£¡")  | 
|             return  | 
|         awardIndex = awardPKCountList.index(awardPKCount)  | 
|         awardStateDictName = ChConfig.Def_PDict_CrossPK_DayPKCountAwardState  | 
|         awardItemList = dayPKCountAwardDict[str(awardPKCount)]  | 
|         eventName = "PKCount"  | 
|         drDataDict = {"awardPKCount":awardPKCount}  | 
|           | 
|     elif awardType == 2:  | 
|         awardWinCount = awardData  | 
|         playerTodayWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayWinCount)  | 
|         GameWorld.DebugLog("Íæ¼ÒÁìȡÿÈÕʤÀû´ÎÊý½±Àø! awardWinCount=%s,playerTodayWinCount=%s" % (awardWinCount, playerTodayWinCount), playerID)  | 
|         if playerTodayWinCount < awardWinCount:  | 
|             GameWorld.DebugLog("    Ê¤Àû´ÎÊý²»×㣬ÎÞ·¨ÁìÈ¡£¡", playerID)  | 
|             return  | 
|         dayWinCountAwardDict = IpyGameDataPY.GetFuncEvalCfg("CrossRealmPKAward", 2, {}) # {"´ÎÊý":[[ÎïÆ·ID,¸öÊý,ÊÇ·ñ°ó¶¨], ...], ...}  | 
|         awardWinCountList = dayWinCountAwardDict.keys()  | 
|         awardWinCountList = [int(k) for k in awardWinCountList]  | 
|         awardWinCountList.sort()  | 
|         GameWorld.DebugLog("    awardWinCountList=%s" % awardWinCountList, playerID)  | 
|         if awardWinCount not in awardWinCountList:  | 
|             GameWorld.DebugLog("    Ã»ÓиÃʤÀû´ÎÊý½±Àø£¡", playerID)  | 
|             return  | 
|         awardIndex = awardWinCountList.index(awardWinCount)  | 
|         awardStateDictName = ChConfig.Def_PDict_CrossPK_DayWinCountAwardState  | 
|         awardItemList = dayWinCountAwardDict[str(awardWinCount)]  | 
|         eventName = "WinCount"  | 
|         drDataDict = {"awardWinCount":awardWinCount}  | 
|           | 
|     elif awardType == 3:  | 
|         awardDanLV = awardData  | 
|         playerDanLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)  | 
|         GameWorld.DebugLog("Íæ¼ÒÁìÈ¡¶Îλ´ï±ê½±Àø! awardDanLV=%s,playerDanLV=%s" % (awardDanLV, playerDanLV), playerID)  | 
|         if playerDanLV < awardDanLV:  | 
|             GameWorld.DebugLog("    ¶Îλδ´ï±ê£¬ÎÞ·¨ÁìÈ¡£¡", playerID)  | 
|             return  | 
|         danLVAwardIpyData = GetCrossPKDanAwardIpyData(seasonID, awardDanLV, True)  | 
|         if not danLVAwardIpyData:  | 
|             return  | 
|         awardIndex = awardDanLV  | 
|         awardStateDictName = ChConfig.Def_PDict_CrossPK_DanLVAwardState  | 
|         awardItemList = danLVAwardIpyData.GetDanLVAwardList()  | 
|         eventName = "DanLV"  | 
|         drDataDict = {"awardDanLV":awardDanLV}  | 
|           | 
|     elif awardType == 4:  | 
|         GameWorld.DebugLog("Íæ¼ÒÁìÈ¡Èü¼¾½áËã½±Àø!", playerID)  | 
|         totalScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)  | 
|         if not totalScore:  | 
|             GameWorld.DebugLog("ÎÞÈü¼¾»ý·ÖÎÞ·¨ÁìÈ¡½±Àø!", playerID)  | 
|             return  | 
|         if GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonState) != 2:  | 
|             GameWorld.DebugLog("·ÇÈü¼¾½áËã½×¶Î£¬²»¿ÉÁìÈ¡!", playerID)  | 
|             return  | 
|         if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardState):  | 
|             GameWorld.DebugLog("ÒѾÁìÈ¡¹ý¸Ã½±Àø£¬²»¿ÉÁìÈ¡!", playerID)              | 
|             return  | 
|         # ²éѯ GameServer Íæ¼ÒÈü¼¾ÅÅÃû  | 
|         OnQueryCrossPKSeasonOrderAward(curPlayer, zoneID, seasonID, False)  | 
|         return  | 
|       | 
|     else:  | 
|         return  | 
|       | 
|     if not awardItemList:  | 
|         GameWorld.DebugLog("¸Ã½±ÀøÃ»ÓÐÅäÖý±ÀøÎïÆ·!", playerID)  | 
|         return  | 
|       | 
|     awardState = curPlayer.NomalDictGetProperty(awardStateDictName)  | 
|     if pow(2, awardIndex) & awardState:  | 
|         GameWorld.DebugLog("    ÒѾÁìÈ¡¹ý¸Ã½±Àø!awardIndex=%s,awardState=%s" % (awardIndex, awardState), playerID)  | 
|         return  | 
|       | 
|     needSpace = len(awardItemList)  | 
|     # ±³°ü¿Õ¼ä  | 
|     packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)  | 
|     if packSpace < needSpace:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")  | 
|         return  | 
|       | 
|     awardState |= pow(2, awardIndex)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, awardStateDictName, awardState)  | 
|     SyncCrossRealmPKAwardState(curPlayer)  | 
|     GameWorld.DebugLog("Íæ¼ÒÁìÈ¡¿ç·þPK½±Àø! awardType=%s,awardData=%s,awardIndex=%s,awardState=%s,awardItemList=%s"   | 
|                        % (awardType, awardData, awardIndex, awardState, awardItemList), playerID)  | 
|     drDataDict.update({"awardIndex":awardIndex, "awardState":awardState, "awardItemList":awardItemList})  | 
|     for itemID, itemCnt, isBind in awardItemList:  | 
|         ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])  | 
|           | 
|     if awardType == 3:  | 
|         PlayerControl.WorldNotify(0, "CrossMatching22", [curPlayer.GetPlayerName(), awardDanLV])  | 
|           | 
|     DR_GetCrossPKAward(curPlayer, zoneID, seasonID, eventName, False, drDataDict)  | 
|     return  | 
|   | 
| def SendDayPKAwardByMail(curPlayer, zoneID, seasonID, eventName, dataCount, awardState, awardItemDict, mailTypeKey):  | 
|     ## Óʼþ·¢·ÅδÁìÈ¡µÄÿÈÕ½±Àø  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     awardCountList = awardItemDict.keys()  | 
|     awardCountList = [int(k) for k in awardCountList]  | 
|     awardCountList.sort()  | 
|     GameWorld.DebugLog("    awardCountList=%s" % awardCountList, playerID)  | 
|     for i, awardCount in enumerate(awardCountList):  | 
|         if dataCount < awardCount:  | 
|             GameWorld.DebugLog("¿ç·þPKÿÈÕ½±Àø´ÎÊý²»×ã: eventName=%s,i=%s,awardCount=%s > dataCount=%s" % (eventName, i, awardCount, dataCount), playerID)  | 
|             break  | 
|         if pow(2, i) & awardState:  | 
|             GameWorld.DebugLog("ÒÑÁìÈ¡¸Ã¿ç·þPKÿÈÕ½±Àø: eventName=%s,i=%s,awardCount=%s" % (eventName, i, awardCount), playerID)  | 
|             continue  | 
|         awardItemList = awardItemDict[str(awardCount)]  | 
|         GameWorld.Log("Óʼþ·¢·Å¿ç·þPKδÁìÈ¡µÄÿÈÕ½±Àø: zoneID=%s,seasonID=%s,eventName=%s,i=%s,awardCount=%s,dataCount=%s,awardState=%s,awardItemList=%s"   | 
|                       % (zoneID, seasonID, eventName, i, awardCount, dataCount, awardState, awardItemList), playerID)  | 
|           | 
|         mailDetail = {"EventName":eventName, "zoneID":zoneID, "seasonID":seasonID, "awardCount":awardCount, "awardState":awardState}  | 
|         PlayerControl.SendMailByKey(mailTypeKey, [playerID], awardItemList, [awardCount], detail=mailDetail)  | 
|         DR_GetCrossPKAward(curPlayer, zoneID, seasonID, eventName, True, mailDetail)  | 
|           | 
|     return  | 
|   | 
| def OnQueryCrossPKSeasonOrderAward(curPlayer, zoneID, seasonID, isMail):  | 
|     # ²éѯ GameServer Íæ¼ÒÈü¼¾ÅÅÃû  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     danLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)  | 
|     eventName, eventData = "SeasonAward", [danLV, isMail]  | 
|     sendMsg = str([zoneID, seasonID, eventName, eventData])  | 
|     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "CrossPKSeasonOrder", sendMsg, len(sendMsg))  | 
|     GameWorld.Log("²éѯGameServerÍæ¼ÒÈüÇøÈü¼¾ÅÅÃû: zoneID=%s, seasonID=%s, sendMsg=%s" % (zoneID, seasonID, sendMsg), playerID)  | 
|     return  | 
|   | 
| def GameServer_CrossPKSeasonOrder(curPlayer, msgList):  | 
|     zoneID, seasonID, eventName, eventData, order = msgList  | 
|       | 
|     # ÁìÈ¡Èü¼¾½±Àø  | 
|     if eventName == "SeasonAward":  | 
|         danLV, isMail = eventData  | 
|         DoGetPKSeasonAward(curPlayer, eventName, zoneID, seasonID, order, danLV, isMail)  | 
|           | 
|     return  | 
|   | 
| def DoGetPKSeasonAward(curPlayer, eventName, zoneID, seasonID, order, danLV, isMail):  | 
|     ## Ö´Ðз¢·ÅÈü¼¾½áËã½±Àø£¬Ãû´Î½±ÀøÓë×î¸ß¶Îλ½±Àø»¥³â£¬ÓÅÏÈÃû´Î½±Àø  | 
|     isNotify = not isMail  | 
|     notifyKey = ""  | 
|     awardItemList = []  | 
|     seasonAwardLV = danLV  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     mapSeasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|     GameWorld.Log("·¢·ÅÍæ¼Ò¿ç·þPKÈü¼¾½áËã½±Àø! zoneID=%s,seasonID=%s,order=%s,danLV=%s,isMail=%s,seasonAwardLV=%s,mapSeasonID=%s"   | 
|                   % (zoneID, seasonID, order, danLV, isMail, seasonAwardLV, mapSeasonID), playerID)  | 
|     mailTypeKey, mailParamList, mailDetail = "", [], {"EventName":eventName, "zoneID":zoneID, "seasonID":seasonID,   | 
|                                                       "order":order, "danLV":danLV, "mapSeasonID":mapSeasonID}  | 
|     if order > 0:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonOrder % seasonID, order)  | 
|         crossZoneName = GameWorld.GetCrossZoneName()  | 
|         seasonOrderAwardIpyData = IpyGameDataPY.GetIpyGameDataNotLog("CrossRealmPKOrderAward", crossZoneName, seasonID)  | 
|         if not seasonOrderAwardIpyData:  | 
|             seasonOrderAwardIpyData = IpyGameDataPY.GetIpyGameData("CrossRealmPKOrderAward", "", seasonID)  | 
|         seasonOrderAwardDict = {} if not seasonOrderAwardIpyData else seasonOrderAwardIpyData.GetOrderAwardInfo() # {"Ãû´Î":[[ÎïÆ·ID,¸öÊý,ÊÇ·ñ°ó¶¨], ...], ...}  | 
|         awardOrderList = seasonOrderAwardDict.keys()  | 
|         awardOrderList = [int(k) for k in awardOrderList]  | 
|         awardOrderList.sort()  | 
|         GameWorld.DebugLog("    awardOrderList=%s" % awardOrderList, playerID)  | 
|         fromOrder, toOrder = 1, 1  | 
|         for i, awardOrder in enumerate(awardOrderList):  | 
|             if order <= awardOrder:  | 
|                 toOrder = awardOrder  | 
|                 awardItemList = seasonOrderAwardDict[str(awardOrder)]  | 
|                 maxDanLV = IpyGameDataPY.IPY_Data().GetCrossRealmPKDanCount() - 1 # ÒòΪ¶ÎλµÈ¼¶´Ó0¿ªÊ¼£¬ËùÒÔ×î´ó¶ÎλµÈ¼¶Òª¼õ1  | 
|                 seasonAwardLV = maxDanLV + (len(awardOrderList) - i)  | 
|                 GameWorld.Log("»ñµÃÅÅÃû½±Àø, ¸üн±ÀøµÈ¼¶: awardOrderList=%s,i=%s,maxDanLV=%s,seasonAwardLV=%s" % (awardOrderList, i, maxDanLV, seasonAwardLV), playerID)  | 
|                 mailTypeKey = "CrossServer4"  | 
|                 notifyKey = "CrossMatching23"  | 
|                 mailParamList = [seasonID, fromOrder, toOrder]  | 
|                 break  | 
|             fromOrder = awardOrder + 1  | 
|               | 
|     # Ã»Óн±ÀøµÄ»°È¡¶Îλ½±Àø      | 
|     if not awardItemList:  | 
|         danLVAwardIpyData = GetCrossPKDanAwardIpyData(seasonID, danLV, False)  | 
|         if not danLVAwardIpyData:  | 
|             return  | 
|         awardItemList = danLVAwardIpyData.GetSeasonDanLVAwardList()  | 
|         mailTypeKey = "CrossServer5"  | 
|         notifyKey = "CrossMatching24"  | 
|         mailParamList = [seasonID, danLV]  | 
|           | 
|     if not awardItemList:  | 
|         GameWorld.Log("ûÓÐÍæ¼Ò¶ÔÓ¦µÄÈü¼¾½áËã½±Àø£¡", playerID)  | 
|         return  | 
|     ## ·¢½±ÀøÖ®Ç°ÐèÔÙÅжÏÒ»´Î£¬·ÀÖ¹ÖØ¸´·¢°üÖØ¸´ÁìÈ¡  | 
|     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardState):  | 
|         GameWorld.Log("ÒѾ·¢·Å¹ýÈü¼¾½áËã½±Àø£¡", playerID)  | 
|         return  | 
|     if seasonID == mapSeasonID:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonAwardState, 1)  | 
|         SyncCrossRealmPKAwardState(curPlayer)  | 
|         GameWorld.Log("»¹ÊÇͬһ¸öÈü¼¾£¬ÉèÖÃÈü¼¾½±ÀøÒÑÁìÈ¡!")  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CrossPK_SeasonAwardLV % seasonID, seasonAwardLV)  | 
|     SyncCrossRealmPKHisSeasonInfo(curPlayer)  | 
|       | 
|     if not isMail:  | 
|         needSpace = len(awardItemList)  | 
|         packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)  | 
|         if packSpace < needSpace:  | 
|             isMail = True  | 
|               | 
|     if isMail:  | 
|         PlayerControl.SendMailByKey(mailTypeKey, [playerID], awardItemList, mailParamList, detail=mailDetail)  | 
|     else:  | 
|         for itemID, itemCnt, isBind in awardItemList:  | 
|             ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])  | 
|               | 
|     GameWorld.Log("ÁìÈ¡³É¹¦! awardItemList=%s" % (awardItemList), playerID)  | 
|     drDataDict = {"awardItemList":awardItemList, "order":order, "danLV":danLV, "seasonAwardLV":seasonAwardLV, "isMail":isMail}  | 
|     DR_GetCrossPKAward(curPlayer, zoneID, seasonID, eventName, isMail, drDataDict)  | 
|       | 
|     if isNotify and notifyKey:  | 
|         PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName()] + mailParamList + [awardItemList[0][0]])  | 
|     return  | 
|   | 
| def SyncCrossRealmPKPlayerInfo(curPlayer):  | 
|     ## Í¬²½Íæ¼Ò¿ç·þPKÍæ¼ÒÏà¹ØÐÅÏ¢£¬»ý·Ö¡¢¶Îλ¡¢Ïà¹Ø´ÎÊýµÈÐÅÏ¢  | 
|     pkPlayerInfo = ChPyNetSendPack.tagMCCrossRealmPKPlayerInfo()  | 
|     pkPlayerInfo.Score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TotalScore)  | 
|     pkPlayerInfo.DanLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLV)  | 
|     pkPlayerInfo.PKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_PKCount)  | 
|     pkPlayerInfo.WinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_WinCount)  | 
|     pkPlayerInfo.CWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_CWinCount)  | 
|     pkPlayerInfo.DayPKCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayPKCount)  | 
|     pkPlayerInfo.DayWinCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayWinCount)  | 
|     pkPlayerInfo.DayBuyCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_TodayBuyCount)  | 
|     pkPlayerInfo.DayItemAddCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_ItemAddCount)  | 
|     NetPackCommon.SendFakePack(curPlayer, pkPlayerInfo)  | 
|     return  | 
|       | 
| def SyncCrossRealmPKAwardState(curPlayer):  | 
|     ## Í¬²½Íæ¼Ò¿ç·þPKÏà¹Ø½±Àø×´Ì¬  | 
|     pkAwardPack = ChPyNetSendPack.tagMCCrossRealmPKAwardState()  | 
|     pkAwardPack.DayPKCountAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DayPKCountAwardState)  | 
|     pkAwardPack.DayWinCountAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DayWinCountAwardState)  | 
|     pkAwardPack.DanLVAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_DanLVAwardState)  | 
|     pkAwardPack.SeasonAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardState)  | 
|     NetPackCommon.SendFakePack(curPlayer, pkAwardPack)  | 
|     return  | 
|   | 
| def SyncCrossRealmPKHisSeasonInfo(curPlayer):  | 
|     mapSeasonID = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_CrossPKSeasonID)  | 
|     hisSeasonInfo = ChPyNetSendPack.tagMCCrossRealmPKPlayerHisSeasonInfo()  | 
|     hisSeasonInfo.SeasonList = []  | 
|     for seasonID in xrange(1, mapSeasonID + 1):  | 
|         seasonInfo = ChPyNetSendPack.tagMCCrossRealmPKPlayerHisSeason()  | 
|         seasonInfo.SeasonID = seasonID  | 
|         seasonInfo.DanLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonDanLV % seasonID)  | 
|         seasonInfo.Score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonScore % seasonID)  | 
|         seasonInfo.Order = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonOrder % seasonID)  | 
|         seasonInfo.AwardLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardLV % seasonID)  | 
|         hisSeasonInfo.SeasonList.append(seasonInfo)  | 
|     hisSeasonInfo.Count = len(hisSeasonInfo.SeasonList)  | 
|     NetPackCommon.SendFakePack(curPlayer, hisSeasonInfo)  | 
|     return  | 
|   | 
| def DR_GetCrossPKAward(curPlayer, zoneID, seasonID, eventName, isMail, drDataDict):  | 
|     ## ¼Ç¼Áì½±Á÷Ïò  | 
|     drDataDict.update({"zoneID":zoneID, "seasonID":seasonID, "isMail":isMail})  | 
|     DataRecordPack.SendEventPack("GetCrossPKAward_%s" % eventName, drDataDict, curPlayer)  | 
|     return  | 
|   |