#!/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 PlayerTJG  
 | 
import PlayerPet  
 | 
import PlayerVip  
 | 
import datetime  
 | 
import time  
 | 
import FormulaControl  
 | 
import PlayerBossReborn  
 | 
import PlayerActGarbageSorting  
 | 
import PlayerTongTianLing  
 | 
import PlayerSuccess  
 | 
import PlayerGubao  
 | 
  
 | 
#¹ØÁªÀàÐÍ  
 | 
(  
 | 
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)  
 | 
            key = ChConfig.Def_PDict_Activity_AddTotal % ipyData.GetID()  
 | 
            if __GetPDictValue(curPlayer, key):  
 | 
                __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)  
 | 
          
 | 
        SyncDailyActivityInfo(curPlayer)  
 | 
          
 | 
        # ¼Ç¼×òÈÕ»îÔ¾ÎüÄɾÑé  
 | 
        todayExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceTodayExp)  
 | 
        todayExpPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceTodayExpPoint)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceTodayExp, 0)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceTodayExpPoint, 0)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceYestorDayExp, todayExp)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceYestorDayExpPoint, todayExpPoint)  
 | 
        #»îÔ¾·ÅÖà  
 | 
        Sync_ActivityPlaceInfo(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)  
 | 
    #»îÔ¾·ÅÖà  
 | 
    Sync_ActivityPlaceInfo(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  
 | 
    curAddTotal = None  
 | 
    if maxActiveValue:  
 | 
        if dailyQuestData.GetRelatedType() == RelatedType_1 and dailyQuestData.GetRelatedID() in [ShareDefine.DailyActionID_CrossBattlefield]:  
 | 
            curAddTotal = __GetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AddTotal % activityNum)  #µ¥´Î½ø¶ÈÖµ  
 | 
            if curAddTotal >= maxActiveValue:  
 | 
                GameWorld.DebugLog("»îÔ¾¶È¿ÉÍê³É´ÎÊýÒÑ´ïµ½ÉÏÏÞ,activityNum=%s,curAddTotal=%s >= %s" % (activityNum, curAddTotal, maxActiveValue))  
 | 
                return  
 | 
        else:  
 | 
            if 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)  
 | 
      
 | 
    if curAddTotal != None:  
 | 
        curAddTotal += addValue  
 | 
        __SetPDictValue(curPlayer, ChConfig.Def_PDict_Activity_AddTotal % activityNum, curAddTotal)  
 | 
          
 | 
    #  
 | 
    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)  
 | 
    PlayerActGarbageSorting.AddActGarbageTaskProgress(curPlayer, ChConfig.Def_GarbageTask_Activity, addValue)  
 | 
    PlayerTongTianLing.AddTongTianTaskValue(curPlayer, ChConfig.TTLTaskType_Activity, addValue)  
 | 
    PlayerControl.NotifyCode(curPlayer, "GetActivity", [addValue])  
 | 
    SyncDailyActivityInfo(curPlayer)  
 | 
    EventShell.EventRespons_AddActivityValue(curPlayer)  
 | 
    GameWorld.DebugLog("Ôö¼Ó»îÔ¾¶È,addValue=%s,multiple=%s,addExtraPoint=%s,isLVUp=%s"   
 | 
                       % (addValue, multiple, addExtraPoint, isLVUp), 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:  
 | 
        maxPoint = IpyGameDataPY.GetFuncCfg('ActivityPlace', 1)  
 | 
        if maxPoint and curPoint >= maxPoint:  
 | 
            GameWorld.DebugLog("¿ÉÏûºÄµÄ»îÔ¾µã³¬³öÉÏÏÞ£¬²»Ôö¼Ó! curPoint=%s,maxPoint=%s" % (curPoint, maxPoint))  
 | 
            return  
 | 
        updPoint = curPoint + addValue  
 | 
    __SetPDictValue(curPlayer, ChConfig.Def_PDict_ActivityCanCostTotalPoint, updPoint)  
 | 
      
 | 
    costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # µ¥´Î·ÅÖÃÏûºÄµÄ»îÔ¾µãÊý  
 | 
    if updPoint >= costPoint:  
 | 
        EventShell.EventRespons_ActivityPlace(curPlayer, "canstart", True)  
 | 
    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 GetActivityNum(relatedType, relatedID):  
 | 
    ## »ñÈ¡ÈÕ³£ÈÎÎñID£¨»îÔ¾ID£©  
 | 
    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('DailyQuest', {"RelatedID":relatedID, "RelatedType":relatedType}, False, False)  
 | 
    if not ipyData:  
 | 
        return 0  
 | 
    return ipyData.GetID()  
 | 
  
 | 
#########################################ÈÕ³£»î¶¯###########################################  
 | 
  
 | 
def GetDailyActionOpenEndTime(dailyID):  
 | 
    ## »ñÈ¡ÈÕ³£»î¶¯¿ªÆô½áÊøÊ±¼äµã  
 | 
    ipyData = IpyGameDataPY.GetIpyGameData('DailyAction', dailyID)  
 | 
    if not ipyData:  
 | 
        return  
 | 
    openTimeDict = ipyData.GetOpenTimeDict()  
 | 
    duration = ipyData.GetDuration()  
 | 
    if not openTimeDict or not duration:  
 | 
        return  
 | 
    allOpenTimeList = openTimeDict.values()  
 | 
    if not allOpenTimeList:  
 | 
        return  
 | 
    openTimeList = allOpenTimeList[0] # Õâ±ßĬÈÏΪÿÈյĿªÆôʱ¼ä¶ÎÒ»Ñù£¬Ö±½ÓÈ¡µÚÒ»ÈÕ  
 | 
    if len(openTimeList) == 1:  
 | 
        openHour, openMinute = openTimeList[0]  
 | 
    else:  
 | 
        #openHour, openMinute =   
 | 
        # Ã¿Ìì¶à¸öʱ¼ä¶ÎµÄÔÙ˵£¬ÔÝʱûÓõ½  
 | 
        return  
 | 
      
 | 
    curDateTime = GameWorld.GetCurrentTime()  
 | 
    openTimeStr = "%d-%d-%d %02d:%02d:00" % (curDateTime.year, curDateTime.month, curDateTime.day, openHour, openMinute)  
 | 
    openDateTime = datetime.datetime.strptime(openTimeStr, ChConfig.TYPE_Time_Format)  
 | 
    endDateTime = openDateTime + datetime.timedelta(minutes=duration)  
 | 
    return openDateTime, endDateTime  
 | 
  
 | 
def GetDailyActionRemainSeconds(dailyID):  
 | 
    ## »ñÈ¡ÈÕ³£»î¶¯µ±Ç°Ê£ÓàÃëÊý  
 | 
    openEndTimeInfo = GetDailyActionOpenEndTime(dailyID)  
 | 
    if not openEndTimeInfo:  
 | 
        return 0  
 | 
    openDateTime, endDateTime = openEndTimeInfo  
 | 
    curDateTime = GameWorld.GetCurrentTime()  
 | 
    if curDateTime < openDateTime or curDateTime >= endDateTime:  
 | 
        return 0  
 | 
    remainDateTime = endDateTime - curDateTime  
 | 
    return remainDateTime.seconds  
 | 
  
 | 
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, ShareDefine.DailyActionID_CrossBattlefield]:  
 | 
        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 dailyID != ShareDefine.DailyActionID_SealDemon 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()  
 | 
        buyTimesPrivilegeID = ipyData.GetBuyTimesPrivilegeID()  
 | 
        vipBuyCountEx = PlayerVip.GetPrivilegeValue(curPlayer, buyTimesPrivilegeID)  
 | 
        dayBuyTimesLimit += vipBuyCountEx  
 | 
        moneyType = ipyData.GetMoneyType()  
 | 
        buyNeedMoneyList = ipyData.GetBuyNeedMoney()  
 | 
        if not dayBuyTimesLimit or not buyNeedMoneyList:  
 | 
            GameWorld.DebugLog("ÎÞ·¨¹ºÂò! dayBuyTimesLimit=%s,buyNeedMoneyList=%s" % (dayBuyTimesLimit, buyNeedMoneyList))  
 | 
            return  
 | 
        if curDayBuyTimes >= dayBuyTimesLimit:  
 | 
            GameWorld.DebugLog('½ñÈÕ¹ºÂò´ÎÊýÒÑ´ïÉÏÏÞ£¬²»¿ÉÔö¼Ó£¡')  
 | 
            return  
 | 
        buyNeedMoney = buyNeedMoneyList[curDayBuyTimes] if len(buyNeedMoneyList) > curDayBuyTimes else buyNeedMoneyList[-1]  
 | 
        if not PlayerControl.PayMoney(curPlayer, moneyType, 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  
 | 
  
 | 
  
 | 
################################## »îÔ¾·ÅÖà##############################################  
 | 
  
 | 
#// B0 29 »îÔ¾·ÅÖÃÃ÷ϸ²éѯ #tagCMActivityPlaceQuery  
 | 
#  
 | 
#struct    tagCMActivityPlaceQuery  
 | 
#{  
 | 
#    tagHead        Head;  
 | 
#};  
 | 
def OnActivityPlaceQuery(index, clientData, tick):  
 | 
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  
 | 
    Sync_ActivityPlaceInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
#// B0 27 »îÔ¾·ÅÖÃÆô¶¯ #tagCMActivityPlaceStart  
 | 
#  
 | 
#struct    tagCMActivityPlaceStart  
 | 
#{  
 | 
#    tagHead        Head;  
 | 
#};  
 | 
def OnActivityPlaceStart(index, clientData, tick):  
 | 
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  
 | 
      
 | 
    maxRewardCount = IpyGameDataPY.GetFuncCfg("ActivityPlace", 4) # ×î´óÀۼƷÅÖý±Àø´ÎÊý          
 | 
    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)  
 | 
    rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)  
 | 
      
 | 
    maxCanStartCount = maxRewardCount - remainCount - rewardCount  
 | 
    if maxCanStartCount <= 0:  
 | 
        GameWorld.DebugLog("»îÔ¾·ÅÖý±ÀøÀۼƴÎÊýÒÑ´ïÉÏÏÞ£¬ÎÞ·¨Æô¶¯!remainCount=%s + rewardCount=%s >= maxRewardCount=%s"   
 | 
                           % (remainCount, rewardCount, maxRewardCount))  
 | 
        return  
 | 
              
 | 
    costPoint = IpyGameDataPY.GetFuncCfg("ActivityPlace", 2) # µ¥´Î·ÅÖÃÏûºÄµÄ»îÔ¾µãÊý  
 | 
    canUseActivityPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityCanCostTotalPoint)  
 | 
    pointCanUseCount = canUseActivityPoint / costPoint  
 | 
    startCount = min(maxCanStartCount, pointCanUseCount)  
 | 
    if startCount <= 0:  
 | 
        GameWorld.DebugLog("¿ÉÓûîÔ¾²»×㣬ÎÞ·¨Ìí¼Ó´ÎÊýÆô¶¯!canUseActivityPoint=%s,costPoint=%s" % (canUseActivityPoint, costPoint))  
 | 
        return  
 | 
      
 | 
    updRemainCount = remainCount + startCount  
 | 
    GameWorld.DebugLog("Ìí¼Ó»îÔ¾·ÅÖôÎÊý: startCount=%s,rewardCount=%s,remainCount=%s,updRemainCount=%s"   
 | 
                       % (startCount, rewardCount, remainCount, updRemainCount))  
 | 
      
 | 
    costPointTotal = costPoint * startCount  
 | 
    CostActivityPoint(curPlayer, costPointTotal)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, updRemainCount)  
 | 
      
 | 
    if not remainCount:  
 | 
        curTime = int(time.time())  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, curTime)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceExpCount, 0)  
 | 
        GameWorld.DebugLog("    Ã»ÓÐÊ£Óà´ÎÊý£¬¸üÐÂÆô¶¯Ê±¼ä: %s" % curTime)  
 | 
          
 | 
    EventShell.EventRespons_ActivityPlace(curPlayer, "start")  
 | 
      
 | 
    Sync_ActivityPlaceInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
