| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerActivity  | 
| #  | 
| # @todo:Íæ¼ÒÿÈÕ»îÔ¾¶È  | 
| # @author xdh  | 
| # @date 2014-07-14  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: Íæ¼ÒÿÈÕ»îÔ¾¶È¡¢Ã¿Èջ  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-02-25 11:30"""  | 
| #---------------------------------------------------------------------  | 
|   | 
| import ChConfig  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import ShareDefine  | 
| import GameWorld  | 
| import ItemCommon  | 
| import IPY_GameWorld  | 
| import PlayerControl  | 
| import ItemControler  | 
| import IpyGameDataPY  | 
| import PyGameData  | 
| import GameFuncComm  | 
| import EventShell  | 
| import PlayerPet  | 
|   | 
| #¹ØÁªÀàÐÍ  | 
| (  | 
| RelatedType_1,  # 1¹ØÁªÈÕ³£»î¶¯±í  | 
| RelatedType_2,  # 2¹ØÁª¸±±¾×Ü±í  | 
| ) = range(1, 3)  | 
|   | 
|   | 
| def OnWeek(curPlayer, onWeekType):  | 
|     actionIDInfo = []  | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     for i in xrange(ipyDataMgr.GetDailyActionCount()):  | 
|         ipyData = ipyDataMgr.GetDailyActionByIndex(i)  | 
|         weekTimesLimit = ipyData.GetWeekTimes()  | 
|         if not weekTimesLimit:  | 
|             continue  | 
|         # ÖØÖÃÀàÐͲ»Í¬µÄ²»´¦Àí  | 
|         if ipyData.GetWeekResetType() != onWeekType:  | 
|             continue  | 
|         key = ChConfig.Def_PDict_DailyActionWeekTimes % ipyData.GetDailyID()  | 
|         __SetPDictValue(curPlayer, key, 0)  | 
|       | 
|         actionIDInfo.append(ipyData.GetDailyID())  | 
|               | 
|     if actionIDInfo:  | 
|         SyncDailyActionInfo(curPlayer, actionIDInfo)  | 
|           | 
|     return  | 
|   | 
|   | 
| ## OnDay  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @return  | 
| def OnDay(curPlayer, onEventType):  | 
|       | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     if onEventType == ShareDefine.Def_OnEventTypeEx:  | 
|         # ÖØÖÃÍê³É´ÎÊý  | 
|         for i in xrange(ipyDataMgr.GetDailyQuestCount()):  | 
|             ipyData = ipyDataMgr.GetDailyQuestByIndex(i)  | 
|               | 
|             key = ChConfig.Def_PDict_Activity_FinishCnt % ipyData.GetID()  | 
|             curPBCnt = __GetPDictValue(curPlayer, key)  #µ¥´Î½ø¶ÈÖµ  | 
|             if curPBCnt:  | 
|                 __SetPDictValue(curPlayer, key, 0)  | 
|         #×Ü»îÔ¾¶ÈÖØÖà  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, 0)  | 
|         # ÖØÖÃÁì½±¼Ç¼  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityAwardRecord, 0)  | 
|         #ÖØÖöîÍâ»ñµÃÐÞÐеãÊý  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint, 0)  | 
|         #ÖØÐ¼ÆËã½±Àø½×¶Î  | 
|         __CalcAwardStage(curPlayer)  | 
|         #ÖØÖÿÉÁìÈ¡ÐÞÐе㣬δÁìÈ¡µÄ·¢Óʼþ  | 
| #        realmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint)  | 
| #        if realmPoint and GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Official):  | 
| #            if GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_DailyQuest):  | 
| #                PlayerControl.SendMailByKey('XXDForgetToPick', [curPlayer.GetID()], [(ChConfig.Def_ItemID_RealmPoint, realmPoint, 1)], [realmPoint])  | 
| #            __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint, 0)  | 
|           | 
|         SyncDailyActivityInfo(curPlayer)  | 
|     else:  | 
|         SendDayActionMail(curPlayer)  | 
|       | 
|     #ÈÕ³£»î¶¯ÖØÖà  | 
|     actionIDInfo = []  | 
|     for i in xrange(ipyDataMgr.GetDailyActionCount()):  | 
|         ipyData = ipyDataMgr.GetDailyActionByIndex(i)  | 
|         dayTimesLimit = GetMaxDayTimes(ipyData)  #ipyData.GetDayTimes()  | 
|         if not dayTimesLimit:  | 
|             continue  | 
|         # ÖØÖÃÀàÐͲ»Í¬µÄ²»´¦Àí  | 
|         if ipyData.GetDayResetType() != onEventType:  | 
|             continue  | 
|         dailyID = ipyData.GetDailyID()  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % dailyID, 0)  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID, 0)  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID, 0)  | 
|           | 
|         actionIDInfo.append(ipyData.GetDailyID())  | 
|     if actionIDInfo:  | 
|         SyncDailyActionInfo(curPlayer, actionIDInfo)  | 
|     return  | 
|   | 
|   | 
| def SendDayActionMail(curPlayer):  | 
|     ##·¢ËÍÿÈջÓʼþ  | 
|     if curPlayer.GetLV() >= IpyGameDataPY.GetFuncCfg('DailyQuestMailLvLimit'):  | 
|         PlayerControl.SendMailByKey('TodayDailyTask', [curPlayer.GetID()], [])  | 
|     return  | 
|   | 
|   | 
| #ÖØÐ¼ÆËã½±Àø½×¶Î  | 
| def __CalcAwardStage(curPlayer):  | 
|     realmLV = curPlayer.GetOfficialRank()  | 
|     ipyData = IpyGameDataPY.IPY_Data().GetDailyLivenessRewardByIndex(0)  | 
|     if not ipyData:  | 
|         return  | 
|     stageLVList = ipyData.GetStageLV()  | 
|     curStage = 0  | 
|     for i, lv in enumerate(stageLVList):  | 
|         if realmLV < lv:  | 
|             break  | 
|         if realmLV >= lv:  | 
|             curStage = i  | 
|     __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AwardStage, curStage)  | 
|     GameWorld.DebugLog('    ÖØÐ¼ÆËã»îÔ¾½±Àø½×¶Î curStage=%s,realmLV=%s' % (curStage, realmLV))  | 
|     return  | 
|   | 
|   | 
| ## OnLogin  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @return  | 
| def OnLogin(curPlayer):  | 
|     # Í¬²½Íê³É¶È¼°Áì½±¼Ç¼  | 
|     SyncDailyActivityInfo(curPlayer)  | 
|     #ͬ²½ÈÕ³£»î¶¯´ÎÊý  | 
|     SyncDailyActionInfo(curPlayer)  | 
|     return  | 
|   | 
|   | 
| ## »ñÈ¡»îÔ¾¶ÈÍæ¼ÒÊý¾Ý¿â×ÖµäÐÅÏ¢Öµ  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param key ×Öµäkey  | 
| #  @param defaultValue Ä¬ÈÏÖµ  | 
| #  @return  | 
| def __GetPDictValue(curPlayer, key, defaultValue=0):  | 
|     return curPlayer.NomalDictGetProperty(key, defaultValue)  | 
|   | 
|   | 
| ## ÉèÖûîÔ¾¶ÈÍæ¼ÒÊý¾Ý¿â×ÖµäÐÅÏ¢Öµ  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param key ×Öµäkey  | 
| #  @param value ÉèÖõÄÖµ  | 
| #  @return  | 
| def __SetPDictValue(curPlayer, key, value):  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, key, value)  | 
|     return  | 
|   | 
|   | 
| ## ¿Û³ý»õ±Ò»ñµÃ»îÔ¾¶È  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param type_Price   | 
| #  @param price   | 
| #  @return  | 
| def OnPayMoneyActivity(curPlayer, type_Price, price):  | 
|     #½ð×ÓÖ§¸¶  | 
| #    if type_Price == IPY_GameWorld.TYPE_Price_Gold_Money:  | 
| #        AddActivityFinishCnt(curPlayer, ShareDefine.ActivityNum_UseGoldCnt)  | 
| #    #½ðƱ֧¸¶  | 
| #    elif type_Price == IPY_GameWorld.TYPE_Price_Gold_Paper:  | 
| #        AddActivityFinishCnt(curPlayer, ShareDefine.ActivityNum_UseGoldPaperCnt)  | 
|           | 
|     return  | 
|   | 
|   | 
| ## ÃþNPC»ñµÃ»îÔ¾¶È  | 
| #  @param atkObj  | 
| #  @param curNPC   | 
| #  @return  | 
| def OnAttackNPCActivity(atkObj, curNPC):  | 
|     atkObjType = atkObj.GetGameObjType()  | 
|       | 
|     # ²»ÊÇÍæ¼ÒÔݲ»´¦Àí  | 
|     if atkObjType != IPY_GameWorld.gotPlayer:  | 
|         return  | 
|                   | 
|     # »÷ɱboss  | 
| #    if curNPC.GetIsBoss():  | 
| #        canAddBossIDList = ReadChConfig.GetEvalChConfig("Activity_BossID")  | 
| #          | 
| #        if curNPC.GetNPCID() in canAddBossIDList:  | 
| #            AddActivityFinishCnt(atkObj, ShareDefine.ActivityNum_KillBoss)  | 
|           | 
|     return  | 
|   | 
|   | 
| ## Ôö¼ÓÍê³É»îÔ¾¶È´ÎÊý  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param activityNum »îÔ¾¶È±àºÅ   | 
| #  @param finishCnt ÒÑÍê³É´ÎÊý  | 
| #  @param addCnt Ôö¼Ó´ÎÊý£¬Ä¬ÈÏ1   | 
| #  @return  | 
| def AddActivityFinishCnt(curPlayer, activityNum, finishCnt, addCnt):  | 
|       | 
|     dailyQuestData = IpyGameDataPY.GetIpyGameDataNotLog('DailyQuest', activityNum)  | 
|     if not dailyQuestData:  | 
|         return  | 
|       | 
|     maxActiveValue = dailyQuestData.GetTotalActiveValue()  | 
|     onceActivity = dailyQuestData.GetOnceActivity()  | 
|     onceActivityTime = dailyQuestData.GetOnceActivityTime()  | 
|     if not onceActivity:  | 
|         return  | 
|     if maxActiveValue and finishCnt > maxActiveValue / onceActivity * onceActivityTime:  | 
|         #GameWorld.DebugLog("»îÔ¾¶È¿ÉÍê³É´ÎÊýÒÑ´ïµ½ÉÏÏÞ,activityNum=%s" % (activityNum))  | 
|         return  | 
|       | 
|     key = ChConfig.Def_PDict_Activity_FinishCnt % activityNum  | 
|     curPBCnt = __GetPDictValue(curPlayer, key)  #µ¥´Î½ø¶ÈÖµ  | 
|       | 
|     addValue = (addCnt + curPBCnt) / onceActivityTime * onceActivity  #Ôö¼ÓµÄ»îÔ¾¶È  | 
|     addPbCnt = (addCnt + curPBCnt) % onceActivityTime  | 
|       | 
|     __SetPDictValue(curPlayer, key, addPbCnt)  | 
|       | 
|     #  | 
|     DoAddActivity(curPlayer, addValue, True)  | 
|     return  | 
|   | 
| def DoAddActivityByLV(curPlayer, befLV, aftLV):  | 
|     ##Éý¼¶Ôö¼Ó»îÔ¾µã  | 
|     perLVAddPoint = IpyGameDataPY.GetFuncCfg('ImmortalDomainActivePoint', 3)  | 
|     skillTypeID, perAddLV, addPoint, maxPoint = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomainActivePoint', 4)  | 
|     learnSkillList, passiveSkillList = PlayerPet.GetPetLearnSkill(curPlayer)  | 
|     addValue = (aftLV-befLV)*perLVAddPoint  | 
|     if skillTypeID in passiveSkillList:  | 
|         for lv in xrange(befLV+1, aftLV+1):  | 
|             addValue += min(((lv-1)/perAddLV+1) * addPoint, maxPoint)  | 
|     DoAddActivity(curPlayer, addValue, False, True)  | 
|     return  | 
|   | 
| def AddActivityByLVOnLearnSkill(curPlayer, skillID):  | 
|     ## »ñµÃ¼¼ÄÜʱ£¬´¦ÀíÔö¼ÓÉý¼¶»ñµÃ»îÔ¾µãЧ¹û  | 
|     skillTypeID, perAddLV, addPoint, maxPoint = IpyGameDataPY.GetFuncEvalCfg('ImmortalDomainActivePoint', 4)  | 
|     if skillID != skillTypeID:  | 
|         return  | 
|     curLV = curPlayer.GetLV()  | 
|     addValue = 0  | 
|     for lv in xrange(2, curLV+1):  | 
|         addValue += min(((lv-1)/perAddLV+1) * addPoint, maxPoint)  | 
|     DoAddActivity(curPlayer, addValue, False, True)  | 
|     return  | 
|   | 
| def DoAddActivity(curPlayer, addValue, isMultiple=False, isLVUp=False):  | 
|     if not addValue:  | 
|         return  | 
|     multiple = 1  | 
|     addExtraPoint = 0  | 
|     if isMultiple:  | 
|         multiple, extraPointLimit = __GetActionAddPer(curPlayer)  | 
|         curExtraPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint)  | 
|         addExtraPoint = max(0, min(addValue * (multiple - 1),  | 
|                                    extraPointLimit - curExtraPoint)) if extraPointLimit else addValue * (multiple - 1)  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint, curExtraPoint + addExtraPoint)  | 
|         addValue = addValue + addExtraPoint  | 
|     curTotalPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint)  | 
|     __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, curTotalPoint + addValue)  | 
|     AddCanCostActivityPoint(curPlayer, addValue, isLVUp)  | 
|     historyPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityHistoryPoint)  | 
|     __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityHistoryPoint,  | 
|                     min(ChConfig.Def_UpperLimit_DWord, historyPoint + addValue))  | 
|   | 
|     SyncDailyActivityInfo(curPlayer)  | 
|     EventShell.EventRespons_AddActivityValue(curPlayer)  | 
|     GameWorld.DebugLog(  | 
|         "Ôö¼Ó»îÔ¾¶È,addValue=%s, multiple=%s, addExtraPoint=%s"  | 
|         % (addValue, multiple, addExtraPoint), curPlayer.GetPlayerID())  | 
|   | 
|     return  | 
|   | 
| def __GetActionAddPer(curPlayer):  | 
|     multiple, extraPointLimit = 1, 0  #±¶Êý¡¢¶îÍâ¿É»ñµÃÐÞÐеãÉÏÏÞ  | 
|     actRealmPointInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_RealmPoint, {})  # ¶à±¶ÐÞÐеã»î¶¯  | 
|     if not actRealmPointInfo:  | 
|         return multiple, extraPointLimit  | 
|     if not actRealmPointInfo.get(ShareDefine.ActKey_State):  | 
|         return multiple, extraPointLimit  | 
|     actRealmPointIpyData = IpyGameDataPY.GetIpyGameData("ActRealmPoint", actRealmPointInfo.get(ShareDefine.ActKey_CfgID, 0))  | 
|     if not actRealmPointIpyData:  | 
|         return multiple, extraPointLimit  | 
|     if curPlayer.GetLV() < actRealmPointIpyData.GetLVLimit():  | 
|         return multiple, extraPointLimit  | 
|     return actRealmPointIpyData.GetMultiple(), actRealmPointIpyData.GetPointLimit()  | 
|   | 
| def AddCanCostActivityPoint(curPlayer, addValue, isLVUp):  | 
|     # Ôö¼Ó¿ÉÏûºÄµÄ»îÔ¾µã  | 
|     curPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint)  | 
|     if isLVUp:  | 
|         updPoint = min(ChConfig.Def_UpperLimit_DWord, curPoint + addValue)  | 
|     else:  | 
|         updPoint = min(IpyGameDataPY.GetFuncCfg('ImmortalDomainActivePoint'), curPoint + addValue)  | 
|     __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint, updPoint)  | 
|     return  | 
|   | 
| def CostActivityPoint(curPlayer, costPoint, isOnlyCheck=False):  | 
|     # ÏûºÄ»îÔ¾µã  | 
|     curPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint)  | 
|     if curPoint < costPoint:  | 
|         return  | 
|     if not isOnlyCheck:  | 
|         __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint,  | 
|                         curPoint - costPoint)  | 
|         SyncDailyActivityInfo(curPlayer)  | 
|     return True  | 
|   | 
| ## Í¬²½»îÔ¾¶ÈÐÅÏ¢  | 
| #  @param curPlayer  | 
| #  @param syncNum Ä¬ÈÏ-1ʱȫ²¿Í¬²½  | 
| #  @return None  | 
| def SyncDailyActivityInfo(curPlayer):  | 
|     sendPack = ChPyNetSendPack.tagMCDailyActivityInfoList()  | 
|     sendPack.Clear()  | 
|     sendPack.CurValue = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint)  | 
|     sendPack.StageIndex = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AwardStage)  | 
|     sendPack.AwardRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityAwardRecord)  | 
|     sendPack.RealmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint)  | 
|     sendPack.ExtraPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_ExtraRealmPoint)  | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|     return  | 
|   | 
|   | 
| ## ÁìÈ¡»îÔ¾¶È½±Àø  | 
| #  @param curPlayer  | 
| #  @param awardIndex  | 
| #  @return None  | 
| def GetActivityAward(curPlayer, awardIndex):  | 
|     rewardCount = IpyGameDataPY.IPY_Data().GetDailyLivenessRewardCount()  | 
|    | 
|     if awardIndex < 0 or awardIndex >= rewardCount:  | 
|         GameWorld.ErrLog("»îÔ¾¶È½±ÀøË÷Òý²»ºÏ·¨,index=%s,Len=%s" % (awardIndex, rewardCount))  | 
|         return  | 
|       | 
|     # ÅжÏÊÇ·ñÒÑÁìÈ¡  | 
|     getAwardRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityAwardRecord)  | 
|     if getAwardRecord & pow(2, awardIndex):  | 
|         GameWorld.Log("ÒѾÁìÈ¡¹ý¸Ã»îÔ¾¶È½±Àø,index=%s" % (awardIndex))  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.IPY_Data().GetDailyLivenessRewardByIndex(awardIndex)  | 
|       | 
|     needActivity = ipyData.GetLiveness()  | 
|     totalActivity = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint)  | 
|       | 
|     # ÅжϻîÔ¾¶È  | 
|     if totalActivity < needActivity:  | 
|         GameWorld.Log("Áì½±»îÔ¾¶È²»×ã,index=%s,needActivity=%s,totalActivity=%s"   | 
|                       % (awardIndex, needActivity, totalActivity))  | 
|         return  | 
|       | 
|     awardStage = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AwardStage)  | 
|      | 
|     itemIDList = ipyData.GetItemID()  | 
|     itemCntList = ipyData.GetItemCount()  | 
|     itemIsBindList = ipyData.GetItemBind()  | 
|     if awardStage >= len(itemIDList) or awardStage >= len(itemCntList) or awardStage >= len(itemIsBindList):  | 
|         return  | 
|   | 
|     itemID = itemIDList[awardStage]  | 
|     itemCnt = itemCntList[awardStage]  | 
|     isBind = itemIsBindList[awardStage]  | 
|     # ¼ì²é±³°ü  | 
|     packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)  | 
|     if 1 > packSpace:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  | 
|         return  | 
|       | 
|     # ¸øÎïÆ·  | 
|     ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])  | 
|   | 
|     # ¸üÐÂÒÑÁìÈ¡³É¹¦±ê¼Ç  | 
|     updAwardRecord = getAwardRecord | (1 << awardIndex)  | 
|     __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityAwardRecord, updAwardRecord)  | 
|     SyncDailyActivityInfo(curPlayer)  | 
|     GameWorld.DebugLog("ÁìÈ¡»îÔ¾¶È½±ÀøOK£¡awardStage=%s, index=%s,needActivity=%s,totalActivity=%s,awardRecord=%s"   | 
|                        % (awardStage, awardIndex, needActivity, totalActivity, updAwardRecord))  | 
|     EventShell.EventRespons_ActivityAward(curPlayer, awardIndex)  | 
|     return  | 
|   | 
|   | 
| def GetRealmPointAward(curPlayer):  | 
|     #ÁìÈ¡»îÔ¾ÐÞÐÐµã  | 
|     realmPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint)  | 
|     if not realmPoint:  | 
|         return  | 
|     PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_RealmPoint, realmPoint)  | 
|     __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_RealmPoint, 0)  | 
|     #totalPoint = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint)  | 
|     #__SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_TotalPoint, totalPoint+realmPoint)  | 
|     SyncDailyActivityInfo(curPlayer)  | 
|     return  | 
|   | 
|   | 
| def GetActivityNum(relatedType, relatedID):  | 
|     ## »ñÈ¡ÈÕ³£ÈÎÎñID£¨»îÔ¾ID£©  | 
|     ipyData = IpyGameDataPY.GetIpyGameDataByCondition('DailyQuest', {"RelatedID":relatedID, "RelatedType":relatedType}, False, False)  | 
|     if not ipyData:  | 
|         return 0  | 
|     return ipyData.GetID()  | 
|   | 
| #########################################ÈÕ³£»î¶¯###########################################  | 
|   | 
|   | 
| def AddDailyActionFinishCnt(curPlayer, dailyID, addCnt=1):  | 
|     ##Ôö¼ÓÈÕ³£»î¶¯Íê³É´ÎÊý  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID)  | 
|     if not ipyData:  | 
|         return  | 
| #    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_DailyQuest):  | 
| #        #GameWorld.DebugLog("ÈÕ³£ÈÎÎñ¹¦ÄÜ먦Æô£¡dailyID=%s" % dailyID)  | 
| #        return  | 
|       | 
|     # ÓÉGameServer¾ö¶¨  | 
|     # Ä¿Ç°¿ç·þPKÔݲ»ÐèÒªÅжϣ¬ÒòΪ¿ç·þPK´ÎÊý½áËãÔÚ±¾·þ£¬Íæ¼Ò¿ÉÄÜÉÏ´Îδ½áËãÀëÏߣ¬µÈ·ÇÆ¥ÅäÆÚ¼äÉÏÏߣ¬Ò²ÐèÒª¼ÓÉÏ£¬ËùÒÔÔݲ»ÅÐ¶Ï  | 
|     if dailyID not in [ShareDefine.DailyActionID_CrossReamPK]:  | 
|         if not GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % dailyID):  | 
|             GameWorld.DebugLog("ÈÕ³£»î¶¯Î´¿ªÆô£¡dailyID=%s" % dailyID)  | 
|             return  | 
|       | 
|     dayTimesLimit = GetMaxDayTimes(ipyData)  #ipyData.GetDayTimes()  | 
|     weekTimesLimit = ipyData.GetWeekTimes()  | 
|     if not dayTimesLimit and not weekTimesLimit:  | 
|         return  | 
|     #¶ÔÓ¦µÄÈÕ³£ÈÎÎñ±íID  | 
|     activityNum = GetActivityNum(RelatedType_1, dailyID)  | 
|     dailyQuestData = IpyGameDataPY.GetIpyGameDataNotLog('DailyQuest', activityNum)  | 
|     unLimitCnt = dailyQuestData and not dailyQuestData.GetTotalActiveValue()  | 
|     funcID = dailyQuestData.GetUnLockFuncID() if dailyQuestData else 0  | 
|     if funcID and not GameFuncComm.GetFuncCanUse(curPlayer, funcID):  | 
|         return  | 
|           | 
|     updDayTimes = 0  | 
|     if dayTimesLimit:  | 
|         key = ChConfig.Def_PDict_DailyActionDayTimes % dailyID  | 
|         curDayTimes = curPlayer.NomalDictGetProperty(key)  | 
|         curDayBuyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID)  | 
|         curDayItemTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID)  | 
|         if not unLimitCnt and curDayTimes >= dayTimesLimit + curDayBuyTimes + curDayItemTimes:  | 
|             return  | 
|         updDayTimes = curDayTimes + addCnt if unLimitCnt else min(dayTimesLimit + curDayBuyTimes + curDayItemTimes, curDayTimes + addCnt)  | 
|         addCnt = updDayTimes - curDayTimes  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, key, updDayTimes)  | 
|         GameWorld.DebugLog('Ôö¼ÓÈÕ³£»î¶¯Íê³É´ÎÊý dailyID=%s, curDayTimes=%s, updDayTimes=%s' % (dailyID, curDayTimes, updDayTimes))  | 
|     updWeekTimes = 0  | 
|     if weekTimesLimit:  | 
|         key = ChConfig.Def_PDict_DailyActionWeekTimes % dailyID  | 
|         curWeekTimes = curPlayer.NomalDictGetProperty(key)  | 
|         if not unLimitCnt and curWeekTimes >= weekTimesLimit:  | 
|             return  | 
|         updWeekTimes = curWeekTimes + addCnt if unLimitCnt else min(weekTimesLimit, curWeekTimes + addCnt)  | 
|         addCnt = updWeekTimes - curWeekTimes  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, key, updWeekTimes)  | 
|         GameWorld.DebugLog('Ôö¼ÓÈÕ³£»î¶¯Íê³É´ÎÊý dailyID=%s, curWeekTimes=%s, updWeekTimes=%s' % (dailyID, curWeekTimes, updWeekTimes))  | 
|   | 
|     SyncDailyActionInfo(curPlayer, [dailyID])  | 
|       | 
|     #¶ÔÓ¦µÄÈÕ³£ÈÎÎñ±íID  | 
|     updTimes = updDayTimes or updWeekTimes  | 
|     if addCnt and updTimes and dailyQuestData:  | 
|         AddActivityFinishCnt(curPlayer, activityNum, updTimes, addCnt)  | 
|     return True  | 
|   | 
|   | 
| def GetDailyActionFinishCnt(curPlayer, dailyID):  | 
|     key = ChConfig.Def_PDict_DailyActionDayTimes % dailyID  | 
|     curDayTimes = __GetPDictValue(curPlayer, key)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID)  | 
|     if not ipyData:  | 
|         return 0, 0  | 
|     dayTimesLimit = GetMaxDayTimes(ipyData)  #ipyData.GetDayTimes()  | 
|     return curDayTimes, dayTimesLimit  | 
|   | 
| def GetDailyActionrRemainCnt(curPlayer, dailyID):  | 
|     ##»ñÈ¡»î¶¯Ê£Óà´ÎÊý  | 
|     curDayTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % dailyID)  | 
|     curDayBuyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID)  | 
|     curDayItemTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID)  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID)  | 
|     dayTimesLimit = GetMaxDayTimes(ipyData)  | 
|     return max(0, dayTimesLimit+curDayBuyTimes+curDayItemTimes-curDayTimes)  | 
|   | 
| def GetMaxDayTimes(ipyData):  | 
|     dayTimesLimit = ipyData.GetDayTimes()  | 
|     if ipyData.GetDailyID() == ShareDefine.DailyActionID_TowerSD:  | 
|         dayTimesLimit += IpyGameDataPY.GetFuncCfg('RuneTowerSweepBuy')  | 
|     return dayTimesLimit  | 
|   | 
|   | 
| #// A5 25 ¹ºÂòÈÕ³£»î¶¯´ÎÊý #tagCMBuyDailyActionCnt  | 
| #  | 
| #struct    tagCMBuyDailyActionCnt  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD    ActionID;    // ID  | 
| #    BYTE    AddType;    // 0-»¨ÏÉÓñ 1-ÓÃÎïÆ·  | 
| #};  | 
| def OnDailyActionBuyCnt(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     dailyID = clientData.ActionID  | 
|     addType = clientData.AddType  #0»¨ÏÉÓñ 1ʹÓÃÎïÆ·  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID)  | 
|     if not ipyData:  | 
|         return  | 
|     curDayTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % dailyID)  | 
|     curDayBuyTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID)  | 
|     curDayItemTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID)  | 
|     if curDayBuyTimes + curDayItemTimes - curDayTimes >= 0:  | 
|         GameWorld.DebugLog('Ê£Óà´ÎÊýÒÑ´ïÉÏÏÞ£¬²»¿ÉÔö¼Ó£¡')  | 
|         return  | 
|       | 
|     if addType == 0:  | 
|         dayBuyTimesLimit = ipyData.GetDayBuyTimes()  | 
|         buyNeedMoney = ipyData.GetBuyNeedMoney()  | 
|         if not dayBuyTimesLimit or not buyNeedMoney:  | 
|             return  | 
|         if curDayBuyTimes >= dayBuyTimesLimit:  | 
|             GameWorld.DebugLog('½ñÈÕ¹ºÂò´ÎÊýÒÑ´ïÉÏÏÞ£¬²»¿ÉÔö¼Ó£¡')  | 
|             return  | 
|         if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, buyNeedMoney, ChConfig.Def_Cost_BuyDailyActionCnt, {'dailyID':dailyID, 'curDayBuyTimes':curDayBuyTimes}):  | 
|             return  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyActionDayBuyTimes % dailyID, curDayBuyTimes + 1)  | 
|           | 
|     elif addType == 1:  | 
|         dayItemAddTimesLimit = ipyData.GetDayItemAddTimes()  | 
|         dayItemID = ipyData.GetDayItemID()  | 
|         if not dayItemAddTimesLimit or not dayItemID:  | 
|             return  | 
|         if curDayItemTimes >= dayItemAddTimesLimit:  | 
|             GameWorld.DebugLog('½ñÈÕʹÓÃÎïÆ·Ôö¼Ó´ÎÊýÒÑ´ïÉÏÏÞ£¬²»¿ÉÔö¼Ó£¡')  | 
|             return  | 
|         itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|         enough, indexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(dayItemID, itemPack, 1)  | 
|         if not enough:  | 
|             return  | 
|         ItemCommon.ReduceItem(curPlayer, itemPack, indexList, 1, False, "DailyActionCnt")  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DailyActionDayItemTimes % dailyID, curDayItemTimes + 1)  | 
|   | 
|     else:  | 
|         return  | 
|     SyncDailyActionInfo(curPlayer, [dailyID])  | 
|     return  | 
|   | 
|   | 
| ## Í¬²½»îÔ¾¶ÈÐÅÏ¢  | 
| #  @param curPlayer  | 
| #  @param syncNum Ä¬ÈÏ-1ʱȫ²¿Í¬²½  | 
| #  @return None  | 
| def SyncDailyActionInfo(curPlayer, syncNumList=[]):  | 
|     sendPack = ChPyNetSendPack.tagMCDailyActionCnt()  | 
|     sendPack.Clear()  | 
|     sendPack.ActionInfo = []  | 
|     syncNumList = syncNumList if syncNumList else ShareDefine.DailyActionIDList  | 
|   | 
|     for activityNum in syncNumList:  | 
|         activityInfo = ChPyNetSendPack.tagMCDailyActionInfo()  | 
|         activityInfo.Clear()  | 
|         activityInfo.ActionID = activityNum  | 
|         activityInfo.DayFinishCnt = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayTimes % activityNum)  | 
|         activityInfo.DayBuyTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayBuyTimes % activityNum)  | 
|         activityInfo.DayItemTimes = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionDayItemTimes % activityNum)  | 
|         activityInfo.WeekFinishCnt = __GetPDictValue(curPlayer, ChConfig.Def_PDict_DailyActionWeekTimes % activityNum)  | 
|         sendPack.ActionInfo.append(activityInfo)  | 
|       | 
|     sendPack.Count = len(sendPack.ActionInfo)  | 
|     NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|     return  | 
|   | 
|   | 
| ##################################¸±±¾ÀàÔö¼Ó»îÔ¾##########################################  | 
| ## ²Î¼Ó¸±±¾»ñµÃ»îÔ¾¶È  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param tick   | 
| #  @return  | 
| def OnEnterFBActivity(curPlayer, mapID, curDayTimes, addCount):  | 
|     activityNum = GetActivityNum(RelatedType_2, mapID)  | 
|     if activityNum:   | 
|         AddActivityFinishCnt(curPlayer, activityNum, curDayTimes, addCount)  | 
|     return  |