| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerTongTianLing  | 
| #  | 
| # @todo:ͨÌìÁî  | 
| # @author hxp  | 
| # @date 2022-01-17  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: Í¨ÌìÁî  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2022-01-17 19:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import GameWorld  | 
| import ShareDefine  | 
| import PlayerControl  | 
| import IpyGameDataPY  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import ItemControler  | 
| import ChConfig  | 
| import time  | 
|   | 
| TTL_LVAwardKeyCount = 2  | 
| TTL_TaskAwardKeyCount = 9  | 
|   | 
| def OnPlayerLogin(curPlayer):  | 
|     if CheckTongTianLingReset(curPlayer):  | 
|         return  | 
|     SyncTongTianLVInfo(curPlayer)  | 
|     SyncTongTianTaskInfo(curPlayer)  | 
|     SyncTongTianTaskAward(curPlayer)  | 
|     return  | 
|   | 
| def OnDay(curPlayer, onEventType):  | 
|       | 
|     if onEventType == ShareDefine.Def_OnEventType:  | 
|         # ³£¹æÊ±¼ä0µã¹ýÌì¼ì²éÖØÖà  | 
|         if CheckTongTianLingReset(curPlayer):  | 
|             return  | 
|         return  | 
|       | 
|     resetTaskTypeList, resetTaskIDList = [], []  | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     for index in xrange(ipyDataMgr.GetTongTianTaskCount()):  | 
|         ipyData = ipyDataMgr.GetTongTianTaskByIndex(index)  | 
|         if not ipyData.GetIsDailyTask():  | 
|             continue  | 
|         ttTaskID = ipyData.GetTTTaskID()  | 
|         ttTaskType = ipyData.GetTTTaskType()  | 
|         resetTaskTypeList.append(ttTaskType)  | 
|           | 
|         if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_TaskAwardRecord, ttTaskID):  | 
|             GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_TaskAwardRecord, ttTaskID, 0)  | 
|             resetTaskIDList.append(ttTaskID)  | 
|               | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_DailyTaskPointToday, 0)  | 
|     isDailyTask = 1 # Ö»´¦ÀíÿÈÕÖØÖõÄÈÎÎñ  | 
|     syncTaskInfoList = []  | 
|     for ttTaskType in resetTaskTypeList:  | 
|         curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask))  | 
|         if not curValue:  | 
|             continue  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask), 0)  | 
|         syncTaskInfoList.append([ttTaskType, isDailyTask])  | 
|           | 
|     if syncTaskInfoList:  | 
|         #GameWorld.DebugLog("ÖØÖÃͨÌìÈÎÎñ½ø¶È: syncTaskInfoList=%s" % syncTaskInfoList)  | 
|         SyncTongTianTaskInfo(curPlayer, syncTaskInfoList)  | 
|           | 
|     if resetTaskIDList:  | 
|         #GameWorld.DebugLog("ÖØÖÃͨÌìÈÎÎñ½±Àø: resetTaskIDList=%s" % resetTaskIDList)  | 
|         SyncTongTianTaskAward(curPlayer)  | 
|           | 
|     return  | 
|   | 
| def CheckTongTianLingReset(curPlayer):  | 
|     ## ¼ì²éͨÌìÁîÖØÖà  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     resetDays = IpyGameDataPY.GetFuncCfg("TongTianLing", 4)  | 
|     if resetDays <= 0:  | 
|         return  | 
|       | 
|     curTime = int(time.time())  | 
|     startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_StartTime)  | 
|     passDays = GameWorld.GetDiff_Day(curTime, startTime) + 1  | 
|     if passDays <= resetDays:  | 
|         GameWorld.DebugLog("ͨÌìÁî±¾ÂÖÌìÊýδÍ꣬²»ÖØÖÃ! startTime(%s),passDays=%s <= %s"   | 
|                            % (GameWorld.ChangeTimeNumToStr(startTime), passDays, resetDays), playerID)  | 
|         return  | 
|       | 
|     syncTaskInfoList = []  | 
|     for ttTaskType in ChConfig.TTLTaskTypeList:  | 
|         for isDailyTask in [0, 1]:  | 
|             curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask))  | 
|             if not curValue:  | 
|                 continue  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask), 0)  | 
|             syncTaskInfoList.append([ttTaskType, isDailyTask])  | 
|               | 
|     for i in xrange(TTL_LVAwardKeyCount):  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_CommAwardRecord % i, 0)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_XianAwardRecord % i, 0)  | 
|           | 
|     for i in xrange(TTL_TaskAwardKeyCount):  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_TaskAwardRecord % i, 0)  | 
|           | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_StartTime, curTime)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_LVInfo, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_LVPoint, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_DailyTaskPointToday, 0)  | 
|       | 
|     GameWorld.Log("ͨÌìÁîÖØÖÃ! StartTime=%s" % curTime, playerID)  | 
|     SyncTongTianLVInfo(curPlayer)  | 
|     SyncTongTianTaskInfo(curPlayer, syncTaskInfoList)  | 
|     SyncTongTianTaskAward(curPlayer)  | 
|     return True  | 
|   | 
| def GetTongTianLingLVInfo(curPlayer):  | 
|     ## »ñȡͨÌìÁîµÈ¼¶×´Ì¬ÐÅÏ¢  | 
|     # @return: Í¨ÌìÁîµÈ¼¶, ÊÇ·ñ¼¤»îͨÌìÁî  | 
|     lvInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_LVInfo)  | 
|     ttLV, ttState = lvInfo / 10, lvInfo % 10  | 
|     return ttLV, ttState  | 
|   | 
| def SetTongTianLingLVInfo(curPlayer, ttLV, ttState):  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_LVInfo, ttLV * 10 + ttState)  | 
|     return  | 
|   | 
| def AddTongTianTaskValue(curPlayer, ttTaskType, addValue):  | 
|     ## Ôö¼ÓͨÌìÁîÈÎÎñ½ø¶È  | 
|       | 
|     taskIpyList = IpyGameDataPY.GetIpyGameDataByCondition("TongTianTask", {"TTTaskType":ttTaskType}, True, False)  | 
|     if not taskIpyList:  | 
|         return  | 
|       | 
|     addValueDict = {}  | 
|     for ipyData in taskIpyList:  | 
|         taskID = ipyData.GetTTTaskID()  | 
|         if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_TaskAwardRecord, taskID):  | 
|             # ÒÑÁì½±µÄ²»ÔÙ´¦Àí  | 
|             continue  | 
|         isDailyTask = ipyData.GetIsDailyTask()  | 
|         finishNeedValue = ipyData.GetFinishNeedValue()  | 
|         maxValue = addValueDict.get((ttTaskType, isDailyTask), 0)  | 
|         if finishNeedValue > maxValue:  | 
|             addValueDict[(ttTaskType, isDailyTask)] = finishNeedValue  | 
|               | 
|     syncTaskInfoList = []  | 
|     for key, finishNeedValue in addValueDict.items():  | 
|         ttTaskType, isDailyTask = key  | 
|         curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask))  | 
|         if curValue >= finishNeedValue:  | 
|             continue  | 
|         updValue = min(curValue + addValue, finishNeedValue)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask), updValue)  | 
|         #GameWorld.DebugLog("¸üÐÂͨÌìÁîÈÎÎñ½ø¶È: ttTaskType=%s,isDailyTask=%s,curValue=%s,addValue=%s,updValue=%s"   | 
|         #                   % (ttTaskType, isDailyTask, curValue, addValue, updValue), curPlayer.GetPlayerID())  | 
|         syncTaskInfoList.append([ttTaskType, isDailyTask])  | 
|           | 
|     if syncTaskInfoList:  | 
|         SyncTongTianTaskInfo(curPlayer, syncTaskInfoList)  | 
|           | 
|     return  | 
|   | 
| def AddTongTianPoint(curPlayer, addPoint):  | 
|     ## Ôö¼ÓͨÌìÁî¾Ñéµã  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     ttLV, ttState = GetTongTianLingLVInfo(curPlayer)  | 
|     ttPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_LVPoint)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("TongTianLV", ttLV)  | 
|     if not ipyData:  | 
|         return  | 
|     lvUPPoint = ipyData.GetLVUPPoint()  | 
|     if not lvUPPoint:  | 
|         GameWorld.DebugLog("ͨÌìÁîÒÑÂú¼¶!", playerID)  | 
|         return  | 
|     updLV = ttLV  | 
|     updPoint = ttPoint + addPoint  | 
|     GameWorld.DebugLog("Ôö¼ÓͨÌìÁî¾Ñé: ttLV=%s,ttPoint=%s,addPoint=%s,updPoint=%s,lvUPPoint=%s"   | 
|                        % (ttLV, ttPoint, addPoint, updPoint, lvUPPoint), playerID)  | 
|     doCount = 0  | 
|     while lvUPPoint and updPoint >= lvUPPoint and doCount < 50:  | 
|         doCount += 1  | 
|         updPoint -= lvUPPoint  | 
|         updLV += 1  | 
|         nextLVIPYData = IpyGameDataPY.GetIpyGameDataNotLog("TongTianLV", updLV)  | 
|         lvUPPoint = nextLVIPYData.GetLVUPPoint() if nextLVIPYData else 0  | 
|         GameWorld.DebugLog("    Í¨ÌìÁîÉý¼¶: updLV=%s,updPoint=%s,nextLVUPPoint=%s" % (updLV, updPoint, lvUPPoint), playerID)  | 
|           | 
|     SetTongTianLingLVInfo(curPlayer, updLV, ttState)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_LVPoint, updPoint)  | 
|     SyncTongTianLVInfo(curPlayer)  | 
|     return updLV, updPoint  | 
|   | 
| #// A5 43 Í¨ÌìÁîÁìÈ¡ÈÎÎñ½±Àø #tagCMGetTongTianTaskAward  | 
| #  | 
| #struct    tagCMGetTongTianTaskAward  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        TaskID;    // ÈÎÎñID  | 
| #};  | 
| def OnGetTongTianTaskAward(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     ttTaskID = clientData.TaskID  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("TongTianTask", ttTaskID)  | 
|     if not ipyData:  | 
|         return  | 
|       | 
|     if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_TaskAwardRecord, ttTaskID):  | 
|         GameWorld.DebugLog("ͨÌìÈÎÎñÒÑÁì½±! ttTaskID=%s" % ttTaskID, playerID)  | 
|         return  | 
|       | 
|     ttTaskType = ipyData.GetTTTaskType()  | 
|     isDailyTask = ipyData.GetIsDailyTask()  | 
|     finishNeedValue = ipyData.GetFinishNeedValue()  | 
|     curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask))  | 
|     if curValue < finishNeedValue:  | 
|         GameWorld.DebugLog("ͨÌìÈÎÎñ½ø¶ÈδÍê³É£¬ÎÞ·¨Áì½±! ttTaskID=%s,ttTaskType=%s,isDailyTask=%s,curValue=%s < %s"   | 
|                            % (ttTaskID, ttTaskType, isDailyTask, curValue, finishNeedValue), playerID)  | 
|         return  | 
|       | 
|     addTaskPoint = ipyData.GetTaskPoint()  | 
|     dailyTaskPointMax = IpyGameDataPY.GetFuncCfg("TongTianLing", 3)  | 
|     if isDailyTask and dailyTaskPointMax:  | 
|         dailyTaskPointToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_DailyTaskPointToday)  | 
|         if dailyTaskPointToday >= dailyTaskPointMax:  | 
|             GameWorld.DebugLog("ͨÌìÈÎÎñÈÕ³£ÈÎÎñ»ý·Ö½±ÀøÒÑ´ïÉÏÏÞ! ttTaskID=%s,ttTaskType=%s,dailyTaskPointToday=%s >= %s"   | 
|                                % (ttTaskID, ttTaskType, dailyTaskPointToday, dailyTaskPointMax), playerID)  | 
|             return  | 
|         addTaskPoint = min(addTaskPoint, dailyTaskPointMax - dailyTaskPointToday)  | 
|         dailyTaskPointToday += addTaskPoint  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TTL_DailyTaskPointToday, dailyTaskPointToday)  | 
|         GameWorld.DebugLog("¸üÐÂͨÌìÈÎÎñÈÕ³£ÈÎÎñ½ñÈÕÒÑ»ñµÃ»ý·Ö: dailyTaskPointToday=%s" % dailyTaskPointToday, playerID)  | 
|     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_TaskAwardRecord, ttTaskID, 1)  | 
|     AddTongTianPoint(curPlayer, addTaskPoint)  | 
|     SyncTongTianTaskAward(curPlayer)  | 
|     return  | 
|   | 
| #// A5 44 Í¨ÌìÁîÁìÈ¡µÈ¼¶½±Àø #tagCMGetTongTianLVAward  | 
| #  | 
| #struct    tagCMGetTongTianLVAward  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        TTLV;    // ÁìÈ¡¶ÔÓ¦µÈ¼¶½±Àø£¬·¢255Ϊһ¼üÁìÈ¡ËùÓеȼ¶½±Àø£¬°üº¬ÏÉÆ·½±Àø  | 
| #    BYTE        IsXian;    // ÊÇ·ñÁìÈ¡ÏÉÆ·½±Àø£¬½öÖ¸¶¨µÈ¼¶½±ÀøÓÐЧ  | 
| #};  | 
| def OnGetTongTianLVAward(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     getTTLVLV = clientData.TTLV  | 
|     isXian = clientData.IsXian  | 
|       | 
|     ttLV, ttState = GetTongTianLingLVInfo(curPlayer)  | 
|     if getTTLVLV == 255:  | 
|         awardLVList = range(0, ttLV + 1)  | 
|         isXian = 1 # Ò»¼üÁìÈ¡µÄĬÈϰüº¬ÏÉÆ·½±Àø  | 
|     else:  | 
|         awardLVList = [getTTLVLV]  | 
|           | 
|     GameWorld.DebugLog("ÁìȡͨÌìÁî½±Àø: getTTLVLV=%s,isXian=%s,awardLVList=%s" % (getTTLVLV, isXian, awardLVList), playerID)  | 
|       | 
|     notifyItemIDList = []  | 
|     itemList = []  | 
|     for awardTTLV in awardLVList:  | 
|         if awardTTLV > ttLV:  | 
|             GameWorld.DebugLog("    Í¨ÌìµÈ¼¶²»×㣬ÎÞ·¨Áì½±! awardTTLV=%s < %s" % (awardTTLV, ttLV), playerID)  | 
|             break  | 
|         ipyData = IpyGameDataPY.GetIpyGameData("TongTianLV", awardTTLV)  | 
|         if not ipyData:  | 
|             continue  | 
|         commAwardItemList = ipyData.GetCommAwardItemList()  | 
|         xianAwardItemList = ipyData.GetXianAwardItemList()  | 
|         notifyItemIDList.extend(ipyData.GetNotifyItemIDList())  | 
|           | 
|         if commAwardItemList and not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_CommAwardRecord, awardTTLV):  | 
|             GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_CommAwardRecord, awardTTLV, 1)  | 
|             itemList.extend(commAwardItemList)  | 
|             GameWorld.DebugLog("    ³£¹æ½±Àø: awardTTLV=%s,commAwardItemList=%s" % (awardTTLV, commAwardItemList), playerID)  | 
|         #elif commAwardItemList:  | 
|         #    GameWorld.DebugLog("    ÒÑÁìÈ¡¹ý¸Ã½±Àø: awardTTLV=%s" % (awardTTLV), playerID)  | 
|                   | 
|         getXian = (isXian and xianAwardItemList)  | 
|         if getXian and ttState and not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_XianAwardRecord, awardTTLV):  | 
|             GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_TTL_XianAwardRecord, awardTTLV, 1)  | 
|             itemList.extend(xianAwardItemList)  | 
|             GameWorld.DebugLog("    ÏÉÆ·½±Àø: awardTTLV=%s,xianAwardItemList=%s" % (awardTTLV, xianAwardItemList), playerID)  | 
|         #elif getXian:  | 
|         #    GameWorld.DebugLog("    ÏÉÆ·Í¨ÌìÁîδ¼¤»î»òÒÑÁì½±: awardTTLV=%s,ttState=%s" % (awardTTLV, ttState), playerID)  | 
|               | 
|     GameWorld.DebugLog("    ×îÖÕ½±Àø: itemList=%s" % itemList, playerID)  | 
|     if not itemList:  | 
|         return  | 
|       | 
|     giveItemDict = {}  | 
|     for itemID, itemCount, isBind in itemList:  | 
|         key = (itemID, isBind)  | 
|         giveItemDict[key] = giveItemDict.get(key, 0) + itemCount  | 
|           | 
|     awardItemList = []  | 
|     for key, itemCount in giveItemDict.items():  | 
|         itemID, isBind = key  | 
|         awardItemList.append([itemID, itemCount, isBind])  | 
|         if itemID in notifyItemIDList:  | 
|             PlayerControl.NotifyCode(curPlayer, "TongTianLingLVAward", [curPlayer.GetPlayerName(), itemID, itemCount])  | 
|               | 
|     GameWorld.DebugLog("    »ã×ܽ±Àø: awardItemList=%s" % awardItemList, playerID)  | 
|     dataDict = {"awardLVList":awardLVList, "isXian":isXian}  | 
|     ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["TongTianLing", False, dataDict])  | 
|     SyncTongTianLVInfo(curPlayer)  | 
|     return  | 
|   | 
| #// A5 45 ¶Ò»»Í¨ÌìÁîµÈ¼¶¾Ñé»ý·Öµã #tagCMExchangeTongTianLVPoint  | 
| #  | 
| #struct    tagCMExchangeTongTianLVPoint  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD        ExchangePoint;    // ¶Ò»»µãÊý  | 
| #};  | 
| def OnExchangeTongTianLVPoint(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     exchangePoint = clientData.ExchangePoint  | 
|     exchangeCostInfo = IpyGameDataPY.GetFuncEvalCfg("TongTianLing", 1)  | 
|     if len(exchangeCostInfo) != 2:  | 
|         return  | 
|     costMoneyType, costMoneyValue = exchangeCostInfo  | 
|     if not costMoneyType or not costMoneyValue:  | 
|         return  | 
|       | 
|     ttLV = GetTongTianLingLVInfo(curPlayer)[0]  | 
|     ttPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_LVPoint)  | 
|     canBuyPointMax = 0  | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     for index in xrange(ttLV, ipyDataMgr.GetTongTianLVCount()):  | 
|         ipyData = ipyDataMgr.GetTongTianLVByIndex(index)  | 
|         canBuyPointMax += ipyData.GetLVUPPoint()  | 
|     canBuyPointMax -= ttPoint  | 
|       | 
|     exchangePoint = min(exchangePoint, canBuyPointMax)  | 
|     costMoneyTotal = costMoneyValue * exchangePoint  | 
|     GameWorld.DebugLog("¶Ò»»Í¨ÌìÁîµÈ¼¶¾Ñé: ttLV=%s,ttPoint=%s,exchangePoint=%s,canBuyPointMax=%s,costMoneyType=%s,costMoneyTotal=%s"   | 
|                        % (ttLV, ttPoint, exchangePoint, canBuyPointMax, costMoneyType, costMoneyTotal), playerID)  | 
|       | 
|     if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyTotal):  | 
|         return  | 
|           | 
|     updInfo = AddTongTianPoint(curPlayer, exchangePoint)  | 
|     updLV, updPoint = updInfo if updInfo else (ttLV, ttPoint)  | 
|       | 
|     infoDict = {ChConfig.Def_Cost_Reason_SonKey:"ExchangeTongTianLVPoint", "exchangePoint":exchangePoint,   | 
|                 "ttLV":ttLV, "ttPoint":ttPoint, "updLV":updLV, "updPoint":updPoint}  | 
|     PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyTotal, ChConfig.Def_Cost_TongTianLing, infoDict)  | 
|     return  | 
|   | 
| #// A5 46 ¹ºÂòͨÌìÁî #tagCMBuyTongTianLing  | 
| #  | 
| #struct    tagCMBuyTongTianLing  | 
| #{  | 
| #    tagHead        Head;  | 
| #};  | 
| def OnBuyTongTianLing(index, clientData, tick):  | 
|     # ·ÏÆú£¬¸ÄΪ³äÖµ¼¤»î  | 
|     return  | 
|   | 
| def OnActiviteTTTByCTGID(curPlayer, ctgID):  | 
|     ctgIDList = IpyGameDataPY.GetFuncEvalCfg("TongTianLing", 5)  | 
|     if ctgID not in ctgIDList:  | 
|         return  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     ttLV, ttState = GetTongTianLingLVInfo(curPlayer)  | 
|     if ttState:  | 
|         GameWorld.DebugLog("ͨÌìÁîÒѾ¹ºÂò¹ýÁË£¡", playerID)  | 
|         return  | 
|       | 
|     ttState = 1  | 
|     SetTongTianLingLVInfo(curPlayer, ttLV, ttState)  | 
|     GameWorld.DebugLog("¹ºÂò¼¤»îͨÌìÁ", playerID)  | 
|     PlayerControl.NotifyCode(curPlayer, "TongTianLingActive")  | 
|     SyncTongTianLVInfo(curPlayer)  | 
|     return  | 
|   | 
| def SyncTongTianLVInfo(curPlayer):  | 
|     ## µÈ¼¶ÐÅÏ¢  | 
|     ttLV, ttState = GetTongTianLingLVInfo(curPlayer)  | 
|     clientPack = ChPyNetSendPack.tagMCTongTianLingInfo()  | 
|     clientPack.TTLBuyState = ttState  | 
|     clientPack.TTLLV = ttLV  | 
|     clientPack.CurPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_LVPoint)  | 
|     clientPack.CommAwardStateList = []  | 
|     clientPack.XianAwardStateList = []  | 
|     for i in xrange(TTL_LVAwardKeyCount):  | 
|         clientPack.CommAwardStateList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_CommAwardRecord % i))  | 
|         clientPack.XianAwardStateList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_XianAwardRecord % i))  | 
|     clientPack.AwardStateCount = len(clientPack.CommAwardStateList)  | 
|     clientPack.StartTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_StartTime)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def SyncTongTianTaskInfo(curPlayer, syncTaskInfoList=None):  | 
|     ## ÈÎÎñ½ø¶ÈÐÅÏ¢  | 
|     syncAppoint = True  | 
|     if syncTaskInfoList == None:  | 
|         syncAppoint = False  | 
|         syncTaskInfoList = []  | 
|         for ttTaskType in ChConfig.TTLTaskTypeList:  | 
|             syncTaskInfoList.append([ttTaskType, 0])  | 
|             syncTaskInfoList.append([ttTaskType, 1])  | 
|               | 
|     clientPack = ChPyNetSendPack.tagMCTongTianLingTaskValueInfo()  | 
|     clientPack.TaskValueList = []  | 
|     for ttTaskType, isDailyTask in syncTaskInfoList:  | 
|         curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_TaskValue % (ttTaskType, isDailyTask))  | 
|         if not curValue and not syncAppoint:  | 
|             continue  | 
|         task = ChPyNetSendPack.tagMCTongTianLingTaskValue()  | 
|         task.TaskType = ttTaskType  | 
|         task.IsDaily = isDailyTask  | 
|         task.TaskValue = curValue  | 
|         clientPack.TaskValueList.append(task)  | 
|     clientPack.Count = len(clientPack.TaskValueList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def SyncTongTianTaskAward(curPlayer):  | 
|     ## ÈÎÎñ½±ÀøÐÅÏ¢  | 
|     clientPack = ChPyNetSendPack.tagMCTongTianLingTaskAwardInfo()  | 
|     clientPack.TaskAwardStateList = []  | 
|     for i in xrange(TTL_TaskAwardKeyCount):  | 
|         clientPack.TaskAwardStateList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TTL_TaskAwardRecord % i))  | 
|     clientPack.AwardStateCount = len(clientPack.TaskAwardStateList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
|   |