#// B0 28 »îÔ¾·ÅÖÿìËÙÍê³É #tagCMActivityPlaceQuickFinish  
 | 
#  
 | 
#struct    tagCMActivityPlaceQuickFinish  
 | 
#{  
 | 
#    tagHead        Head;  
 | 
#    BYTE        FinishCount;    //Íê³É´ÎÊý  
 | 
#};  
 | 
def OnActivityPlaceQuickFinish(index, clientData, tick):  
 | 
    ## ¾Ñé¸ÄΪʵʱ»ñÈ¡£¬ÔÝÆÁ±Î¿ìËÙÍê³É  
 | 
    return  
 | 
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  
 | 
    finishCount = clientData.FinishCount  
 | 
    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)  
 | 
    if not remainCount:  
 | 
        GameWorld.DebugLog("ûÓÐÊ£Óà»îÔ¾·ÅÖôÎÊý£¬ÎÞ·¨¿ìËÙÍê³É!")  
 | 
        return  
 | 
    finishCount = min(finishCount, remainCount)  
 | 
    if not finishCount:  
 | 
        return  
 | 
      
 | 
    costItemID, costGoldParper = IpyGameDataPY.GetFuncEvalCfg("ActivityPlace", 5)  
 | 
    costItemCount = finishCount # Ã¿´Î¿ÛÒ»¸ö  
 | 
      
 | 
    costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)  
 | 
    lackCnt = costItemCount - bindCnt - unBindCnt  
 | 
    delItemCount = costItemCount  
 | 
    if lackCnt > 0:  
 | 
        costGoldParperTotal = costGoldParper * lackCnt  
 | 
        if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, costGoldParperTotal, ChConfig.Def_Cost_ActivityPlace):  
 | 
            return  
 | 
        delItemCount -= lackCnt  
 | 
          
 | 
    if delItemCount > 0:  
 | 
        ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delItemCount, ChConfig.ItemDel_ActivityPlace)  
 | 
          
 | 
    __DoActivityPlaceRewardEnd(curPlayer, finishCount, isQuick=True)  
 | 
    return  
 | 
  
 | 
