| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerActXianXiaMJ  | 
| #  | 
| # @todo:ÏÉÏ»ÃØ¾³  | 
| # @author hxp  | 
| # @date 2021-05-26  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ÏÉÏ»ÃØ¾³  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2021-05-26 11:30"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import PyGameData  | 
| import ShareDefine  | 
| import PlayerControl  | 
| import IpyGameDataPY  | 
| import ItemControler  | 
| import CrossRealmPlayer  | 
| import PlayerBillboard  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import PlayerActTask  | 
| import ItemCommon  | 
| import GameWorld  | 
| import ChConfig  | 
|   | 
| Def_SuperLibType = 9 # ´ó½±¿âÀàÐ͹̶¨Îª9  | 
|   | 
| def OnMixFirstLogin(curPlayer):  | 
|       | 
|     for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_XianXiaMJ, {}).values():  | 
|         actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)  | 
|         if not actInfo.get(ShareDefine.ActKey_State):  | 
|             continue  | 
|         score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJScore % actNum)  | 
|         if not score:  | 
|             continue  | 
|         GameWorld.Log("ÏÉÏ»ÃØ¾³ºÏ·þÊ×µÇͬ²½»ý·Ö°ñµ¥: actNum=%s,score=%s" % (actNum, score), curPlayer.GetPlayerID())  | 
|         PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_XianXiaMJScore, score, autoSort=True)  | 
|         break  | 
|       | 
|     return  | 
|   | 
| def OnPlayerLogin(curPlayer):  | 
|       | 
|     for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_XianXiaMJ, {}).values():  | 
|         actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)  | 
|         isReset = __CheckPlayerXianXiaMJAction(curPlayer, actNum)  | 
|         if not isReset:  | 
|             # »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢  | 
|             if actInfo.get(ShareDefine.ActKey_State):  | 
|                 Sync_XianXiaMJActionInfo(curPlayer, actNum)  | 
|                 Sync_XianXiaMJLayerInfo(curPlayer, actNum)  | 
|                   | 
|     if not __CheckPlayerCrossActXianXiaMJ(curPlayer):  | 
|         Sync_CrossActXianXiaMJActionInfo(curPlayer)  | 
|           | 
|     return  | 
|   | 
| def RefreshXianXiaMJActionInfo(actNum):  | 
|     ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢  | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     for index in xrange(playerManager.GetPlayerCount()):  | 
|         curPlayer = playerManager.GetPlayerByIndex(index)  | 
|         if not GameWorld.IsNormalPlayer(curPlayer):  | 
|             continue  | 
|         __CheckPlayerXianXiaMJAction(curPlayer, actNum)  | 
|     return  | 
|   | 
| def __CheckPlayerXianXiaMJAction(curPlayer, actNum):  | 
|     ## ¼ì²éÍæ¼Ò»î¶¯Êý¾ÝÐÅÏ¢  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)  | 
|     actID = actInfo.get(ShareDefine.ActKey_ID, 0)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|       | 
|     playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJID % actNum) # Íæ¼ÒÉíÉϵĻID  | 
|       | 
|     # »î¶¯ID ÏàͬµÄ»°²»´¦Àí  | 
|     if actID == playerActID:  | 
|         GameWorld.DebugLog("ÏÉÏ»ÃØ¾³»î¶¯ID²»±ä£¬²»´¦Àí£¡actNum=%s,actID=%s" % (actNum, actID), playerID)  | 
|           | 
|         layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)  | 
|         if state and layerNum <= 0:  | 
|             GameWorld.Log("ÏÉÏ»ÃØ¾³»î¶¯Öе«Êײ㽱³ØÎ´Ë¢Ð³õʼ»¯£¬³¢ÊÔˢУ¡actNum=%s,actID=%s" % (actNum, actID), playerID)  | 
|             __InitFirstLayerData(curPlayer, actNum, actInfo)  | 
|               | 
|         return  | 
|       | 
|     actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)  | 
|       | 
|     GameWorld.DebugLog("ÏÉÏ»ÃØ¾³ÖØÖÃ! actNum=%s,actID=%s,playerActID=%s,state=%s,cfgID=%s"   | 
|                        % (actNum, actID, playerActID, state, cfgID), playerID)  | 
|       | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJID % actNum, actID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJWorldLV % actNum, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJLayerNum % actNum, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJPlayCount % actNum, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJScore % actNum, 0)  | 
|       | 
|     if state:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJWorldLV % actNum, actWorldLV)  | 
|         Sync_XianXiaMJActionInfo(curPlayer, actNum)  | 
|         __InitFirstLayerData(curPlayer, actNum, actInfo)  | 
|     return True  | 
|   | 
| def __InitFirstLayerData(curPlayer, actNum, actInfo):  | 
|     ## ³õʼ»¯ÊײãÊý¾Ý  | 
|       | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID) if cfgID else None  | 
|     templateID = ipyData.GetTemplateID() if ipyData else 0  | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID) if templateID else []  | 
|     if awardIpyDataList:  | 
|         for awardIpyData in awardIpyDataList:  | 
|             libType = awardIpyData.GetAwardLibType()  | 
|             libItemCount = max(awardIpyData.GetAwardItemCountList())  | 
|             for num in xrange(libItemCount):  | 
|                 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), 0)  | 
|                   | 
|             itemAwardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()  | 
|             for itemID in itemAwardTimesTotalInfo.keys():  | 
|                 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID), 0)  | 
|                   | 
|         # »î¶¯ÖУ¬Éú³Éн±³Ø      | 
|         if state:  | 
|             __RefreshXianXiaMJAwardPool(curPlayer, actInfo, ipyData, awardIpyDataList)  | 
|               | 
|     Sync_XianXiaMJLayerInfo(curPlayer, actNum)  | 
|     return True  | 
|   | 
| def RefreshCrossActXianXiaMJInfo():  | 
|     ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢  | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     for index in xrange(playerManager.GetPlayerCount()):  | 
|         curPlayer = playerManager.GetPlayerByIndex(index)  | 
|         if not GameWorld.IsNormalPlayer(curPlayer):  | 
|             continue  | 
|         __CheckPlayerCrossActXianXiaMJ(curPlayer)  | 
|           | 
|     return  | 
|   | 
| def __CheckPlayerCrossActXianXiaMJ(curPlayer):  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|       | 
|     actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_XianXiaMJ)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|     actID = actInfo.get(ShareDefine.ActKey_ID, 0)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0)  | 
|       | 
|     playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_XianXiaMJID) # Íæ¼ÒÉíÉϵĻID  | 
|       | 
|     # »î¶¯ID ÏàͬµÄ»°²»´¦Àí  | 
|     if actID == playerActID:  | 
|         GameWorld.DebugLog("¿ç·þÏÉÏ»ÃØ¾³»î¶¯ID²»±ä£¬²»´¦Àí£¡cfgID=%s,dayIndex=%s,actID=%s" % (cfgID, dayIndex, actID), playerID)     | 
|         return  | 
|     GameWorld.DebugLog("¿ç·þÏÉÏ»ÃØ¾³»î¶¯ÖØÖÃ! cfgID=%s,actID=%s,playerActID=%s,state=%s" % (cfgID, actID, playerActID, state), playerID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_XianXiaMJID, actID)  | 
|       | 
|     if not state:  | 
|         CrossRealmPlayer.NotifyCrossActEnd(curPlayer, ShareDefine.CrossActName_XianXiaMJ)  | 
|           | 
|     Sync_CrossActXianXiaMJActionInfo(curPlayer)  | 
|     return True  | 
|   | 
| def SendToGameServer_XianXiaMJ(curPlayer, msgType, dataMsg=""):  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     msgList = str([msgType, dataMsg])  | 
|     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "XianXiaMJ", msgList, len(msgList))  | 
|     GameWorld.Log("ÏÉÏ»ÃØ¾³·¢ËÍGameServer: %s, %s" % (msgType, dataMsg), playerID)  | 
|     return  | 
|   | 
| def AddPlayerLotteryScore(curPlayer, actNum, addScore, isRelationCrossAct):  | 
|     if addScore <= 0:  | 
|         return 0  | 
|     lotteryScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJScore % actNum)  | 
|     updLotteryScore = lotteryScore + addScore  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJScore % actNum, updLotteryScore)  | 
|     PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_XianXiaMJScore, updLotteryScore, autoSort=True)  | 
|     SendToGameServer_XianXiaMJ(curPlayer, "AddLotteryScore", [addScore, updLotteryScore, isRelationCrossAct])  | 
|     return updLotteryScore  | 
|   | 
| def GetLayerSetByList(layerNum, setList):  | 
|     if not setList:  | 
|         return 0  | 
|     return setList[layerNum - 1] if len(setList) >= layerNum else setList[-1]  | 
|   | 
| #// AA 16 ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½± #tagCMActXianXiaMJSuperItem  | 
| #  | 
| #struct    tagCMActXianXiaMJSuperItem  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ActNum;        //»î¶¯±àºÅ  | 
| #    BYTE        SuperItemCount;    //Ñ¡ÔñÎïÆ·ÊýÁ¿  | 
| #    DWORD        SuperItemIDList[SuperItemCount];    //Ñ¡ÔñµÄ´ó½±¿âÎïÆ·IDÁÐ±í£¬Ã¿´ÎÖØÐÂÑ¡ÔñÐèÒª·¢ËÍÈ«²¿ÒÑÑ¡ÔñµÄ´ó½±ÎïÆ·ID£¬²»ÄÜÖ»·¢µ¥¸öÎïÆ·ID;  | 
| #};  | 
| def OnActXianXiaMJSuperItem(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     actNum = clientData.ActNum  | 
|     superItemIDList = clientData.SuperItemIDList  | 
|       | 
|     GameWorld.DebugLog("ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½±: actNum=%s,superItemIDList=%s" % (actNum, superItemIDList))  | 
|       | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)  | 
|     if not actInfo.get(ShareDefine.ActKey_State):  | 
|         GameWorld.DebugLog("    ·Ç»î¶¯ÖÐ!")  | 
|         return  | 
|       | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     templateID = ipyData.GetTemplateID()  | 
|     if not templateID:  | 
|         return  | 
|           | 
|     layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)  | 
|     actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)  | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)  | 
|     if not awardIpyDataList:  | 
|         return  | 
|       | 
|     superAwardIpyData = None  | 
|     for awardIpyData in awardIpyDataList:  | 
|         libType = awardIpyData.GetAwardLibType()  | 
|         if libType == Def_SuperLibType:  | 
|             superAwardIpyData = awardIpyData  | 
|             break  | 
|       | 
|     if not superAwardIpyData:  | 
|         GameWorld.ErrLog("ûÓÐÅäÖÃÏÉÏ»ÃØ¾³»î¶¯´ó½±¿â! cfgID=%s,actNum=%s,templateID=%s" % (cfgID, actNum, templateID))  | 
|         return  | 
|       | 
|     superLibItemCount = GetLayerSetByList(layerNum, superAwardIpyData.GetAwardItemCountList())  | 
|     if len(superItemIDList) != superLibItemCount:  | 
|         GameWorld.ErrLog("ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½±¸öÊý´íÎó! cfgID=%s,actNum=%s,templateID=%s,layerNum=%s,superLibItemCount=%s,reqSuperItemIDList=%s"   | 
|                          % (cfgID, actNum, templateID, layerNum, superLibItemCount, superItemIDList))          | 
|         return  | 
|       | 
|     posNumItemIDList = [] # ÒѳéÖеĴó½±ÎïÆ·ID  | 
|     libType = superAwardIpyData.GetAwardLibType()  | 
|     for num in xrange(superLibItemCount):  | 
|         itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))  | 
|         if not itemInfoValue:  | 
|             break  | 
|         itemID, posNum = itemInfoValue / 100, itemInfoValue % 100  | 
|         if posNum and itemID not in superItemIDList:  | 
|             GameWorld.ErrLog("ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ÒѳéÖеĴó½±IDΪ±ØÑ¡ID£¡ posNum=%s, itemID=%s not in superItemIDList=%s"   | 
|                              % (posNum, itemID, superItemIDList))  | 
|             return  | 
|           | 
|         if posNum:  | 
|             posNumItemIDList.append(itemID)  | 
|               | 
|     GameWorld.DebugLog("    ÒѳéÖеĴó½±ID! %s" % posNumItemIDList)  | 
|       | 
|       | 
|     libItemDict = __GetXianXiaMJAwardLibItem(superAwardIpyData.GetLibItemInfo(), actWorldLV)  | 
|     layerLimitInfo = superAwardIpyData.GetItemLayerLimitInfo()  | 
|     awardTimesTotalInfo = superAwardIpyData.GetItemAwardTimesTotalInfo()  | 
|       | 
|     replaceSuperItemIDList = [] # ÐèÒªÌæ»»µÄ´ó½±IDÁÐ±í  | 
|       | 
|     for selectItemID in superItemIDList:  | 
|         if selectItemID in posNumItemIDList:  | 
|             GameWorld.DebugLog("        ÒѳéÖеĴó½±ID£¬²»ÑéÖ¤£¡selectItemID=%s" % (selectItemID))  | 
|             continue  | 
|           | 
|         if selectItemID not in libItemDict:  | 
|             GameWorld.ErrLog("ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ´ó½±ID²»´æÔڴ󽱿âÖУ¡ selectItemID=%s not in libItemDict=%s"   | 
|                              % (selectItemID, libItemDict))  | 
|             return  | 
|           | 
|         layerLimit = layerLimitInfo.get(selectItemID, 0)  | 
|         if layerLimit > layerNum:  | 
|             GameWorld.ErrLog("ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ´ó½±ID¸Ã²ã²»ÄÜÑ¡Ôñ£¡ selectItemID=%s layerLimit(%s) > layerNum(%s)"   | 
|                              % (selectItemID, layerLimit, layerNum))  | 
|             return  | 
|           | 
|         totalTimesLimit = awardTimesTotalInfo.get(selectItemID, 0)  | 
|         if totalTimesLimit:  | 
|             totalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, selectItemID))  | 
|             if totalTimesNow >= totalTimesLimit:  | 
|                 GameWorld.ErrLog("ÏÉÏ»ÃØ¾³»î¶¯Ñ¡Ôñ´ó½±ID´íÎó! ´ó½±IDÒÑ´ïµ½×î´ó½±Àø´ÎÊý£¬²»ÄÜÑ¡Ôñ£¡ selectItemID=%s totalTimesNow(%s) >= totalTimesLimit(%s)"   | 
|                                  % (selectItemID, totalTimesNow, totalTimesLimit))  | 
|                 return  | 
|                   | 
|         replaceSuperItemIDList.append(selectItemID)  | 
|           | 
|     GameWorld.DebugLog("    Ñé֤ͨ¹ý£¬¿ÉÌæ»»´ó½±ID! replaceSuperItemIDList=%s" % replaceSuperItemIDList)  | 
|     if not replaceSuperItemIDList:  | 
|         return  | 
|       | 
|     for num in xrange(superLibItemCount):  | 
|         itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))  | 
|         itemID, posNum = itemInfoValue / 100, itemInfoValue % 100  | 
|         if itemID in posNumItemIDList:  | 
|             GameWorld.DebugLog("        ÒѳéÖеĴó½±ID£¬²»Ìæ»»£¡itemID=%s" % (itemID))  | 
|             continue  | 
|         replaceSuperItemID = replaceSuperItemIDList.pop(0)  | 
|         updItemInfoValue = replaceSuperItemID * 100 + posNum  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), updItemInfoValue)  | 
|         GameWorld.DebugLog("        Ìæ»»´ó½±IDÑ¡Ôñ£¡num=%s,itemID=%s,posNum=%s,replaceSuperItemID=%s,updItemInfoValue=%s"   | 
|                            % (num, itemID, posNum, replaceSuperItemID, updItemInfoValue))  | 
|           | 
|         if not replaceSuperItemIDList:  | 
|             break  | 
|           | 
|     Sync_XianXiaMJLayerInfo(curPlayer, actNum)  | 
|     return  | 
|   | 
| #// AA 18 ÏÉÏ»ÃØ¾³»î¶¯½±³ØË¢Ð #tagCMActXianXiaMJAwardPoolRefresh  | 
| #  | 
| #struct    tagCMActXianXiaMJAwardPoolRefresh  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ActNum;        //»î¶¯±àºÅ  | 
| #};  | 
| def OnActXianXiaMJAwardPoolRefresh(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     actNum = clientData.ActNum  | 
|       | 
|     GameWorld.DebugLog("ÏÉÏ»ÃØ¾³»î¶¯½±³ØË¢ÐÂ: actNum=%s" % (actNum))  | 
|       | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)  | 
|     if not actInfo.get(ShareDefine.ActKey_State):  | 
|         GameWorld.DebugLog("    ·Ç»î¶¯ÖÐ!")  | 
|         return  | 
|       | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     templateID = ipyData.GetTemplateID()  | 
|     if not templateID:  | 
|         return  | 
|       | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)  | 
|     if not awardIpyDataList:  | 
|         return  | 
|       | 
|     if not __RefreshXianXiaMJAwardPool(curPlayer, actInfo, ipyData, awardIpyDataList):  | 
|         return  | 
|       | 
|     Sync_XianXiaMJLayerInfo(curPlayer, actNum)  | 
|     return  | 
|   | 
| def __RefreshXianXiaMJAwardPool(curPlayer, actInfo, ipyData, awardIpyDataList):  | 
|     ## Ë¢Ð½±³ØÎïÆ·  | 
|       | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)  | 
|     actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)  | 
|     layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)  | 
|       | 
|     GameWorld.DebugLog("Ë¢ÐÂÏÉÏ»ÃØ¾³½±³ØÎïÆ·: cfgID=%s,actNum=%s,actWorldLV=%s,layerNum=%s" % (cfgID, actNum, actWorldLV, layerNum))  | 
|       | 
|     if layerNum:  | 
|         # ·Ç0²ã£¬ÑéÖ¤´ó½±ÊÇ·ñÒѳéÍ꣬³éÍê²Å¿ÉÒÔˢн±³Ø²ã  | 
|         superLib = False  | 
|         for awardIpyData in awardIpyDataList:  | 
|             libType = awardIpyData.GetAwardLibType()  | 
|             if libType != Def_SuperLibType:  | 
|                 continue  | 
|             superLib = True  | 
|             libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())  | 
|             for num in xrange(libItemCount):  | 
|                 itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))  | 
|                 if not itemInfoValue:  | 
|                     GameWorld.ErrLog("δѡÔñ´ó½±£¡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,layerNum=%s,num=%s"   | 
|                                      % (cfgID, actNum, layerNum, num))  | 
|                     return  | 
|                 itemID, posNum = itemInfoValue / 100, itemInfoValue % 100  | 
|                 if itemID and not posNum:  | 
|                     GameWorld.ErrLog("Óдó½±Î´³éÖУ¡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,layerNum=%s,num=%s,itemID=%s,posNum=%s"   | 
|                                      % (cfgID, actNum, layerNum, num, itemID, posNum))  | 
|                     return  | 
|             break  | 
|         if not superLib:  | 
|             GameWorld.ErrLog("½±³ØÅäÖÃûÓд󽱿⣡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,layerNum=%s,superLib=%s" % (cfgID, actNum, layerNum, superLib))  | 
|             return  | 
|           | 
|     layerNum = min(layerNum + 1, 65530) # ¿Éˢн±³Ø£¬Ä¬ÈÏ+1²ã  | 
|     GameWorld.DebugLog("    ¿Éˢн±³Ø£¡ÏÂÒ»²ã: layerNum=%s" % (layerNum))  | 
|       | 
|     refreshLibDict = {}  | 
|     for awardIpyData in awardIpyDataList:  | 
|         libType = awardIpyData.GetAwardLibType()  | 
|         libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())  | 
|         libItemDict = __GetXianXiaMJAwardLibItem(awardIpyData.GetLibItemInfo(), actWorldLV)  | 
|         layerLimitInfo = awardIpyData.GetItemLayerLimitInfo()  | 
|         awardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()  | 
|           | 
|         canRandItemDict = {}  | 
|         for itemID, libItemInfo in libItemDict.items():  | 
|             _, weight = libItemInfo  | 
|               | 
|             layerLimit = layerLimitInfo.get(itemID, 0)  | 
|             if layerLimit > layerNum:  | 
|                 GameWorld.DebugLog("        ¸Ã²ã²»ÄÜÑ¡Ôñ¸Ã½±Æ·£¡ itemID=%s layerLimit(%s) > layerNum(%s)"   | 
|                                  % (itemID, layerLimit, layerNum))  | 
|                 continue  | 
|               | 
|             totalTimesLimit = awardTimesTotalInfo.get(itemID, 0)  | 
|             if totalTimesLimit:  | 
|                 totalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID))  | 
|                 if totalTimesNow >= totalTimesLimit:  | 
|                     GameWorld.DebugLog("        ½±Æ·IDÒÑ´ïµ½×î´ó½±Àø´ÎÊý£¬²»ÄÜÑ¡Ôñ£¡ itemID=%s totalTimesNow(%s) >= totalTimesLimit(%s)"   | 
|                                        % (itemID, totalTimesNow, totalTimesLimit))  | 
|                     continue  | 
|                   | 
|             canRandItemDict[itemID] = [weight, itemID]  | 
|               | 
|         if libItemCount > len(canRandItemDict):  | 
|             GameWorld.ErrLog("½±Æ·¿âÅäÖÿÉÑ¡Ôñ½±Æ·¸öÊý²»¹»£¡ÎÞ·¨Ë¢Ð½±³Ø! cfgID=%s,actNum=%s,libType=%s,layerNum=%s,libItemCount=%s > %s canRandItemDict(%s)"   | 
|                              % (cfgID, actNum, libType, layerNum, libItemCount, len(canRandItemDict), canRandItemDict))  | 
|             return  | 
|           | 
|         refreshLibDict[libType] = [libItemCount, canRandItemDict]  | 
|           | 
|     for libType, refreshInfo in refreshLibDict.items():  | 
|         libItemCount, canRandItemDict = refreshInfo  | 
|         GameWorld.DebugLog("    Ëæ»ú½±³ØÎïÆ·: libType=%s,libItemCount=%s,canRandItemDict=%s, %s" % (libType, libItemCount, len(canRandItemDict), canRandItemDict))  | 
|           | 
|         if libType == Def_SuperLibType:  | 
|             # ´ó½±Ö±½ÓÖØÖã¬ÏµÍ³²»Éú³É£¬ÓÉÍæ¼ÒÊÖ¶¯Ñ¡Ôñ  | 
|             for num in xrange(libItemCount):  | 
|                 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), 0)  | 
|             continue  | 
|           | 
|         for num in xrange(libItemCount):  | 
|             weightList = canRandItemDict.values()  | 
|             randItemID = GameWorld.GetResultByWeightList(weightList)  | 
|             canRandItemDict.pop(randItemID, None)  | 
|               | 
|             posNum = 0  | 
|             itemInfoValue = randItemID * 100 + posNum  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), itemInfoValue)  | 
|             GameWorld.DebugLog("        Ëæ»úÉú³É½±Æ·! libType=%s,num=%s,randItemID=%s" % (libType, num, randItemID))  | 
|               | 
|     playCount = 0 # Ã¿²ãÖØÖó齱´ÎÊý  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJLayerNum % actNum, layerNum)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJPlayCount % actNum, playCount)  | 
|     GameWorld.DebugLog("    Ë¢ÐÂÍê³É! layerNum=%s,playCount=%s" % (layerNum, playCount))  | 
|     PlayerActTask.UpdActTaskValue(curPlayer, ChConfig.ActTaskType_XianXiaMJLayer, layerNum)  | 
|     if layerNum > 1:  | 
|         AddPlayerLotteryScore(curPlayer, actNum, ipyData.GetLayerAddScore(), ipyData.GetIsRelationCrossAct())  | 
|     return True  | 
|   | 
| #// AA 17 ÏÉÏ»ÃØ¾³»î¶¯³é½± #tagCMActXianXiaMJLottery  | 
| #  | 
| #struct    tagCMActXianXiaMJLottery  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ActNum;        //»î¶¯±àºÅ  | 
| #    BYTE        PosNum;        //Íæ¼Òµã»÷µÄ½±ÀøÎ»ÖñàºÅ£¬´Ó1¿ªÊ¼  | 
| #};  | 
| def OnActXianXiaMJLottery(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     actNum = clientData.ActNum  | 
|     reqPosNum = clientData.PosNum  | 
|       | 
|     GameWorld.DebugLog("ÏÉÏ»ÃØ¾³»î¶¯³é½±: actNum=%s,reqPosNum=%s" % (actNum, reqPosNum))  | 
|       | 
|     if reqPosNum <= 0:  | 
|         return  | 
|       | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)  | 
|     if not actInfo.get(ShareDefine.ActKey_State):  | 
|         GameWorld.DebugLog("    ·Ç»î¶¯ÖÐ!")  | 
|         return  | 
|           | 
|     playerID = curPlayer.GetPlayerID()  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     if ipyData.GetIsRelationCrossAct():  | 
|         crossActInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_XianXiaMJ)  | 
|         if crossActInfo.get(ShareDefine.ActKey_State, 0):  | 
|             if crossActInfo.get(ShareDefine.ActKey_StateJoin) != ShareDefine.ActStateJoin_Start:  | 
|                 GameWorld.Log("¿ç·þÏÉÏ»ÃØ¾³·Ç²ÎÓë»î¶¯ÖÐ: actNum=%s" % actNum, playerID)  | 
|                 return  | 
|     else:  | 
|         if actInfo.get(ShareDefine.ActKey_StateJoin) != ShareDefine.ActStateJoin_Start:  | 
|             GameWorld.Log("ÏÉÏ»ÃØ¾³·Ç²ÎÓë»î¶¯ÖÐ: actNum=%s" % actNum, playerID)  | 
|             return  | 
|           | 
|     templateID = ipyData.GetTemplateID()  | 
|     if not templateID:  | 
|         return  | 
|       | 
|     actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)  | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)  | 
|     if not awardIpyDataList:  | 
|         return  | 
|       | 
|     checkUseMoney = False  | 
|     costItemID = ipyData.GetUseItemID()  | 
|     costItemCount = 1  | 
|     if costItemID:  | 
|         costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)  | 
|         lackCnt = costItemCount - bindCnt - unBindCnt  | 
|         if lackCnt > 0:  | 
|             checkUseMoney = True  | 
|     else:  | 
|         checkUseMoney = True  | 
|           | 
|     costMoneyType, costMoneyValue = ipyData.GetUseMoneyInfo()  | 
|     if checkUseMoney:  | 
|         if not costMoneyType or not costMoneyValue:  | 
|             return  | 
|         if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue):  | 
|             GameWorld.DebugLog("    »õ±Ò²»×㣬ÎÞ·¨³é½±! costMoneyType=%s,costMoneyValue(%s) > curMoneyValue(%s)"   | 
|                                % (costMoneyType, costMoneyValue, PlayerControl.GetMoney(curPlayer, costMoneyType)))  | 
|             return  | 
|           | 
|     layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)  | 
|     playCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJPlayCount % actNum)  | 
|     GameWorld.DebugLog("layerNum=%s,playCount=%s" % (layerNum, playCount))  | 
|       | 
|     posNumMax = 0  | 
|     randLibItemDict = {}  | 
|     for awardIpyData in awardIpyDataList:  | 
|         libType = awardIpyData.GetAwardLibType()  | 
|         libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())  | 
|         unlockLimitTimes = GetLayerSetByList(layerNum, awardIpyData.GetUnlockAwardLimitTimesList())  | 
|         libWeight = GetLayerSetByList(layerNum, awardIpyData.GetAwardLibWeightList())  | 
|         posNumMax += libItemCount  | 
|           | 
|         if libType == Def_SuperLibType:  | 
|             for num in xrange(libItemCount):  | 
|                 itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))  | 
|                 if not itemInfoValue:  | 
|                     GameWorld.DebugLog("    Î´Ñ¡Ôñ´ó½±£¡ÎÞ·¨³é½±! libType=%s,num=%s,itemInfoValue=%s" % (libType, num, itemInfoValue))           | 
|                     return  | 
|                   | 
|         if unlockLimitTimes and playCount < unlockLimitTimes:  | 
|             GameWorld.DebugLog("    ¸Ã¿âµ±Ç°³é½±´ÎÊýÎÞ·¨½âËø! libType=%s,playCount(%s) < unlockLimitTimes(%s)" % (libType, playCount, unlockLimitTimes))  | 
|             continue  | 
|           | 
|         awardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()  | 
|         libItemDict = __GetXianXiaMJAwardLibItem(awardIpyData.GetLibItemInfo(), actWorldLV)  | 
|         canRandItemList = []  | 
|         for num in xrange(libItemCount):  | 
|             itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))  | 
|             if not itemInfoValue:              | 
|                 return  | 
|               | 
|             itemID, posNum = itemInfoValue / 100, itemInfoValue % 100  | 
|             if itemID not in libItemDict:  | 
|                 continue  | 
|               | 
|             if posNum:  | 
|                 GameWorld.DebugLog("    ¸Ã½±Æ·Òѱ»³éÖÐ! libType=%s,itemID=%s,posNum=%s" % (libType, itemID, posNum))  | 
|                 if posNum == reqPosNum:  | 
|                     GameWorld.ErrLog("    ¸ÃλÖÃÒѾÓг齱½á¹û£¬ÎÞ·¨Öظ´Ñ¡Ôñ³é½±! libType=%s,num=%s,itemInfoValue=%s,posNum=%s"   | 
|                                      % (libType, num, itemInfoValue, posNum))                  | 
|                     return                  | 
|                 continue  | 
|               | 
|             itemCount, weight = libItemDict[itemID]  | 
|             isAddTimes = (itemID in awardTimesTotalInfo)  | 
|             canRandItemList.append([weight, itemID, itemCount, num, isAddTimes])  | 
|               | 
|         if canRandItemList:  | 
|             randLibItemDict[libType] = [libWeight, libType, canRandItemList]  | 
|             GameWorld.DebugLog("    ¸Ã¿âÓлú»á³éµ½ÎïÆ·: libType=%s,libWeight=%s,canRandItemList=%s" % (libType, libWeight, canRandItemList))  | 
|         else:  | 
|             GameWorld.DebugLog("    ¸Ã¿âÎïÆ·ÒÑÈ«±»³éÍê: libType=%s,libWeight=%s,canRandItemList=%s" % (libType, libWeight, canRandItemList))  | 
|               | 
|     if reqPosNum > posNumMax:  | 
|         GameWorld.DebugLog("    ÇëÇóλÖÃÒì³££¬ÎÞ·¨³é½±! reqPosNum(%s) > posNumMax(%s)" % (reqPosNum, posNumMax))  | 
|         return  | 
|       | 
|     if not randLibItemDict:  | 
|         GameWorld.DebugLog("    Ã»Óпɳ齱µÄ½±Æ·ÁË£¬ÎÞ·¨³é½±!")  | 
|         return  | 
|       | 
|     randLibInfo = GameWorld.GetResultByWeightList(randLibItemDict.values())  | 
|     if not randLibInfo:  | 
|         return  | 
|     libType, canRandItemList = randLibInfo  | 
|     randItemInfo = GameWorld.GetResultByWeightList(canRandItemList)  | 
|     if not randItemInfo:  | 
|         return  | 
|     itemID, itemCount, num, isAddTimes = randItemInfo  | 
|       | 
|     # ¿Û³ýÏûºÄ  | 
|     if checkUseMoney:  | 
|         PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, "ActXianXiaMJ")  | 
|         GameWorld.DebugLog("ÏûºÄ»õ±Ò: costMoneyType=%s,costMoneyValue=%s" % (costMoneyType, costMoneyValue))  | 
|     else:  | 
|         GameWorld.DebugLog("ÏûºÄµÀ¾ß: costItemID=%s,costItemCount=%s %s" % (costItemID, costItemCount, costItemIndexList))  | 
|         ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, costItemCount, "XianXiaMJ")  | 
|           | 
|     # ¸üÐÂÒѳéÖÐÖµ  | 
|     updItemInfoValue = itemID * 100 + reqPosNum  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num), updItemInfoValue)  | 
|       | 
|     totalTimesNow = 0  | 
|     if isAddTimes:  | 
|         totalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID)) + 1  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID), totalTimesNow)  | 
|           | 
|     playCount += 1  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XianXiaMJPlayCount % actNum, playCount)  | 
|       | 
|     GameWorld.DebugLog("    ³éÖÐÎïÆ·: layerNum=%s,libType=%s,itemID=%s,itemCount=%s,num=%s,reqPosNum=%s,updItemInfoValue=%s,totalTimesNow=%s,playCount=%s"   | 
|                        % (layerNum, libType, itemID, itemCount, num, reqPosNum, updItemInfoValue, totalTimesNow, playCount))  | 
|       | 
|     # ¸øÎïÆ·  | 
|     isAuctionItem = 0  | 
|     itemList = [[itemID, itemCount, isAuctionItem]]  | 
|     ItemControler.GivePlayerItemOrMail(curPlayer, itemList, event=["XianXiaMJLottery", False, {}])  | 
|       | 
|     # ÈÎÎñ  | 
|     PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_XianXiaMJLottery, 1)  | 
|       | 
|     # ¹ã²¥  | 
|     if libType == Def_SuperLibType:  | 
|         PlayerControl.WorldNotify(0, "XianXiaMJ%s" % actNum, [curPlayer.GetPlayerName(), itemID, itemCount])  | 
|           | 
|     # »ý·Ö  | 
|     lotteryScore = AddPlayerLotteryScore(curPlayer, actNum, ipyData.GetLotteryAddScore(), ipyData.GetIsRelationCrossAct())  | 
|       | 
|     # Í¨Öª³é½±½á¹û  | 
|     clientPack = ChPyNetSendPack.tagMCActXianXiaMJAwardItemResult()  | 
|     clientPack.ActNum = actNum  | 
|     clientPack.ItemLibType = libType  | 
|     clientPack.ItemID = itemID  | 
|     clientPack.ItemCount = itemCount  | 
|     clientPack.PosNum = reqPosNum  | 
|     clientPack.TotalTimesNow = totalTimesNow  | 
|     clientPack.LotteryScore = lotteryScore  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def Sync_XianXiaMJActionInfo(curPlayer, actNum):  | 
|     ## Í¨Öª»î¶¯ÐÅÏ¢  | 
|       | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)  | 
|     if not actInfo.get(ShareDefine.ActKey_State):  | 
|         return  | 
|       | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|     costMoneyType, costMoneyValue = ipyData.GetUseMoneyInfo()  | 
|       | 
|     personalTempID = ipyData.GetPersonalTemplateID()  | 
|     personalTempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJBillTemp", personalTempID) if personalTempID else []  | 
|       | 
|     startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)  | 
|       | 
|     clientPack = ChPyNetSendPack.tagMCActXianXiaMJInfo()  | 
|     clientPack.ActNum = actNum  | 
|     clientPack.StartDate = startDateStr  | 
|     clientPack.EndtDate = endDateStr  | 
|     clientPack.JoinStartTime = ipyData.GetJoinStartTime()  | 
|     clientPack.JoinEndTime = ipyData.GetJoinEndTime()  | 
|     clientPack.IsDayReset = ipyData.GetIsDayReset()  | 
|     clientPack.LimitLV = ipyData.GetLVLimit()  | 
|     clientPack.UseItemID = ipyData.GetUseItemID()  | 
|     clientPack.MoneyType = costMoneyType  | 
|     clientPack.MoneyValue = costMoneyValue  | 
|     clientPack.LotteryAddScore = ipyData.GetLotteryAddScore()  | 
|     clientPack.LayerAddScore = ipyData.GetLayerAddScore()  | 
|       | 
|     clientPack.PersonalBillboardInfoList = __GetTempRankBillPackList(personalTempIpyDataList)  | 
|     clientPack.PersonalBillCount = len(clientPack.PersonalBillboardInfoList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def __GetXianXiaMJAwardLibItem(libItemInfo, actWorldLV):  | 
|     ## »ñÈ¡½±Àø¿âÎïÆ·ÐÅÏ¢×ֵ䣬֧³Ö°´ÊÀ½çµÈ¼¶·¶Î§ÅäÖõĸñʽ  | 
|     keyList = libItemInfo.keys()  | 
|     if not keyList:  | 
|         return {}  | 
|     if isinstance(keyList[0], tuple) and len(keyList[0]) == 2:  | 
|         return GameWorld.GetDictValueByRangeKey(libItemInfo, actWorldLV, {})  | 
|     return libItemInfo  | 
|   | 
| def Sync_XianXiaMJLayerInfo(curPlayer, actNum):  | 
|       | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_XianXiaMJ, actNum)  | 
|     if not actInfo.get(ShareDefine.ActKey_State):  | 
|         return  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActXianXiaMJ", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     templateID = ipyData.GetTemplateID()  | 
|     if not templateID:  | 
|         return  | 
|     actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJWorldLV % actNum)  | 
|     layerNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJLayerNum % actNum)  | 
|       | 
|     clientPack = ChPyNetSendPack.tagMCActXianXiaMJLayerInfo()  | 
|     clientPack.ActNum = actNum  | 
|     clientPack.LayerNum = layerNum  | 
|     clientPack.LotteryScore = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJScore % actNum)  | 
|     clientPack.AwardItemList = [] # ½±³ØÎïÆ·ÁÐ±í  | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJAward", templateID)  | 
|     if awardIpyDataList:  | 
|         for awardIpyData in awardIpyDataList:  | 
|             libType = awardIpyData.GetAwardLibType()  | 
|             libItemCount = GetLayerSetByList(layerNum, awardIpyData.GetAwardItemCountList())  | 
|             libItemDict = __GetXianXiaMJAwardLibItem(awardIpyData.GetLibItemInfo(), actWorldLV)  | 
|             layerLimitInfo = awardIpyData.GetItemLayerLimitInfo()  | 
|             awardTimesTotalInfo = awardIpyData.GetItemAwardTimesTotalInfo()  | 
|               | 
|             # ½±³ØÎïÆ·ÁÐ±í£¬ÒÑÉú³ÉµÄ£¬°üº¬ÒÑÑ¡ÔñµÄ´ó½±ÎïÆ·  | 
|             for num in xrange(libItemCount):  | 
|                 itemInfoValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemInfo % (actNum, libType, num))  | 
|                 if not itemInfoValue:  | 
|                     break  | 
|                 itemID, posNum = itemInfoValue / 100, itemInfoValue % 100  | 
|                 if itemID not in libItemDict:  | 
|                     continue  | 
|                 libItemInfo = libItemDict[itemID]  | 
|                   | 
|                 layerItem = ChPyNetSendPack.tagMCActXianXiaMJLayerItem()  | 
|                 layerItem.ItemLibType = libType  | 
|                 layerItem.ItemID = itemID  | 
|                 layerItem.ItemCount = libItemInfo[0]  | 
|                 layerItem.PosNum = posNum  | 
|                 layerItem.TotalTimesMax = awardTimesTotalInfo.get(itemID, 0)  | 
|                 layerItem.TotalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID))  | 
|                 layerItem.LayerLimit = layerLimitInfo.get(itemID, 0)  | 
|                 clientPack.AwardItemList.append(layerItem)  | 
|                   | 
|             # ´ó½±ÎïÆ·´ýÑ¡Ôñ¿â£¬È«²¿Í¬²½  | 
|             if libType == Def_SuperLibType:  | 
|                 for itemID, libItemInfo in libItemDict.items():  | 
|                     layerItem = ChPyNetSendPack.tagMCActXianXiaMJLayerItem()  | 
|                     layerItem.ItemLibType = libType  | 
|                     layerItem.ItemID = itemID  | 
|                     layerItem.ItemCount = libItemInfo[0]  | 
|                     layerItem.TotalTimesMax = awardTimesTotalInfo.get(itemID, 0)  | 
|                     layerItem.TotalTimesNow = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XianXiaMJAwardItemTimes % (actNum, libType, itemID))  | 
|                     layerItem.LayerLimit = layerLimitInfo.get(itemID, 0)  | 
|                     clientPack.SuperItemList.append(layerItem)  | 
|                 clientPack.SuperItemCount = len(clientPack.SuperItemList)  | 
|                 clientPack.SuperItemCanChooseCount = libItemCount  | 
|                   | 
|     clientPack.AwardItemCount = len(clientPack.AwardItemList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def Sync_CrossActXianXiaMJActionInfo(curPlayer):  | 
|     ## Í¨Öª»î¶¯ÐÅÏ¢  | 
|     actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_XianXiaMJ)  | 
|     if not actInfo:  | 
|         return  | 
|       | 
|     if not actInfo.get(ShareDefine.ActKey_State):  | 
|         return  | 
|       | 
|     ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {})  | 
|     if not ipyDataDict:  | 
|         return  | 
|       | 
|     personalTempID = ipyDataDict.get("PersonalTemplateID", 0)  | 
|     personalTempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActXianXiaMJBillTemp", personalTempID) if personalTempID else []  | 
|       | 
|     clientPack = ChPyNetSendPack.tagMCCrossActXianXiaMJInfo()  | 
|     clientPack.ServerIDRangeInfo = str(actInfo.get(ShareDefine.ActKey_ServerIDRangeList, []))  | 
|     clientPack.ServerInfoLen = len(clientPack.ServerIDRangeInfo)  | 
|     clientPack.GroupValue1 = ipyDataDict.get("ZoneID", 0)  | 
|     clientPack.StartDate = ipyDataDict.get("StartDate", "")  | 
|     clientPack.EndtDate = ipyDataDict.get("EndDate", "")  | 
|     clientPack.JoinStartTime = ipyDataDict.get("JoinStartTime", "")  | 
|     clientPack.JoinEndTime = ipyDataDict.get("JoinEndTime", "")  | 
|     clientPack.IsDayReset = ipyDataDict.get("IsDayReset", 0)  | 
|       | 
|     clientPack.PersonalBillboardInfoList = __GetTempRankBillPackList(personalTempIpyDataList)  | 
|     clientPack.PersonalBillCount = len(clientPack.PersonalBillboardInfoList)  | 
|       | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def __GetTempRankBillPackList(ipyDataList):  | 
|     packBillList = []  | 
|     if not ipyDataList:  | 
|         return packBillList  | 
|     for tempIpyData in ipyDataList:  | 
|         rankInfo = ChPyNetSendPack.tagMCActXianXiaMJBillard()  | 
|         rankInfo.Rank = tempIpyData.GetRank()  | 
|           | 
|         rankInfo.AwardItemList = []  | 
|         awardItemList = tempIpyData.GetAwardItemList()  | 
|         for itemID, itemCount, isAuctionItem in awardItemList:  | 
|             item = ChPyNetSendPack.tagMCActXianXiaMJItem()  | 
|             item.Clear()  | 
|             item.ItemID = itemID  | 
|             item.ItemCount = itemCount  | 
|             item.IsBind = isAuctionItem  | 
|             rankInfo.AwardItemList.append(item)  | 
|         rankInfo.Count = len(rankInfo.AwardItemList)  | 
|           | 
| #        rankInfo.MemAwardItemList = []  | 
| #        memAwardItemList = tempIpyData.GetMemAwardItemList()  | 
| #        for itemID, itemCount, isAuctionItem in memAwardItemList:  | 
| #            item = ChPyNetSendPack.tagMCActXianXiaMJItem()  | 
| #            item.Clear()  | 
| #            item.ItemID = itemID  | 
| #            item.ItemCount = itemCount  | 
| #            item.IsBind = isAuctionItem  | 
| #            rankInfo.MemAwardItemList.append(item)  | 
| #        rankInfo.MemCount = len(rankInfo.MemAwardItemList)  | 
|           | 
|         rankInfo.NeedScore = tempIpyData.GetNeedScore()  | 
|         rankInfo.AwardItemExList = []  | 
|         scoreAwardEx = tempIpyData.GetScoreAwardEx()  | 
|         scoreExList = scoreAwardEx.keys()  | 
|         scoreExList.sort()  | 
|         for scoreEx in scoreExList:  | 
|             itemExList = scoreAwardEx[scoreEx]  | 
|             awardEx = ChPyNetSendPack.tagMCActXianXiaMJAwardEx()  | 
|             awardEx.NeedScore = scoreEx  | 
|             awardEx.AwardItemList = []  | 
|             for itemID, itemCount, isAuctionItem in itemExList:  | 
|                 item = ChPyNetSendPack.tagMCActXianXiaMJItem()  | 
|                 item.Clear()  | 
|                 item.ItemID = itemID  | 
|                 item.ItemCount = itemCount  | 
|                 item.IsBind = isAuctionItem  | 
|                 awardEx.AwardItemList.append(item)  | 
|             awardEx.Count = len(awardEx.AwardItemList)  | 
|               | 
|             rankInfo.AwardItemExList.append(awardEx)  | 
|         rankInfo.CountEx = len(rankInfo.AwardItemExList)  | 
|           | 
|         packBillList.append(rankInfo)  | 
|     return packBillList  |