def ProcessActivityPlace(curPlayer):  
 | 
    ## »îÔ¾·ÅÖö¨Ê±´¦Àí  
 | 
      
 | 
    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)  
 | 
    if remainCount <= 0:  
 | 
        #GameWorld.DebugLog("ûÓÐÊ£Óà·ÅÖôÎÊý²»´¦Àí!")  
 | 
        return  
 | 
      
 | 
    curTime = int(time.time())  
 | 
    startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime)  
 | 
    if not startTime:  
 | 
        startTime = curTime  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, curTime)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceExpCount, 0)  
 | 
          
 | 
    needSeconds = IpyGameDataPY.GetFuncCfg("ActivityPlace", 3) # µ¥´Î·ÅÖý±Àø³ÖÐøÊ±¼ä£¬Ãë  
 | 
    expSeconds = IpyGameDataPY.GetFuncCfg("ActivityPlaceExp", 1) # »îÔ¾·ÅÖûñµÃ¾Ñé¶àÉÙÃëÒ»´Î  
 | 
    passTime = curTime - startTime  
 | 
      
 | 
    endCount = passTime / needSeconds  
 | 
    endCount = min(endCount, remainCount)  
 | 
      
 | 
    expCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceExpCount)  
 | 
    maxExpCount = needSeconds / expSeconds # µ¥´Î·ÅÖÃ×î¶à¿É»ñµÃ¾Ñé´ÎÊý  
 | 
    # ÓÉÓÚ½áËãÊ±ÖØÖÃÁË¿ªÆôÏ´εÄʱ¼ä¼°¾Ñé´ÎÊý£¬ËùÒÔÈç¹ûÓÐÐèÒª½áË㣬ÔòÒç³öʱ¼ä²»¼Æ£¬·ÅÖöàËã¾Ñé´ÎÊý  
 | 
    if endCount >= 1:  
 | 
        maxExpCount *= endCount  
 | 
    canGetExpCount = min(maxExpCount, passTime / expSeconds)  
 | 
    addExpCount = canGetExpCount - expCount  
 | 
    if addExpCount > 0:  
 | 
        #GameWorld.DebugLog("»îÔ¾·ÅÖö¨Ê±´¦Àí : curTime=%s,startTime=%s,passTime=%s,endCount=%s,expCount=%s,canGetExpCount=%s,maxExpCount=%s,addExpCount=%s"   
 | 
        #                   % (curTime, startTime, passTime, endCount, expCount, canGetExpCount, maxExpCount, addExpCount))  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceExpCount, expCount + addExpCount)  
 | 
        lv = curPlayer.GetLV()  
 | 
        reExp = PlayerControl.GetPlayerReExp(curPlayer)  
 | 
        expLV, expFormat = 0, ""  
 | 
        lvFormatList = IpyGameDataPY.GetFuncEvalCfg("ActivityPlaceExp", 2) # [[СÓÚµÈÓڵȼ¶, "¹«Ê½"],...]  
 | 
        for eLV, eFormat in lvFormatList:  
 | 
            if lv <= eLV:  
 | 
                expLV, expFormat = eLV, eFormat  
 | 
                break  
 | 
        if not expLV:  
 | 
            expLV, expFormat = lvFormatList[-1]  
 | 
        addExp = eval(FormulaControl.GetCompileFormula("ActivityPlaceExp_%s" % expLV, expFormat)) * expSeconds * addExpCount  
 | 
        playerControl = PlayerControl.PlayerControl(curPlayer)  
 | 
        addExp = playerControl.AddExp(addExp, ShareDefine.Def_ViewExpType_Activity)  
 | 
          
 | 
        todayExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceTodayExp)  
 | 
        todayExpPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceTodayExpPoint)  
 | 
        todayTotalExp = todayExpPoint * ChConfig.Def_PerPointValue + todayExp + addExp  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceTodayExp, todayTotalExp % ChConfig.Def_PerPointValue)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceTodayExpPoint, todayTotalExp / ChConfig.Def_PerPointValue)  
 | 
          
 | 
        #GameWorld.DebugLog("passTime=%s,canGetExpCount=%s,expCount=%s,addExpCount=%s,addExp=%s,todayTotalExp=%s"   
 | 
        #                   % (passTime, canGetExpCount, expCount, addExpCount, addExp, todayTotalExp))  
 | 
          
 | 
    if endCount > 0:  
 | 
        __DoActivityPlaceRewardEnd(curPlayer, endCount)  
 | 
    return  
 | 
  
 | 
def __DoActivityPlaceRewardEnd(curPlayer, endCount, isQuick=False):  
 | 
    ## ·ÅÖûîÔ¾½±Àø½áËã  
 | 
      
 | 
    remainCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)  
 | 
    endCount = min(endCount, remainCount)  
 | 
    if endCount <= 0:  
 | 
        return  
 | 
      
 | 
    countDataDict = {}  
 | 
    lvDataDict = {}  
 | 
    ipyDataMgr = IpyGameDataPY.IPY_Data()  
 | 
    for index in xrange(ipyDataMgr.GetActivityPlaceRewardCount()):  
 | 
        ipyData = ipyDataMgr.GetActivityPlaceRewardByIndex(index)  
 | 
        placeCount = ipyData.GetPlaceCount()  
 | 
        placeMaxLV = ipyData.GetPlaceMaxLV()  
 | 
        if placeCount:  
 | 
            countDataDict[placeCount] = ipyData  
 | 
        else:  
 | 
            lvDataDict[placeMaxLV] = ipyData  
 | 
              
 | 
    lvRewardIpyData = None  
 | 
    playerLV = curPlayer.GetLV()  
 | 
    lvList = sorted(lvDataDict.keys())  
 | 
    for lv in lvList:  
 | 
        if playerLV <= lv:  
 | 
            lvRewardIpyData = lvDataDict[lv]  
 | 
            break  
 | 
    if not lvRewardIpyData:  
 | 
        lvRewardIpyData = lvDataDict[lvList[-1]]  
 | 
          
 | 
    maxAppointCount = max(countDataDict) # ×î´ó¶¨Öƽ±Àø´ÎÊý  
 | 
    rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)  
 | 
    rewardTotalCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardTotalCount)  
 | 
      
 | 
    rewardItemDict = {}  
 | 
    GameWorld.DebugLog("½áËã·ÅÖûîÔ¾½±Àø: remainCount=%s,rewardCount=%s,endCount=%s,maxAppointCount=%s" % (remainCount, rewardCount, endCount, maxAppointCount))  
 | 
    for _ in xrange(endCount):  
 | 
          
 | 
        rewardIpyData = None  
 | 
          
 | 
        # ¼Ó½±Àø´ÎÊý  
 | 
        remainCount -= 1  
 | 
        rewardCount += 1  
 | 
        if rewardTotalCount < maxAppointCount:  
 | 
            rewardTotalCount += 1  
 | 
            if rewardTotalCount in countDataDict:  
 | 
                rewardIpyData = countDataDict[rewardTotalCount]  
 | 
                #GameWorld.DebugLog("    È¡¶¨ÖÆ´ÎÊý½±Àø: rewardTotalCount=%s" % rewardTotalCount)  
 | 
                  
 | 
        if not rewardIpyData:  
 | 
            rewardIpyData = lvRewardIpyData  
 | 
            #GameWorld.DebugLog("    È¡µÈ¼¶½±Àø: maxLV=%s" % rewardIpyData.GetPlaceMaxLV())  
 | 
              
 | 
        # ¹Ì¶¨½±Àø  
 | 
        for itemID, itemCount in rewardIpyData.GetFixedItemRewardList():  
 | 
            rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + itemCount  
 | 
        # ±ýͼ¿âA  
 | 
        for _ in xrange(rewardIpyData.GetRandItemCountA()):  
 | 
            itemID = GameWorld.GetResultByRandomList(rewardIpyData.GetRandItemRewardListA())  
 | 
            if itemID:  
 | 
                rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + 1  
 | 
        # ±ýͼ¿âB  
 | 
        for _ in xrange(rewardIpyData.GetRandItemCountB()):  
 | 
            itemID = GameWorld.GetResultByRandomList(rewardIpyData.GetRandItemRewardListB())  
 | 
            if itemID:  
 | 
                rewardItemDict[itemID] = rewardItemDict.get(itemID, 0) + 1  
 | 
                  
 | 
        GameWorld.DebugLog("    remainCount=%s,rewardCount=%s,rewardTotalCount=%s, %s" % (remainCount, rewardCount, rewardTotalCount, rewardItemDict))  
 | 
          
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRemainCount, remainCount)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, rewardCount)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardTotalCount, rewardTotalCount)  
 | 
      
 | 
    if remainCount > 0:  
 | 
        nextStartTime = int(time.time())  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceStartTime, nextStartTime)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceExpCount, 0)  
 | 
        GameWorld.DebugLog("    »¹ÓÐÊ£Óà´ÎÊý£¬¸üÐÂÆô¶¯Ê±¼ä: %s" % (nextStartTime))  
 | 
          
 | 
    # ´æ´¢½±Àø  
 | 
    rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)  
 | 
    for i in xrange(rewardItemCount):  
 | 
        itemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemID % i)  
 | 
        if itemID not in rewardItemDict:  
 | 
            continue  
 | 
        addCount = rewardItemDict.pop(itemID)  
 | 
        itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i)  
 | 
        updCount = itemCount + addCount  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i, updCount)  
 | 
        #GameWorld.DebugLog("    ¸üÐÂ̽Ë÷½±Àø: itemID=%s,itemCount=%s,addCount=%s,updCount=%s" % (itemID, itemCount, addCount, updCount))  
 | 
          
 | 
    for itemID, itemCount in rewardItemDict.items():  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemID % rewardItemCount, itemID)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % rewardItemCount, itemCount)  
 | 
        rewardItemCount += 1  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItem, rewardItemCount)  
 | 
        #GameWorld.DebugLog("    ÐÂÔö̽Ë÷½±Àø: itemID=%s,itemCount=%s,rewardItemCount=%s" % (itemID, itemCount, rewardItemCount))  
 | 
          
 | 
    if isQuick:  
 | 
        PlayerControl.NotifyCode(curPlayer, "ActivityPlaceQuickFinishOK")  
 | 
          
 | 
    EventShell.EventRespons_ActivityPlace(curPlayer, "cangetreward")  
 | 
      
 | 
    Sync_ActivityPlaceInfo(curPlayer)  
 | 
      
 | 
    PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_ActivityPlace, endCount)  
 | 
    return  
 | 
  
 | 
def GetActivityPlaceReward(curPlayer):  
 | 
    ## ÁìÈ¡»îÔ¾·ÅÖý±Àø  
 | 
      
 | 
    rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)  
 | 
    if not rewardItemCount:  
 | 
        GameWorld.DebugLog("ûÓлîÔ¾·ÅÖý±Àø£¬ÎÞ·¨ÁìÈ¡!")  
 | 
        return  
 | 
      
 | 
    rewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)  
 | 
    isAppointItem = 0  
 | 
    rewardItemList = []  
 | 
    for i in xrange(rewardItemCount):  
 | 
        itemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemID % i)  
 | 
        itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i)  
 | 
        if not itemID or not itemCount:  
 | 
            break  
 | 
        rewardItemList.append([itemID, itemCount, isAppointItem])  
 | 
          
 | 
        # ÁìÈ¡ºóÐèÒªÖØÖÃΪ0  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemID % i, 0)  
 | 
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i, 0)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardItem, 0)  
 | 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActivityPlaceRewardCount, 0)  
 | 
      
 | 
    GameWorld.DebugLog("ÁìÈ¡»îÔ¾·ÅÖý±Àø: rewardCount=%s,rewardItemCount=%s,rewardItemList=%s" % (rewardCount, rewardItemCount, rewardItemList))  
 | 
    ItemControler.GivePlayerItemOrMail(curPlayer, rewardItemList)  
 | 
      
 | 
    EventShell.EventRespons_ActivityPlace(curPlayer, "getreward")  
 | 
    PlayerActGarbageSorting.AddActGarbageTaskProgress(curPlayer, ChConfig.Def_GarbageTask_ActivityPlace, rewardCount)  
 | 
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ActivityPlace, rewardCount)  
 | 
    PlayerGubao.AddGubaoItemEffValue(curPlayer, PlayerGubao.GubaoEffType_ActivityPlace, rewardCount)  
 | 
      
 | 
    Sync_ActivityPlaceInfo(curPlayer)  
 | 
    return  
 | 
  
 | 
def Sync_ActivityPlaceInfo(curPlayer):  
 | 
    ## Í¬²½»îÔ¾·ÅÖÃÐÅÏ¢  
 | 
    rewardItemInfo = []  
 | 
    rewardItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItem)  
 | 
    for i in xrange(rewardItemCount):  
 | 
        itemID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemID % i)  
 | 
        itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardItemCount % i)  
 | 
        rewardItemInfo.append([itemID, itemCount])  
 | 
    placeInfo = ChPyNetSendPack.tagMCActivityPlaceInfo()  
 | 
    placeInfo.StartTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceStartTime)  
 | 
    placeInfo.PlaceCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRemainCount)  
 | 
    placeInfo.RewardCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceRewardCount)  
 | 
    placeInfo.RewardInfo = str(rewardItemInfo)  
 | 
    placeInfo.RewardLen = len(placeInfo.RewardInfo)  
 | 
    placeInfo.TodayExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceTodayExp)  
 | 
    placeInfo.TodayExpPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceTodayExpPoint)  
 | 
    placeInfo.YestordayExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceYestorDayExp)  
 | 
    placeInfo.YestordayExpPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActivityPlaceYestorDayExpPoint)  
 | 
    NetPackCommon.SendFakePack(curPlayer, placeInfo)  
 | 
    return  
 | 
  
 | 
#########################################################################################  
 | 
  
 | 
  
 | 
  
 |