#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#---------------------------------------------------------------------  
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
##@package GameWorldActionControl  
 | 
# @todo: Ö»×öÊÀ½ç֪ͨºÍ»î¶¯µÄ×Ü¿ª¹ØÂß¼£¨°´Ê±¼ä£©  
 | 
#  
 | 
# @author: hch  
 | 
# @date 2010-3-31  
 | 
# @version 1.1  
 | 
#  
 | 
# @note: Ö»×öÊÀ½ç֪ͨºÍ»î¶¯µÄ×Ü¿ª¹ØÂß¼(°´Ê±¼ä)  
 | 
#  
 | 
# @change: "2018-7-16 12:00" hxp Ôö¼ÓÔËÓª»î¶¯Ê±¼ä¿ØÖÆÖ§³Ö£»Ôö¼Ó¶à±¶¾Ñé»î¶¯¡¢Ïû·Ñ·µÀû»î¶¯  
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
#"""Version = 2018-7-16 12:00"""  
 | 
#---------------------------------------------------------------------  
 | 
import ChConfig  
 | 
import datetime  
 | 
import GameWorld  
 | 
import ReadChConfig  
 | 
import PlayerControl  
 | 
import ShareDefine  
 | 
#import PlayerExam  
 | 
import PlayerDBGSEvent  
 | 
import MergeBroadcast  
 | 
#import PlayerManorWar  
 | 
#import GameWorldShopItem  
 | 
#import GameWorldActionTeHui  
 | 
import GameWorldAverageLv  
 | 
#import GameWorldMergeBoss  
 | 
#import GameWorldMergeKing  
 | 
#import GameWorldMergePK  
 | 
import GameWorldFamilyWar  
 | 
import PlayerFamilyParty  
 | 
import IpyGameDataPY  
 | 
import PlayerXMZZ  
 | 
import PlayerFamilySWRH  
 | 
import GameWorldBoss  
 | 
import PlayerFairyCeremony  
 | 
import ChPyNetSendPack  
 | 
import NetPackCommon  
 | 
  
 | 
from types import IntType  
 | 
import time  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
#ÄêÔÂÈÕʱ¼ä¸ñʽ  
 | 
Time_YmdFormat = ChConfig.TYPE_Time_YmdFormat  
 | 
  
 | 
ATTR_CALL_TIME = ['weekday', 'year', 'month', 'day', 'hour', 'minute']  
 | 
  
 | 
(  
 | 
OperationAction_OpenServerDay, # ÐÅÏ¢ËùÊô¿ª·þÌì  
 | 
OperationAction_TodayInfo, # µ±ÈյĻÐÅÏ¢  
 | 
OperationAction_MapServerInfo, # Í¬²½µØÍ¼µÄ»î¶¯ÐÅÏ¢  
 | 
) = range(3)  
 | 
  
 | 
def OnPlayerLogin(curPlayer):  
 | 
      
 | 
    isReload, OperationActionInfo = __GetOperationActionInfo()  
 | 
    operationActionDict = OperationActionInfo[OperationAction_TodayInfo]  
 | 
      
 | 
    if isReload:  
 | 
        return  
 | 
      
 | 
    # ¶à±¶¾Ñé»î¶¯½øÐÐÖÐ  
 | 
    if ShareDefine.OperationActionName_ExpRate in operationActionDict:  
 | 
        ipyData = operationActionDict[ShareDefine.OperationActionName_ExpRate][0]  
 | 
        if ipyData:  
 | 
            Sync_OperationAction_ExpRate(ipyData, curPlayer)  
 | 
  
 | 
    # ÏɽçÊ¢µä»î¶¯½øÐÐÖÐ  
 | 
    if ShareDefine.OperationActionName_FairyCeremony in operationActionDict:  
 | 
        ipyData = operationActionDict[ShareDefine.OperationActionName_FairyCeremony][0]  
 | 
        if ipyData:  
 | 
            PlayerFairyCeremony.Sync_OperationAction_FairyCeremony(ipyData, curPlayer)  
 | 
          
 | 
    # ¶à±¶ÐÞÐеã»î¶¯½øÐÐÖÐ  
 | 
    if ShareDefine.OperationActionName_RealmPoint in operationActionDict:  
 | 
        ipyData = operationActionDict[ShareDefine.OperationActionName_RealmPoint][0]  
 | 
        if ipyData:  
 | 
            Sync_OperationAction_RealmPoint(ipyData, curPlayer)  
 | 
    return  
 | 
  
 | 
def SendMapServerOperationActionState():  
 | 
    # µØÍ¼Æô¶¯³É¹¦Ê±Í¨Öª±¾ÈÕÔËÐлÏà¹Ø×´Ì¬  
 | 
      
 | 
    isReload, OperationActionInfo = __GetOperationActionInfo()  
 | 
    mapServerInfoDict = OperationActionInfo[OperationAction_MapServerInfo]  
 | 
      
 | 
    if isReload:  
 | 
        # Èç¹ûÊÇÖØ¶ÁµÄ£¬ÔòÔÚÄÚ²ãÒѾͬ²½ÁË£¬´Ë´¦²»Öظ´Í¬²½  
 | 
        return  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    for actName in ShareDefine.OperationActionNameList:  
 | 
        dictName = ChConfig.Def_WorldKey_OperationActionState % actName  
 | 
        state = gameWorld.GetDictByKey(dictName)  
 | 
          
 | 
        sendMapServerMsgDict = mapServerInfoDict.get(actName, {}) if state else {}  
 | 
        sendMapServerMsgDict[ShareDefine.ActKey_State] = state  
 | 
        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_OperationActionInfo % actName, sendMapServerMsgDict)  
 | 
          
 | 
    return  
 | 
  
 | 
def __GetOperationActionInfo(isRefreshState=True):  
 | 
    # @return: isReload, OperationActionInfo  
 | 
      
 | 
    key = "OperationActionInfo"  
 | 
    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1  
 | 
    OperationActionInfo = IpyGameDataPY.GetConfigEx(key)  
 | 
    if OperationActionInfo and OperationActionInfo[OperationAction_OpenServerDay] == openServerDay:  
 | 
        #GameWorld.DebugLog("ÒѾ¼ÓÔØ¹ý±¾ÈÕÔËÓª»î¶¯´¦ÀíÐÅÏ¢£¡openServerDay=%s" % openServerDay)  
 | 
        return False, OperationActionInfo  
 | 
      
 | 
    # ÒòΪºóÃæµÄʱ¼äÅж϶¼ÊǾ«È·µ½·ÖµÄ£¬¶ø´¦Àí´ËÂß¼µÄʱºò¿ÉÄܲ»ÊÇ0Ã룬ËùÒÔÕâÀïµÄdatetimeÈ¡µ±Ç°Ê±¼ä¾«È·µ½·ÖµÄ  
 | 
    serverTime = GameWorld.GetServerTime()  
 | 
    curDateTimeStr = "%d-%d-%d %02d:%02d:00" % (serverTime.year, serverTime.month, serverTime.day, serverTime.hour, serverTime.minute)  
 | 
    curDateTime = datetime.datetime.strptime(curDateTimeStr, ChConfig.TYPE_Time_Format)  
 | 
    GameWorld.Log("¼ÓÔØ±¾ÈÕÔËÓª»î¶¯ÐÅÏ¢: %s, openServerDay=%s" % (curDateTime, openServerDay))  
 | 
      
 | 
    operationActionDict = {}  
 | 
    mapServerOperationActionDict = {}  
 | 
    serverID = GameWorld.GetServerID()  
 | 
    ipyDataMgr = IpyGameDataPY.IPY_Data()  
 | 
      
 | 
    for actName in ShareDefine.OperationActionNameList:  
 | 
          
 | 
        # È¡³ö±¾»î¶¯ËùÊô±¾·þIDµÄËùÓÐÅäÖà  
 | 
        curServerActIpyDataList = __GetOperationActionServerIpyDataList(ipyDataMgr, serverID, actName)  
 | 
          
 | 
        needStartList = [] # [startDateTime, ...]  
 | 
        needEndList = [] # [endDateTime, ...]  
 | 
        needNotifyDict = {} # {notifyDateTime:[notifyKey, [²ÎÊý]], ...}  
 | 
        activityIpyData = None # »î¶¯ÖеĵÄÅäÖã¬È¡ÐèÒª´¦ÀíµÄÅäÖÃÖпªÊ¼Ê±¼ä×îÍíµÄ£¬·´Ö®¿ª¹ØÊ±¼äͷβÏàÁ¬µÄʱºòÎÞ·¨¿ªÆôºóÃæµÄ»î¶¯  
 | 
        # ×¢Ò⣺ÿ¸ö»î¶¯ÅäÖûáÓжà¸ö»î¶¯Ê±¼äµã£¬µ«ÊÇÓÐÇÒÖ»ÄÜÉúЧһÌõ»î¶¯ÅäÖ㬻»¾ä»°Ëµ¾ÍÊÇÿ¸ö»î¶¯ÅäÖÃʱ¼ä²»ÔÊÐí½»²æ  
 | 
        for ipyData in curServerActIpyDataList:  
 | 
              
 | 
            startDateStr = ipyData.GetStartDate()  
 | 
            endDateStr = ipyData.GetEndDate()  
 | 
              
 | 
            if hasattr(ipyData, "GetStartTimeList") and hasattr(ipyData, "GetEndTimeList"):  
 | 
                startHMStrList = ipyData.GetStartTimeList()  
 | 
                endHMStrList = ipyData.GetEndTimeList()  
 | 
            else:  
 | 
                startHMStrList = []  
 | 
                endHMStrList = []  
 | 
                  
 | 
            notifyInfoDictStart = ipyData.GetNotifyInfoStart() if hasattr(ipyData, "GetNotifyInfoStart") else {}  
 | 
            notifyInfoDictEnd = ipyData.GetNotifyInfoEnd() if hasattr(ipyData, "GetNotifyInfoEnd") else {}  
 | 
              
 | 
            if len(startHMStrList) != len(endHMStrList):  
 | 
                GameWorld.ErrLog("»î¶¯ÅäÖÿªÊ¼¼°½áÊøÊ±¼ä¸öÊý²»Æ¥Åä! actName=%s,cfgID=%s" % (actName, ipyData.GetCfgID()))  
 | 
                continue  
 | 
              
 | 
            startList = [] # [startDateTime, ...]  
 | 
            endList = [] # [endDateTime, ...]  
 | 
            isActivity = False # ÓÐÐèÒª´¦Àí¿ª¹ØÊ±¼äµÄ£¨¿ªÊ¼¡¢½áÊø£©  
 | 
            isNotify = False  
 | 
            # Ã»ÅäÖÃʱ·ÖµÄ´ú±íÈ«Ìì, Ö»Òª¿ªÊ¼»ò½áÊøÊ±·ÖûÅä¶¼Ëã  
 | 
            if not startHMStrList or not endHMStrList:  
 | 
                startDayDate = datetime.datetime.strptime("%s 00:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) # ¿ªÊ¼Ìì0µã  
 | 
                endDayDate = datetime.datetime.strptime("%s 00:00:00" % (endDateStr), ChConfig.TYPE_Time_Format) + datetime.timedelta(days=1) # ½áÊøÌì¸ôÌì0µã  
 | 
                startDateTime = startDayDate  
 | 
                endDateTime = endDayDate  
 | 
                startList.append(startDateTime)  
 | 
                endList.append(endDateTime)  
 | 
                if startDayDate <= curDateTime <= endDayDate:  
 | 
                    needStartList.append(startDateTime)  
 | 
                    needEndList.append(endDateTime)  
 | 
                    isActivity = True  
 | 
                      
 | 
            # Ã¿Ì찴ʱ¶Î¿ªÆôµÄ£¬Ö§³Ö¶àʱ¶Î  
 | 
            else:  
 | 
                startDayDate = datetime.datetime.strptime("%s 00:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) # ¿ªÊ¼Ìì0µã  
 | 
                endDayDate = datetime.datetime.strptime("%s 23:59:59" % (endDateStr), ChConfig.TYPE_Time_Format) # ½áÊøÌì23µã59·Ö59Ãë  
 | 
                if startDayDate <= curDateTime <= endDayDate:  
 | 
                    for hmIndex, startHMStr in enumerate(startHMStrList):  
 | 
                        endHMStr = endHMStrList[hmIndex]  
 | 
                        # Ã¿Ì쿪µÄ, Êµ¼Ê¿ª¹ØÊ±¼äֻȡ½ñÌìµÄÈÕÆÚ£» ÕâÀïÓиöÎÊÌ⣬ȫ·þ¹ã²¥µÄʱ¼ä²»ÊǽñÌìµÄ, Ôݲ»×öÖ§³Ö£¬Ö®ºóÕæÓÐÕâÖÖÐèÇóÔÙ˵  
 | 
                        startTimeStr = "%d-%d-%d %s:00" % (curDateTime.year, curDateTime.month, curDateTime.day, startHMStr)  
 | 
                        endTimeStr = "%d-%d-%d %s:00" % (curDateTime.year, curDateTime.month, curDateTime.day, endHMStr)  
 | 
                        startDateTime = datetime.datetime.strptime(startTimeStr, ChConfig.TYPE_Time_Format)  
 | 
                        endDateTime = datetime.datetime.strptime(endTimeStr, ChConfig.TYPE_Time_Format)  
 | 
                          
 | 
                        startList.append(startDateTime)  
 | 
                        endList.append(endDateTime)  
 | 
                          
 | 
                        needStartList.append(startDateTime)  
 | 
                        needEndList.append(endDateTime)  
 | 
                        isActivity = True  
 | 
                          
 | 
            for dtIndex, startDateTime in enumerate(startList):  
 | 
                endDateTime = endList[dtIndex]  
 | 
                # ¹ã²¥ - Ïà¶Ôʵ¼Ê¿ªÊ¼Ê±¼ä  
 | 
                for notifyMinute, notifyInfo in notifyInfoDictStart.items():  
 | 
                    notifyDateTime = startDateTime + datetime.timedelta(minutes=notifyMinute)  
 | 
                    if notifyDateTime.year == curDateTime.year and notifyDateTime.month == curDateTime.month and notifyDateTime.day == curDateTime.day:  
 | 
                        needNotifyDict[notifyDateTime] = notifyInfo  
 | 
                        isNotify = True  
 | 
                      
 | 
                # ¹ã²¥ - Ïà¶Ôʵ¼Ê½áÊøÊ±¼ä  
 | 
                for notifyMinute, notifyInfo in notifyInfoDictEnd.items():  
 | 
                    notifyDateTime = endDateTime + datetime.timedelta(minutes=notifyMinute)  
 | 
                    if notifyDateTime.year == curDateTime.year and notifyDateTime.month == curDateTime.month and notifyDateTime.day == curDateTime.day:  
 | 
                        needNotifyDict[notifyDateTime] = notifyInfo  
 | 
                        isNotify = True  
 | 
                         
 | 
            if not isActivity and not isNotify:  
 | 
                continue  
 | 
              
 | 
            GameWorld.Log("    ±¾ÈÕÐèÒª´¦ÀíµÄÔËÓª»î¶¯ÐÅÏ¢: actName=%s,cfgID=%s,actMark=%s" % (actName, ipyData.GetCfgID(), ipyData.GetActMark()))  
 | 
            if isActivity:  
 | 
                if not activityIpyData or activityIpyData.GetStartDate() < ipyData.GetStartDate():  
 | 
                    activityIpyData = ipyData  
 | 
                      
 | 
        if activityIpyData or needStartList or needEndList or needNotifyDict:  
 | 
            # activityIpyData ¿ÉÄÜΪNone  
 | 
            operationActionDict[actName] = [activityIpyData, needStartList, needEndList, needNotifyDict]  
 | 
            # ÐÂÔöÔËÓª»î¶¯Ö»ÒªÔÚ´Ë´¦Ìí¼Óͬ²½MapServerËùÐèÒªµÄÊý¾Ý×ֵ伴¿É£¬ÆäËûÂß¼¾ùΪ¹«¹²Âß¼  
 | 
            mapServerOperationActionDict[actName] = __GetOperationActionMapServerInfoDict(curDateTime, actName, activityIpyData)  
 | 
              
 | 
    OperationActionInfo = IpyGameDataPY.SetConfigEx(key, [openServerDay, operationActionDict, mapServerOperationActionDict])  
 | 
      
 | 
    GameWorld.Log("±¾ÈÕÔËÓª»î¶¯ÐÅÏ¢¼ÓÔØÍê±Ï!isRefreshState=%s" % isRefreshState)  
 | 
    GameWorld.Log("    operationActionDict=%s" % operationActionDict)  
 | 
    GameWorld.Log("    mapServerOperationActionDict=%s" % mapServerOperationActionDict)  
 | 
      
 | 
    if isRefreshState:  
 | 
        Dispose_OperationActionState(True)  
 | 
          
 | 
    return True, OperationActionInfo  
 | 
  
 | 
def __GetOperationActionServerIpyDataList(ipyDataMgr, serverID, actName):  
 | 
    ## »ñÈ¡ÔËÓª»î¶¯±¾·þÎñÆ÷¶ÔÓ¦µÄÅäÖÃÊý¾ÝÁÐ±í  
 | 
      
 | 
    # ËùÓÐÅäÖÃÏȰ´»î¶¯±êʶ¹é×é  
 | 
    actGroupDict = {} # {ActMark:{ServerIDTuple:[ipyData, ...], ...}, ...}  
 | 
    actCfgCount = getattr(ipyDataMgr, "Get%sCount" % actName)()  
 | 
    for cfgIndex in xrange(actCfgCount):  
 | 
        ipyData = getattr(ipyDataMgr, "Get%sByIndex" % actName)(cfgIndex)  
 | 
        actMark = ipyData.GetActMark()  
 | 
        serverIDTuple = tuple(ipyData.GetServerIDList())  
 | 
          
 | 
        serverIpyDataDict = actGroupDict.get(actMark, {})  
 | 
        ipyDataList = serverIpyDataDict.get(serverIDTuple, [])  
 | 
        ipyDataList.append(ipyData)  
 | 
        serverIpyDataDict[serverIDTuple] = ipyDataList  
 | 
        actGroupDict[actMark] = serverIpyDataDict  
 | 
          
 | 
    # È¡³öËùÊô±¾·þIDµÄËùÓÐÅäÖà  
 | 
    curServerActIpyDataList = []  
 | 
    for actMark, serverIpyDataDict in actGroupDict.items():  
 | 
        generalIpyDataList = []  
 | 
        isGeneral = True  
 | 
        for serverIDTuple, ipyDataList in serverIpyDataDict.items():  
 | 
            if not serverIDTuple:  
 | 
                generalIpyDataList = ipyDataList  
 | 
                continue  
 | 
            for serverIDInfo in serverIDTuple:  
 | 
                if (isinstance(serverIDInfo, int) and serverIDInfo == serverID) \  
 | 
                    or ((isinstance(serverIDInfo, list) or isinstance(serverIDInfo, tuple)) \  
 | 
                        and len(serverIDInfo) == 2 and serverIDInfo[0] <= serverID <= serverIDInfo[1]):  
 | 
                    curServerActIpyDataList += ipyDataList  
 | 
                    isGeneral = False  
 | 
                    break  
 | 
        if isGeneral:  
 | 
            curServerActIpyDataList += generalIpyDataList  
 | 
    return curServerActIpyDataList  
 | 
  
 | 
def __GetOperationActionMapServerInfoDict(curDateTime, actName, ipyData):  
 | 
    ## »ñÈ¡ÔËÓª»î¶¯Í¬²½µ½µØÍ¼·þÎñÆ÷µÄÐÅÏ¢×ֵ䠠    
 | 
    if not ipyData:  
 | 
        return {}  
 | 
      
 | 
    startDateStr = ipyData.GetStartDate()  
 | 
    startDayDate = datetime.datetime.strptime("%s 00:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) # ¿ªÊ¼Ìì0µã  
 | 
    dayIndex = (curDateTime - startDayDate).days # µ±Ç°ÈÕÆÚÔڻÆÚ¼äµÄÌìË÷Òý  
 | 
    if dayIndex < 0:  
 | 
        GameWorld.DebugLog("        ²»´¦ÀíÔËÓªµØÍ¼Êý¾Ý: startDateStr=%s,curDateTime=%s,startDayDate=%s,dayIndex=%s"   
 | 
                           % (startDateStr, curDateTime, startDayDate, dayIndex))  
 | 
        return {}  
 | 
      
 | 
    actID = int(time.mktime(startDayDate.timetuple()))  
 | 
      
 | 
    mapServerInfoDict = {}  
 | 
    # ¶à±¶¾Ñé»î¶¯  
 | 
    if actName == ShareDefine.OperationActionName_ExpRate:  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_LVLimit:ipyData.GetLVLimit(),  
 | 
                             ShareDefine.ActKey_AddExpRate:ipyData.GetAddExpRate()}  
 | 
    # Ïû·Ñ·µÀû»î¶¯  
 | 
    elif actName == ShareDefine.OperationActionName_CostRebate:  
 | 
        isDayReset = ipyData.GetIsDayReset()  
 | 
        if isDayReset:  
 | 
            # Ã¿ÌìÖØÖõĻIDÈ¡µ±ÌìµÄtimeÖµ  
 | 
            actIDDateStr = "%d-%d-%d 00:00:00" % (curDateTime.year, curDateTime.month, curDateTime.day)  
 | 
            actIDDateTime = datetime.datetime.strptime(actIDDateStr, ChConfig.TYPE_Time_Format)  
 | 
            actID = int(time.mktime(actIDDateTime.timetuple()))  
 | 
        templateIDList = ipyData.GetTemplateIDList()  
 | 
        templateID = templateIDList[-1] if dayIndex >= len(templateIDList) else templateIDList[dayIndex]  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_ID:actID,  
 | 
                             ShareDefine.ActKey_StartDate:ipyData.GetStartDate(),  
 | 
                             ShareDefine.ActKey_EndDate:ipyData.GetEndDate(),  
 | 
                             ShareDefine.ActKey_LVLimit:ipyData.GetLVLimit(),  
 | 
                             ShareDefine.ActKey_IsDayReset:ipyData.GetIsDayReset(),  
 | 
                             ShareDefine.ActKey_TemplateID:templateID,  
 | 
                             ShareDefine.ActKey_TemplateIDList:templateIDList}  
 | 
    # ÏÞÊ±ÌØ»Ý»î¶¯  
 | 
    elif actName == ShareDefine.OperationActionName_SpringSale:  
 | 
        isDayReset = ipyData.GetIsDayReset()  
 | 
        if isDayReset:  
 | 
            # Ã¿ÌìÖØÖõĻIDÈ¡µ±ÌìµÄtimeÖµ  
 | 
            actIDDateStr = "%d-%d-%d 00:00:00" % (curDateTime.year, curDateTime.month, curDateTime.day)  
 | 
            actIDDateTime = datetime.datetime.strptime(actIDDateStr, ChConfig.TYPE_Time_Format)  
 | 
            actID = int(time.mktime(actIDDateTime.timetuple()))  
 | 
        shopTypeList = ipyData.GetShopTypeList()  
 | 
        todayShopType = shopTypeList[-1] if dayIndex >= len(shopTypeList) else shopTypeList[dayIndex]  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_ID:actID,  
 | 
                             ShareDefine.ActKey_CfgID:ipyData.GetCfgID(),   
 | 
                             ShareDefine.ActKey_ShopTypeList:todayShopType}  
 | 
    # Boss¸´»î»î¶¯  
 | 
    elif actName == ShareDefine.OperationActionName_BossReborn:  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_ID:actID,  
 | 
                             ShareDefine.ActKey_TemplateID:ipyData.GetTemplateID(),  
 | 
                             ShareDefine.ActKey_StartDate:ipyData.GetStartDate(),  
 | 
                             ShareDefine.ActKey_EndDate:ipyData.GetEndDate(),  
 | 
                             ShareDefine.ActKey_LVLimit:ipyData.GetLVLimit(),}  
 | 
    # ÏÞʱÀñ°ü»î¶¯  
 | 
    elif actName == ShareDefine.OperationActionName_FlashGiftbag:  
 | 
        isDayReset = ipyData.GetIsDayReset()  
 | 
        if isDayReset:  
 | 
            # Ã¿ÌìÖØÖõĻIDÈ¡µ±ÌìµÄtimeÖµ  
 | 
            actIDDateStr = "%d-%d-%d 00:00:00" % (curDateTime.year, curDateTime.month, curDateTime.day)  
 | 
            actIDDateTime = datetime.datetime.strptime(actIDDateStr, ChConfig.TYPE_Time_Format)  
 | 
            actID = int(time.mktime(actIDDateTime.timetuple()))  
 | 
        giftbagTypeList = ipyData.GetGiftbagTypeList()  
 | 
        todayGiftbag = giftbagTypeList[-1] if dayIndex >= len(giftbagTypeList) else giftbagTypeList[dayIndex]  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_ID:actID,  
 | 
                             ShareDefine.ActKey_CfgID:ipyData.GetCfgID(),   
 | 
                             ShareDefine.ActKey_GiftbagTypeList:todayGiftbag}  
 | 
    # ÏɽçÊ¢µä»î¶¯  
 | 
    elif actName == ShareDefine.OperationActionName_FairyCeremony:  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_ID:actID}  
 | 
    # ¶à±¶ÐÞÐеã»î¶¯  
 | 
    if actName == ShareDefine.OperationActionName_RealmPoint:  
 | 
        mapServerInfoDict = {ShareDefine.ActKey_LVLimit:ipyData.GetLVLimit(),  
 | 
                             ShareDefine.ActKey_RealmPointMulti:ipyData.GetMultiple()}  
 | 
    return mapServerInfoDict  
 | 
  
 | 
def Dispose_OperationActionState(reloadRefresh=False):  
 | 
    # ÔËÓª»î¶¯×´Ì¬´¦Àí, Ã¿Ìì0µã»áÇ¿ÖÆÍ¬²½µ±ÌìµÄÔËÓª»î¶¯ÏêÇéµ½µØÍ¼·þÎñÆ÷  
 | 
      
 | 
    isReload, OperationActionInfo = __GetOperationActionInfo(False) # ÕâÀï±ØÐë´«False  
 | 
    isReload = isReload or reloadRefresh  
 | 
    operationActionDict = OperationActionInfo[OperationAction_TodayInfo]  
 | 
    mapServerInfoDict = OperationActionInfo[OperationAction_MapServerInfo]  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
      
 | 
    # ÕâÀïʱ¼äÐ辫ȷµ½·ÖÖÓ£¬²»È»ºóÃæµÄ±È½Ï»áÆ¥Åä²»µ½  
 | 
    curDateTime = GameWorld.GetServerTime()  
 | 
    curDateTime = datetime.datetime.strptime("%d-%d-%d %d:%d:00" % (curDateTime.year, curDateTime.month, curDateTime.day,  
 | 
                                                                    curDateTime.hour, curDateTime.minute), ChConfig.TYPE_Time_Format)  
 | 
      
 | 
    for actName in ShareDefine.OperationActionNameList:  
 | 
          
 | 
        state = 0 # Ä¬ÈÏ¹Ø±Õ  
 | 
        ipyData = None  
 | 
          
 | 
        if actName in operationActionDict:  
 | 
              
 | 
            #startList = [] # [startDateTime, ...]  
 | 
            #endList = [] # [endDateTime, ...]  
 | 
            #notifyDict = {} # {notifyDateTime:[notifyKey, [²ÎÊý]], ...}  
 | 
            #ipyData ¿ÉÄÜΪ None  
 | 
            ipyData, startList, endList, notifyDict = operationActionDict[actName]  
 | 
            # ¾«È·Æ¥Å俪Æô  
 | 
            if curDateTime in startList:  
 | 
                state = startList.index(curDateTime) + 1 # Ò²ÊÇ´ú±íµÚ¼¸¸öʱ¼ä¶Î  
 | 
            # ¾«È·Æ¥Å乨±Õ  
 | 
            elif curDateTime in endList:  
 | 
                state = 0  
 | 
            # goon ×´Ì¬  
 | 
            else:  
 | 
                for dIndex, startDateTime in enumerate(startList):  
 | 
                    endDateTime = endList[dIndex]  
 | 
                    if startDateTime < curDateTime < endDateTime:  
 | 
                        state = dIndex + 1  
 | 
                        break  
 | 
                      
 | 
            # È«·þ¹ã²¥ÌáʾÐÅÏ¢  
 | 
            if curDateTime in notifyDict:  
 | 
                notifyKey, paramList = notifyDict[curDateTime]  
 | 
                PlayerControl.WorldNotify(0, notifyKey, paramList)  
 | 
                  
 | 
        dictName = ChConfig.Def_WorldKey_OperationActionState % actName  
 | 
        preState = gameWorld.GetDictByKey(dictName)  
 | 
        if not isReload and preState == state:  
 | 
            #ÒѾÊÇÕâ¸ö״̬ÁË  
 | 
            continue  
 | 
        #¸üÐÂ×ÖµäÖµ  
 | 
        gameWorld.SetDict(dictName, state)  
 | 
        sendMapServerMsgDict = mapServerInfoDict.get(actName, {}) if state else {}  
 | 
          
 | 
        dbOperationActIDKey = PlayerDBGSEvent.Def_OperationActID % actName  
 | 
        curActID = sendMapServerMsgDict.get(ShareDefine.ActKey_ID)  
 | 
        if state >= 1 and curActID and PlayerDBGSEvent.GetDBGSTrig_ByKey(dbOperationActIDKey) != curActID:  
 | 
            PlayerDBGSEvent.SetDBGSTrig_ByKey(dbOperationActIDKey, curActID)  
 | 
            if actName in ShareDefine.NeedWorldLVOperationActNameList:  
 | 
                #¼Ç¼¿ªÆôʱÊÀ½çµÈ¼¶  
 | 
                worldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)  
 | 
                PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_OActWorldLV % actName, worldLV)  
 | 
                  
 | 
            #´Ë´¦Îª»î¶¯¿ªÆôʱ  
 | 
            if actName == ShareDefine.OperationActionName_BossReborn:  
 | 
                #ÖØÖÃBOSS¸´»îµã  
 | 
                GameWorldBoss.ResetBossRebornPoint()  
 | 
            elif actName == ShareDefine.OperationActionName_FairyCeremony:  
 | 
                #ÖØÖÃÏɽçÊ¢µä  
 | 
                PlayerFairyCeremony.ResetFairyCeremony()  
 | 
              
 | 
              
 | 
                  
 | 
        if state == 1 and actName in ShareDefine.NeedWorldLVOperationActNameList:  
 | 
            actWorldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_OActWorldLV % actName)  
 | 
            sendMapServerMsgDict[ShareDefine.ActKey_WorldLV] = actWorldLV  
 | 
          
 | 
        if actName == ShareDefine.OperationActionName_ExpRate:  
 | 
            if isReload and ipyData:  
 | 
                Sync_OperationAction_ExpRate(ipyData)  
 | 
                  
 | 
        elif actName == ShareDefine.OperationActionName_CostRebate:  
 | 
            if isReload and ipyData:  
 | 
                pass  
 | 
        elif actName == ShareDefine.OperationActionName_BossReborn:  
 | 
            if isReload and ipyData:  
 | 
                GameWorldBoss.SetBossRebornNeedPoint(True)  
 | 
  
 | 
        elif actName == ShareDefine.OperationActionName_FairyCeremony:  
 | 
            if isReload and ipyData:  
 | 
                PlayerFairyCeremony.Sync_OperationAction_FairyCeremony(ipyData)  
 | 
            if preState != state and state == 0:  
 | 
                PlayerFairyCeremony.OnFairyCeremonyEnd()  
 | 
        elif actName == ShareDefine.OperationActionName_RealmPoint:  
 | 
            if isReload and ipyData:  
 | 
                Sync_OperationAction_RealmPoint(ipyData)  
 | 
        #֪ͨMapserver,ÉèÖÃ×Öµä  
 | 
        #GameWorld.SendMapServerMsgEx(dictName, state) # ÔËÓª»î¶¯²»µ¥¶À֪ͨ»î¶¯×´Ì¬£¬ÐèÓë»î¶¯ÐÅÏ¢ÕûºÏºóÒ»Æð֪ͨ  
 | 
          
 | 
        sendMapServerMsgDict[ShareDefine.ActKey_State] = state  
 | 
        GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_OperationActionInfo % actName, sendMapServerMsgDict)  
 | 
          
 | 
        GameWorld.Log("ÔËÓª»î¶¯±ä¸ü: actName=%s,preState=%s,state=%s,dictName=%s, %s" % (actName, preState, state, dictName, sendMapServerMsgDict))  
 | 
    return  
 | 
  
 | 
def Sync_OperationAction_ExpRate(ipyData, curPlayer=None):  
 | 
    if not ipyData:  
 | 
        return  
 | 
    if len(ipyData.GetStartTimeList()) != len(ipyData.GetEndTimeList()):  
 | 
        return  
 | 
    multiExpRateInfo = ChPyNetSendPack.tagGCMultiExpRateInfo()  
 | 
    multiExpRateInfo.Clear()  
 | 
    multiExpRateInfo.StartDate = ipyData.GetStartDate()  
 | 
    multiExpRateInfo.EndtDate = ipyData.GetEndDate()  
 | 
    multiExpRateInfo.ActivityTime = []  
 | 
    for i, startTime in enumerate(ipyData.GetStartTimeList()):  
 | 
        endTime = ipyData.GetEndTimeList()[i]  
 | 
        timeInfo = ChPyNetSendPack.tagGCMultiExpRateTime()  
 | 
        timeInfo.StartTime = startTime  
 | 
        timeInfo.EndtTime = endTime  
 | 
        multiExpRateInfo.ActivityTime.append(timeInfo)  
 | 
    multiExpRateInfo.ActivityTimeCount = len(multiExpRateInfo.ActivityTime)  
 | 
    multiExpRateInfo.LimitLV = ipyData.GetLVLimit()  
 | 
    multiExpRateInfo.AddExpRate = ipyData.GetAddExpRate()  
 | 
      
 | 
    if not curPlayer:  
 | 
        # È«·þ¹ã²¥ÔÚÏßÍæ¼Ò  
 | 
        playerManager = GameWorld.GetPlayerManager()  
 | 
        for i in xrange(playerManager.GetPlayerCount()):  
 | 
            curPlayer = playerManager.GetPlayerByIndex(i)  
 | 
            if curPlayer == None or not curPlayer.GetInitOK():  
 | 
                continue  
 | 
            NetPackCommon.SendFakePack(curPlayer, multiExpRateInfo)  
 | 
    else:  
 | 
        NetPackCommon.SendFakePack(curPlayer, multiExpRateInfo)  
 | 
    return  
 | 
  
 | 
  
 | 
def Sync_OperationAction_RealmPoint(ipyData, curPlayer=None):  
 | 
    ##¶à±¶ÐÞÐеã»î¶¯ÐÅϢ֪ͨ  
 | 
    if not ipyData:  
 | 
        return  
 | 
    multiRealmPointInfo = ChPyNetSendPack.tagGCMultiRealmPointInfo()  
 | 
    multiRealmPointInfo.Clear()  
 | 
    multiRealmPointInfo.StartDate = ipyData.GetStartDate()  
 | 
    multiRealmPointInfo.EndtDate = ipyData.GetEndDate()  
 | 
    multiRealmPointInfo.Multiple = ipyData.GetMultiple()  
 | 
    multiRealmPointInfo.LimitLV = ipyData.GetLVLimit()  
 | 
    if not curPlayer:  
 | 
        # È«·þ¹ã²¥ÔÚÏßÍæ¼Ò  
 | 
        playerManager = GameWorld.GetPlayerManager()  
 | 
        for i in xrange(playerManager.GetPlayerCount()):  
 | 
            curPlayer = playerManager.GetPlayerByIndex(i)  
 | 
            if curPlayer == None or not curPlayer.GetInitOK():  
 | 
                continue  
 | 
            NetPackCommon.SendFakePack(curPlayer, multiRealmPointInfo)  
 | 
    else:  
 | 
        NetPackCommon.SendFakePack(curPlayer, multiRealmPointInfo)  
 | 
    return  
 | 
  
 | 
  
 | 
##--------------------------------------------------------------------------------------------------  
 | 
  
 | 
def __GetTodayDailyActionInfo():  
 | 
    # »ñÈ¡±¾ÈÕ´ý´¦ÀíµÄÈÕ³£»î¶¯ÐÅÏ¢  
 | 
    key = "TodayDailyActionInfo"  
 | 
    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1  
 | 
    TodayDailyActionInfo = IpyGameDataPY.GetConfigEx(key)  
 | 
    if TodayDailyActionInfo and TodayDailyActionInfo[0] == openServerDay:  
 | 
        #GameWorld.DebugLog("ÒѾ¼ÓÔØ¹ý±¾ÈÕÈÕ³£»î¶¯´¦ÀíÐÅÏ¢£¡openServerDay=%s" % openServerDay)  
 | 
        return TodayDailyActionInfo[1]  
 | 
      
 | 
    todayActionInfo = []  
 | 
      
 | 
    dayTime = GameWorld.GetServerTime()  
 | 
    weekDay = str(dayTime.weekday() + 1) # ¸ñʽΪjson, µ±Ç°ÐÇÆÚ¼¸, 1´ú±íÐÇÆÚ1  
 | 
    curTime = int(time.time())  
 | 
    curDateStr = GameWorld.ChangeTimeNumToStr(curTime, ChConfig.TYPE_Time_YmdFormat) # µ±ÌìÈÕÆÚ  
 | 
      
 | 
    GameWorld.Log("¼ÓÔØ±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢: %s, weekDay=%s,openServerDay=%s" % (curDateStr, weekDay, openServerDay))  
 | 
      
 | 
    ipyDataMgr = IpyGameDataPY.IPY_Data()  
 | 
    dailyActionCount = ipyDataMgr.GetDailyActionCount()  
 | 
    for i in xrange(dailyActionCount):  
 | 
        dailyIpyData = ipyDataMgr.GetDailyActionByIndex(i)  
 | 
        dailyID = dailyIpyData.GetDailyID()  
 | 
        openServerDayLimit = dailyIpyData.GetOpenServerDay()  
 | 
          
 | 
        if openServerDay < openServerDayLimit:  
 | 
            GameWorld.Log("    ²»ÊÇÈÕ³£»î¶¯¿ªÆôÌìÊý: dailyID=%s,openServerDayLimit=%s" % (dailyID, openServerDayLimit))  
 | 
            continue  
 | 
          
 | 
        openTimeDict = eval(dailyIpyData.GetOpenTime())  
 | 
        # Ã»ÓÐʱ¼ä¿ØÖƵ쬴ú±íÓÀ¾Ã¿ª·Å  
 | 
        if not openTimeDict:  
 | 
            todayActionInfo.append([dailyID])  
 | 
            GameWorld.Log("    Ôö¼Ó±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢: dailyID=%s" % dailyID)  
 | 
            continue  
 | 
          
 | 
        #Èç¹ûÐÇÆÚkeyÖдæÔÚ "0" ´ú±íÿÈÕ¶¼¿ªÆô  
 | 
        if "0" not in openTimeDict and weekDay not in openTimeDict:  
 | 
            GameWorld.Log("    ²»ÊÇÈÕ³£»î¶¯¿ªÆôÐÇÆÚ: dailyID=%s,openWeekLimit=%s" % (dailyID, openTimeDict.keys()))  
 | 
            continue  
 | 
          
 | 
        notifyInfoDict = dailyIpyData.GetNotifyInfo()  
 | 
          
 | 
        openList = [] # [(ʱ,·Ö), ...]  
 | 
        overList = [] # [(ʱ,·Ö), ...]  
 | 
        goonStateDict = {} # {״̬:[(aDateTime, bDateTime)], ...}  
 | 
        notifyDict = {} # {(ʱ,·Ö):[notifyKey, [²ÎÊý]], ...}  
 | 
        OpenState = 1 # ¶¨Ò忪Æô״̬Ϊ1  
 | 
          
 | 
        openTimeList = openTimeDict["0"] if "0" in openTimeDict else openTimeDict[weekDay]  
 | 
        for hour, minute in openTimeList:    
 | 
            openTimeStr = "%s %02d:%02d:%02d" % (curDateStr, hour, minute, 0)  
 | 
              
 | 
            # ¾«È·¿ªÆôʱ¼ä  
 | 
            openDateTime = datetime.datetime.strptime(openTimeStr, ChConfig.TYPE_Time_Format)  
 | 
            openList.append((openDateTime.hour, openDateTime.minute))  
 | 
              
 | 
            # ¾«È·¹Ø±Õʱ¼ä  
 | 
            overDateTime = openDateTime + datetime.timedelta(minutes=dailyIpyData.GetDuration())  
 | 
            overList.append((overDateTime.hour, overDateTime.minute))  
 | 
              
 | 
            # goon ¿ªÆô״̬  
 | 
            openStateTimeList = goonStateDict.get(OpenState, [])  
 | 
            openStateTimeList.append((openDateTime, overDateTime))  
 | 
            goonStateDict[OpenState] = openStateTimeList  
 | 
              
 | 
            # goon ÆäËû״̬£¬´ýÀ©Õ¹  
 | 
            # ...  
 | 
              
 | 
            # ¹ã²¥  
 | 
            for notifyMinute, notifyInfo in notifyInfoDict.items():  
 | 
                notifyDateTime = openDateTime + datetime.timedelta(minutes=notifyMinute)  
 | 
                notifyDict[(notifyDateTime.hour, notifyDateTime.minute)] = notifyInfo  
 | 
                  
 | 
        todayActionInfo.append([dailyID, openList, overList, goonStateDict, notifyDict])  
 | 
        GameWorld.Log("    Ôö¼Ó±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢: dailyID=%s,openList=%s,overList=%s,goonStateDict=%s,notifyDict=%s"   
 | 
                      % (dailyID, openList, overList, goonStateDict, notifyDict))  
 | 
          
 | 
    TodayDailyActionInfo = IpyGameDataPY.SetConfigEx(key, [openServerDay, todayActionInfo])  
 | 
    GameWorld.Log("±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢¼ÓÔØÍê±Ï!")  
 | 
    return TodayDailyActionInfo[1]  
 | 
  
 | 
def Dispose_DailyActionState():  
 | 
    # ÈÕ³£»î¶¯×´Ì¬±ä¸ü¼ì²é´¦Àí  
 | 
      
 | 
    todayDailyActionInfo = __GetTodayDailyActionInfo()  
 | 
    if not todayDailyActionInfo:  
 | 
        return  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    dayTime = GameWorld.GetServerTime()  
 | 
    curHourMinute = (dayTime.hour, dayTime.minute)  
 | 
      
 | 
    for actionInfo in todayDailyActionInfo:  
 | 
        dailyActionID = actionInfo[0]  
 | 
        state = 0 # Ä¬ÈÏ¹Ø±Õ  
 | 
          
 | 
        # ³¤¶ÈΪ1µÄ´ú±í³£¿ªµÄ»î¶¯  
 | 
        if len(actionInfo) == 1:  
 | 
            state = 1  
 | 
        else:  
 | 
            #openList = [] # [(ʱ,·Ö), ...]  
 | 
            #overList = [] # [(ʱ,·Ö), ...]  
 | 
            #goonStateDict = {} # {״̬:[(aDateTime, bDateTime)], ...}  
 | 
            #notifyDict = {} # {(ʱ,·Ö):[notifyKey, [²ÎÊý]], ...}  
 | 
            openList, overList, goonStateDict, notifyDict = actionInfo[1:]  
 | 
              
 | 
            # ¾«È·Æ¥Å俪Æô  
 | 
            if curHourMinute in openList:  
 | 
                state = 1  
 | 
            # ¾«È·Æ¥Å乨±Õ  
 | 
            elif curHourMinute in overList:  
 | 
                state = 0  
 | 
            # goon ×´Ì¬  
 | 
            else:  
 | 
                for goonState, openStateTimeList in goonStateDict.items():  
 | 
                    for dateTimeInfo in openStateTimeList:  
 | 
                        if dateTimeInfo[0] < dayTime < dateTimeInfo[1]:  
 | 
                            state = goonState  
 | 
                            break  
 | 
                          
 | 
            # È«·þ¹ã²¥ÌáʾÐÅÏ¢  
 | 
            if curHourMinute in notifyDict:  
 | 
                notifyKey, paramList = notifyDict[curHourMinute]  
 | 
                PlayerControl.WorldNotify(0, notifyKey, paramList)  
 | 
                  
 | 
        dictName = ShareDefine.Def_Notify_WorldKey_DailyActionState % dailyActionID  
 | 
        if gameWorld.GetDictByKey(dictName) == state:  
 | 
            #ÒѾÊÇÕâ¸ö״̬ÁË  
 | 
            continue  
 | 
          
 | 
        #֪ͨMapserver,ÉèÖÃ×Öµä  
 | 
        GameWorld.SendMapServerMsgEx(dictName, state)  
 | 
        #¸üÐÂ×ÖµäÖµ  
 | 
        gameWorld.SetDict(dictName, state)  
 | 
        GameWorld.Log("ÈÕ³£»î¶¯×´Ì¬±ä¸ü: dailyActionID=%s,state=%s,dictName=%s" % (dailyActionID, state, dictName))  
 | 
        __DoLogic_GameServer_ActionState(dictName, state)  
 | 
          
 | 
    return  
 | 
  
 | 
def SendMapServerDailyActionState():  
 | 
    # µØÍ¼Æô¶¯³É¹¦Ê±Í¨Öª±¾ÈÕ½øÐÐÖеÄÈÕ³£»î¶¯×´Ì¬  
 | 
      
 | 
    todayDailyActionInfo = __GetTodayDailyActionInfo()  
 | 
    if not todayDailyActionInfo:  
 | 
        return  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    for actionInfo in todayDailyActionInfo:  
 | 
        dailyActionID = actionInfo[0]  
 | 
        dictName = ShareDefine.Def_Notify_WorldKey_DailyActionState % dailyActionID   
 | 
        state = gameWorld.GetDictByKey(dictName)  
 | 
        if state:  
 | 
            GameWorld.SendMapServerMsgEx(dictName, state)  
 | 
    return  
 | 
  
 | 
## -------------------------------------------------------------------------------------------------  
 | 
def __GetFBStateEndTimeNotResetIDList():  
 | 
    key = "FBStateEndTimeNotReset" # ½áÊøÊ±¼ä״̬²»ÖØÖÃΪ0µÄÊý¾ÝID  
 | 
    FBStateEndTimeNotResetIDList = IpyGameDataPY.GetConfigEx(key)  
 | 
    if FBStateEndTimeNotResetIDList == None:  
 | 
        mapStateTimeDict = {}  
 | 
        ipyDataMgr = IpyGameDataPY.IPY_Data()  
 | 
        for i in xrange(ipyDataMgr.GetFBStateTimeCount()):  
 | 
            fbStateTimeIpyData = ipyDataMgr.GetFBStateTimeByIndex(i)  
 | 
            dataID = fbStateTimeIpyData.GetID()  
 | 
            dataMapID = fbStateTimeIpyData.GetDataMapID()  
 | 
            startWeekDay, startHour, startMinute = fbStateTimeIpyData.GetStartWeekday(), fbStateTimeIpyData.GetStartHour(), fbStateTimeIpyData.GetStartMinute()  
 | 
            endWeekDay, endHour, endMinute = fbStateTimeIpyData.GetEndWeekday(), fbStateTimeIpyData.GetEndHour(), fbStateTimeIpyData.GetEndMinute()  
 | 
            startTimeList, endTimeDict = mapStateTimeDict.get(dataMapID, [[], {}])  
 | 
            startTimeList.append([startWeekDay, startHour, startMinute])  
 | 
            endTimeDict[dataID] = [endWeekDay, endHour, endMinute]  
 | 
            mapStateTimeDict[dataMapID] = [startTimeList, endTimeDict]  
 | 
              
 | 
        FBStateEndTimeNotResetIDList = []  
 | 
        for dataMapID, timeInfo in mapStateTimeDict.items():  
 | 
            startTimeList, endTimeDict = timeInfo  
 | 
            for dataID, endTime in endTimeDict.items():  
 | 
                # ½áÊøÊ±¼äÊôÓÚijһÌõµÄ¿ªÆôʱ¼ä£¬Ôò²»ÖØÖ㬾ßÌå״̬ÓÉÁíÒ»Ìõ¾ö¶¨  
 | 
                if endTime in startTimeList:  
 | 
                    FBStateEndTimeNotResetIDList.append(dataID)  
 | 
        FBStateEndTimeNotResetIDList = IpyGameDataPY.SetConfigEx(key, FBStateEndTimeNotResetIDList)  
 | 
        GameWorld.Log("¼ÓÔØ¸±±¾×´Ì¬½áÊøÊ±¼ä²»ÐèÒªÖØÖÃ״ֵ̬µÄÊý¾ÝIDÁбí: %s" % FBStateEndTimeNotResetIDList)  
 | 
    return FBStateEndTimeNotResetIDList  
 | 
  
 | 
def Dispose_FBStateTime():  
 | 
    ## ¸±±¾×´Ì¬Ê±¼ä±í״̬´¦Àí, Ö§³Ö goon×÷Ó㬿ª¹Ø·þ״̬²»ÊÜÓ°Ï죬·þÎñÆ÷ÖØÐÂÆô¶¯»á×Ô¶¯±ä¸üΪËùÓÐʱ¼ä¶ÎµÄ״ֵ̬  
 | 
      
 | 
    FBStateEndTimeNotResetIDList = __GetFBStateEndTimeNotResetIDList()  
 | 
    openServerWeek = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerWeek) + 1  
 | 
    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1  
 | 
    curDateTime = GameWorld.GetServerTime()  
 | 
    curWeekDay, curHour, curMinute = curDateTime.weekday() + 1, curDateTime.hour, curDateTime.minute  
 | 
      
 | 
    curTimeWHM = curWeekDay * 10000 + curHour * 100 + curMinute  
 | 
    GameWorld.DebugLog("¸±±¾×´Ì¬Ê±¼ä±í״̬´¦Àí...openServerWeek=%s,openServerDay=%s,curWeekDay=%s,curHour=%s,curMinute=%s,FBStateEndTimeNotResetIDList=%s"   
 | 
                       % (openServerWeek, openServerDay, curWeekDay, curHour, curMinute, FBStateEndTimeNotResetIDList))  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    ipyDataMgr = IpyGameDataPY.IPY_Data()  
 | 
    for i in xrange(ipyDataMgr.GetFBStateTimeCount()):  
 | 
        fbStateTimeIpyData = ipyDataMgr.GetFBStateTimeByIndex(i)  
 | 
        dataID = fbStateTimeIpyData.GetID()  
 | 
        dataMapID = fbStateTimeIpyData.GetDataMapID()  
 | 
        openServerWeekLimit = fbStateTimeIpyData.GetOpenServerWeek()  
 | 
        openServerDayLimit = fbStateTimeIpyData.GetOpenServerDay()  
 | 
          
 | 
        if openServerWeek <= openServerWeekLimit:  
 | 
            #GameWorld.DebugLog("    ²»ÊǸ±±¾×´Ì¬¿ªÆôÖÜ: i=%s,dataMapID=%s,openServerWeekLimit=%s" % (i, dataMapID, openServerWeekLimit))  
 | 
            continue  
 | 
          
 | 
        if openServerDay <= openServerDayLimit:  
 | 
            #GameWorld.DebugLog("    ²»ÊǸ±±¾×´Ì¬¿ªÆôÌìÊý: i=%s,dataMapID=%s,openServerDayLimit=%s" % (i, dataMapID, openServerDayLimit))  
 | 
            continue  
 | 
          
 | 
        startWeekDay, startHour, startMinute = fbStateTimeIpyData.GetStartWeekday(), fbStateTimeIpyData.GetStartHour(), fbStateTimeIpyData.GetStartMinute()  
 | 
        endWeekDay, endHour, endMinute = fbStateTimeIpyData.GetEndWeekday(), fbStateTimeIpyData.GetEndHour(), fbStateTimeIpyData.GetEndMinute()  
 | 
        # ÐÇÆÚÅäÖÃ0´ú±íÿÌì  
 | 
        if startWeekDay == 0:  
 | 
            startWeekDay = curWeekDay  
 | 
        if endWeekDay == 0:  
 | 
            endWeekDay = curWeekDay  
 | 
        startTimeWHM = startWeekDay * 10000 + startHour * 100 + startMinute # °üº¬¸ÃÖµ  
 | 
        endTimeWHM = endWeekDay * 10000 + endHour * 100 + endMinute # ²»º¬¸ÃÖµ  
 | 
        #GameWorld.DebugLog("    ID=%s,dataMapID=%s,curTimeWHM=%s,startTimeWHM=%s,endTimeWHM=%s" % (dataID, dataMapID, curTimeWHM, startTimeWHM, endTimeWHM))  
 | 
          
 | 
        # È«·þ¹ã²¥key·ÖÖÓ²îÖµ¶Ô±Èʱ¼äΪ¿ªÊ¼Ê±¼ä, Ö§³ÖÕý¸ºÊ±¼ä²î  
 | 
        notifyInfoDict = fbStateTimeIpyData.GetNotifyInfoDict()  
 | 
        if notifyInfoDict:  
 | 
            startDateTime = curDateTime + datetime.timedelta(days=(startWeekDay - curWeekDay))  
 | 
            startDateTime = datetime.datetime(startDateTime.year, startDateTime.month, startDateTime.day, startHour, startMinute, 0)  
 | 
            diffDateTime = curDateTime - startDateTime  
 | 
            diffMinute = (diffDateTime.days * 24 * 3600 + diffDateTime.seconds) / 60 # µ±Ç°Ê±¼äÓ뿪ʼʱ¼äÏà²î·ÖÖÓÊý  
 | 
            #GameWorld.DebugLog("        ¹ã²¥ÅжÏ: curDateTime=%s,startDateTime=%s,diffDays=%s,diffSeconds=%s,diffMinute=%s"   
 | 
            #                   % (curDateTime, startDateTime, diffDateTime.days, diffDateTime.seconds, diffMinute))  
 | 
            if diffMinute in notifyInfoDict:  
 | 
                notifyKey, paramList = notifyInfoDict[diffMinute]  
 | 
                PlayerControl.WorldNotify(0, notifyKey, paramList)  
 | 
                #GameWorld.DebugLog("        Ö´Ðй㲥: notifyKey=%s, paramList=%s" % (notifyKey, paramList))  
 | 
                  
 | 
        isUpdate, isReset = False, False  
 | 
        # Ö§³ÖÖ»ÅäÖÿªÆôʱ¼äʱ£¬×ö¾«È·Æ¥Åä  
 | 
        if curTimeWHM == startTimeWHM:  
 | 
            isUpdate = True  
 | 
            #GameWorld.DebugLog("        µ±Ç°ÊÇ¿ªÊ¼Ê±¼ä!")  
 | 
        # ÊǽáÊøÊ±¼ä  
 | 
        elif curTimeWHM == endTimeWHM:  
 | 
            isReset = dataID not in FBStateEndTimeNotResetIDList  
 | 
            #GameWorld.DebugLog("        µ±Ç°ÊǽáÊøÊ±¼ä! isReset=%s,FBStateEndTimeNotResetIDList=%s" % (isReset, FBStateEndTimeNotResetIDList))  
 | 
        # ½áÊøÊ±¼äÊÇÏÂÖÜ  
 | 
        elif endTimeWHM and endTimeWHM <= startTimeWHM:  
 | 
            isUpdate = (curTimeWHM > startTimeWHM or curTimeWHM < endTimeWHM)  
 | 
            #GameWorld.DebugLog("        ½áÊøÊ±¼äÊÇÏÂÖÜ! isUpdate=%s" % isUpdate)  
 | 
        else:  
 | 
            isUpdate = (startTimeWHM < curTimeWHM < endTimeWHM)  
 | 
            #GameWorld.DebugLog("        ³£¹æÅжÏ: isUpdate=%s" % isUpdate)  
 | 
              
 | 
        if isReset:  
 | 
            updCanEnter = 0  
 | 
            updStateValue = 0  
 | 
        elif isUpdate:  
 | 
            updCanEnter = fbStateTimeIpyData.GetCanEnter()  
 | 
            updStateValue = fbStateTimeIpyData.GetStateValue()  
 | 
        else:  
 | 
            #GameWorld.DebugLog("        µ±Ç°Ê±¼ä¸±±¾×´Ì¬²»±ä£¡")  
 | 
            continue  
 | 
          
 | 
        canEnterKey = ShareDefine.Def_Notify_WorldKey_FBCanEnter % dataMapID  
 | 
        if gameWorld.GetDictByKey(canEnterKey) != updCanEnter:  
 | 
            GameWorld.SendMapServerMsgEx(canEnterKey, updCanEnter) #֪ͨMapserver,ÉèÖÃ×Öµä  
 | 
            gameWorld.SetDict(canEnterKey, updCanEnter) #¸üÐÂ×ÖµäÖµ  
 | 
            if updCanEnter:  
 | 
                SaveFBOpenRecord(dataMapID)  
 | 
            GameWorld.Log("¸±±¾ÊÇ·ñ¿É½øÈë±ä¸ü: dataMapID=%s,updCanEnter=%s,canEnterKey=%s" % (dataMapID, updCanEnter, canEnterKey))  
 | 
        #else:  
 | 
        #    GameWorld.DebugLog("        ¸±±¾¿É·ñ½øÈëÒѾÊǸÃÖµ: dataMapID=%s,updCanEnter=%s,canEnterKey=%s" % (dataMapID, updCanEnter, canEnterKey))              
 | 
              
 | 
        fbFuncStateKey = ShareDefine.Def_Notify_WorldKey_FBFuncState % dataMapID  
 | 
        if gameWorld.GetDictByKey(fbFuncStateKey) != updStateValue:  
 | 
            GameWorld.SendMapServerMsgEx(fbFuncStateKey, updStateValue) #֪ͨMapserver,ÉèÖÃ×Öµä  
 | 
            gameWorld.SetDict(fbFuncStateKey, updStateValue) #¸üÐÂ×ÖµäÖµ  
 | 
            GameWorld.Log("¸±±¾×´Ì¬±ä¸ü: dataMapID=%s,updStateValue=%s,fbFuncStateKey=%s" % (dataMapID, updStateValue, fbFuncStateKey))  
 | 
            __DoLogic_GameServer_ActionState(fbFuncStateKey, updStateValue)  
 | 
        #else:  
 | 
        #    GameWorld.DebugLog("        ¸±±¾×´Ì¬ÒѾÊǸÃÖµ: dataMapID=%s,updStateValue=%s,fbFuncStateKey=%s" % (dataMapID, updStateValue, fbFuncStateKey))  
 | 
              
 | 
              
 | 
    return  
 | 
  
 | 
def SaveFBOpenRecord(mapID):  
 | 
    #¼Ç¼¸±±¾¿ªÆôʱ¼ä  
 | 
    #{mapid:['0315','0316'],..}  
 | 
    curTime = GameWorld.GetServerTime()  
 | 
    curDayStr = '%02d%02d' % (curTime.month, curTime.day)  
 | 
      
 | 
    fbOpenRecord = {}  
 | 
    recType = ShareDefine.Def_UniversalGameRecType_LimitFBOpenRecord  
 | 
    universalRecMgr = GameWorld.GetUniversalRecMgr()    
 | 
    recTypeListData = universalRecMgr.GetTypeList(recType)  
 | 
    findRecData = None  
 | 
    for index in range(recTypeListData.Count()):  
 | 
        universalRecData = recTypeListData.At(index)  
 | 
        recMapID = universalRecData.GetValue1()  
 | 
        if recMapID == mapID:  
 | 
            findRecData = universalRecData  
 | 
        fbOpenRecord[recMapID] = eval(universalRecData.GetStrValue1())  
 | 
          
 | 
    if not findRecData:  
 | 
        findRecData = recTypeListData.AddRec()  
 | 
        findRecData.SetValue1(mapID)  
 | 
        findRecData.SetStrValue1(str([curDayStr]))  
 | 
        fbOpenRecord[mapID] = [curDayStr]  
 | 
    else:  
 | 
        recordList = eval(findRecData.GetStrValue1())  
 | 
        if curDayStr not in recordList:  
 | 
            recordList.append(curDayStr)  
 | 
            if len(recordList) > 3: #Ö»´æ×î½ü3´Î  
 | 
                del recordList[0]  
 | 
            findRecData.SetStrValue1(str(recordList))  
 | 
            fbOpenRecord[mapID] = recordList  
 | 
        else:  
 | 
            return  
 | 
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FBOpenRecord, fbOpenRecord)  
 | 
    return  
 | 
  
 | 
def GetFBOpenRecord():  
 | 
    #»ñÈ¡¸±±¾¿ªÆôʱ¼ä¼Ç¼  
 | 
    fbOpenRecord = {}  
 | 
    recType = ShareDefine.Def_UniversalGameRecType_LimitFBOpenRecord  
 | 
    universalRecMgr = GameWorld.GetUniversalRecMgr()    
 | 
    recTypeListData = universalRecMgr.GetTypeList(recType)  
 | 
    for index in range(recTypeListData.Count()):  
 | 
        universalRecData = recTypeListData.At(index)  
 | 
        recMapID = universalRecData.GetValue1()  
 | 
        recordList = eval(universalRecData.GetStrValue1())  
 | 
        fbOpenRecord[recMapID] = recordList  
 | 
    return fbOpenRecord  
 | 
  
 | 
def SendMapServerFBFuncState():  
 | 
    # µØÍ¼Æô¶¯³É¹¦Ê±Í¨Öª±¾ÈÕ½øÐÐÖеĸ±±¾×´Ì¬  
 | 
      
 | 
    fbEnterTimeLimitMapIDList = []  
 | 
      
 | 
    sendMapIDList = []  
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    ipyDataMgr = IpyGameDataPY.IPY_Data()  
 | 
    for i in xrange(ipyDataMgr.GetFBStateTimeCount()):  
 | 
        fbStateTimeIpyData = ipyDataMgr.GetFBStateTimeByIndex(i)  
 | 
        dataMapID = fbStateTimeIpyData.GetDataMapID()  
 | 
          
 | 
        if fbStateTimeIpyData.GetCanEnter() and dataMapID not in fbEnterTimeLimitMapIDList:  
 | 
            fbEnterTimeLimitMapIDList.append(dataMapID)  
 | 
              
 | 
        if dataMapID not in sendMapIDList:  
 | 
            canEnterKey = ShareDefine.Def_Notify_WorldKey_FBCanEnter % dataMapID   
 | 
            canEnter = gameWorld.GetDictByKey(canEnterKey)  
 | 
            if canEnter:  
 | 
                GameWorld.SendMapServerMsgEx(canEnterKey, canEnter)  
 | 
                  
 | 
            fbFuncStateKey = ShareDefine.Def_Notify_WorldKey_FBFuncState % dataMapID   
 | 
            fbFuncState = gameWorld.GetDictByKey(fbFuncStateKey)  
 | 
            if fbFuncState:  
 | 
                GameWorld.SendMapServerMsgEx(fbFuncStateKey, fbFuncState)  
 | 
                  
 | 
            sendMapIDList.append(dataMapID)  
 | 
          
 | 
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FBEnterTimeLimiitMapID, fbEnterTimeLimitMapIDList)  
 | 
    fbOpenRecord = GetFBOpenRecord()  
 | 
    GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FBOpenRecord, fbOpenRecord)  
 | 
    return  
 | 
  
 | 
## ´¦ÀíÖØ¿ª·þÎñÆ÷ºó, »î¶¯¼ÌÐø¿ªÆôÂß¼¸ù¾ÝÌìÊý  
 | 
#  @param tick µ±Ç°Ê±¼ä   
 | 
#  @return None  
 | 
def Dispose_Action_GoOn_ByDay(tick):  
 | 
    #Òѹ̶¨ÔÚÿÕû·ÖÖÓ´¥·¢£¬¹ÊÔݲ»ÐèҪʱ¼ä¼ä¸ô¿ØÖÆ  
 | 
    #if not GameWorld.SetWorldDictKey(ChConfig.TYPE_ActionOpenAndCloseByDayCountGoOn, tick):  
 | 
    #    #¼ä¸ôδµ½  
 | 
    #    return  
 | 
      
 | 
    if GameWorld.IsMergeServer():  
 | 
        return  
 | 
      
 | 
    Dispose_ActionGoOnByDayKey()  
 | 
    return  
 | 
  
 | 
  
 | 
## É趨ÉϴοªÆô»î¶¯Ê±¼ä¾àÀëÏÖÔÚÌìÊýʼþ  
 | 
#  @param None:   
 | 
#  @return: None  
 | 
def DoLogic_ServerLastOpenActionDay():  
 | 
      
 | 
    #ÊÇ¿ç·þ·þÎñÆ÷  
 | 
    if GameWorld.IsMergeServer():  
 | 
        if not PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_MergeServerOpenActionDay):  
 | 
            return  
 | 
          
 | 
        PlayerDBGSEvent.SetDBGSTrig_ServerTime(PlayerDBGSEvent.Def_MergeServerOpenActionDay)  
 | 
          
 | 
        #֪ͨ×Ó·þÎñÆ÷ÌìÊý  
 | 
        SendBroadcastMergeOpenActionDay()  
 | 
        return  
 | 
      
 | 
    DoLogic_ActionByDayKeyOnDay()  
 | 
      
 | 
    #ÉϴοªÆô»î¶¯Ê±¼ä¾àÀëÏÖÔÚÌìÊý  
 | 
    lastOpenActionDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerLastOpenActionDay)  
 | 
    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay)  
 | 
    initDayList = ReadChConfig.GetEvalChConfig('ActionControlByDayInitOpenServerDay')  
 | 
    if openServerDay < initDayList[0]:  
 | 
        #¿ª·þʱ¼ä䳬¹ý30Ìì  
 | 
        return  
 | 
      
 | 
    #ÐÂÒ»Âֻ´ÓÍ·¿ªÊ¼  
 | 
    if lastOpenActionDay >= initDayList[1] or openServerDay == initDayList[2]:  
 | 
        NewRingOpenActionDay()  
 | 
        return  
 | 
  
 | 
    PlayerDBGSEvent.SetDBGSTrig_ServerTime(PlayerDBGSEvent.Def_ServerLastOpenActionDay)  
 | 
    return  
 | 
              
 | 
  
 | 
## ÐÂÒ»Âֻ¿ªÊ¼  
 | 
#  @param None:   
 | 
#  @return:   
 | 
def NewRingOpenActionDay():  
 | 
      
 | 
    #ÉèÖÃ×ÖµäÖµ´Ó1¿ªÊ¼, ¸úSetDBGSTrig_ServerTime½Ó¿Úͬ²½  
 | 
    PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerLastOpenActionDay, 1)  
 | 
      
 | 
    # »î¶¯ÌìÊýÖØÉè  
 | 
    OpenActionDay_Reset()        
 | 
    return  
 | 
        
 | 
#------------------------------------------------------------------------------  
 | 
## »î¶¯ÌìÊýÖØÉè  
 | 
#  @param None  
 | 
#  @return None  
 | 
def OpenActionDay_Reset():      
 | 
    # ÉèÖùúÍõÕ½¿ªÊ¼  
 | 
    #PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_MergeWarStart, 1)  
 | 
    return  
 | 
  
 | 
### ¼ì²ékeyÊÇ·ñ´¦Àí  
 | 
#def __CheckIsProcessDictName(dictName):  
 | 
#      
 | 
#    # ·Ç¿ç·þ·þÎñÆ÷²»´¦ÀíijЩkey  
 | 
#    if dictName in [ShareDefine.Def_Notify_WorldKey_Merge_King] and not GameWorld.IsMergeServer():  
 | 
#        return False  
 | 
#      
 | 
#    return True  
 | 
  
 | 
## µ±Ç°Ê±¼äÓëÖ¸¶¨Ê±¼ä±È½Ï  
 | 
#  @param curTime µ±Ç°·þÎñÆ÷ʱ¼ä   
 | 
#  @param timeInfo Ö¸¶¨Ê±¼ä [[3,4(ÐÇÆÚ¼¸)], Ä꣬Ô£¬ÈÕ£¬Ê±£¬·Ö]   
 | 
#  @return ´óÓÚ·µ»Ø1£¬Ð¡ÓÚ·µ»Ø-1£¬Ïàͬ·µ»Ø0  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.Òì³£ºÍ²»³É±È½ÏÌõ¼þ(ÐÇÆÚ¼¸²»¶Ô)·µ»ØNone  
 | 
def CompareActTime(curTime, timeInfo):  
 | 
    for index, callObj in enumerate(ATTR_CALL_TIME):  
 | 
        #È¥³ý²»±È½ÏµÄÔªËØ  
 | 
        if timeInfo[index] == '-':  
 | 
            continue  
 | 
          
 | 
        if hasattr(curTime, callObj) != True:  
 | 
            GameWorld.Log('###ϵͳʱ¼ä»ñµÃÒì³££¬ÎÞ´ËÊôÐÔ')  
 | 
            return  
 | 
          
 | 
        curCallObj = getattr(curTime, callObj)  
 | 
  
 | 
        #ÓÅÏÈÐÇÆÚ¼¸ÌØÊâÑéÖ¤  
 | 
        if type(curCallObj) != IntType:  
 | 
            wday = curCallObj() + 1  
 | 
            if wday not in timeInfo[index]:  
 | 
                return  
 | 
              
 | 
            continue  
 | 
          
 | 
        if curCallObj == timeInfo[index]:  
 | 
            continue  
 | 
          
 | 
        #µ±Ç°Ê±¼ä´óÓÚÖ¸¶¨Ê±¼ä  
 | 
        if curCallObj > timeInfo[index]:  
 | 
            return ChConfig.Def_Cmp_Greater  
 | 
        #СÓÚ  
 | 
        return ChConfig.Def_Cmp_Lower  
 | 
    #µÈÓÚ  
 | 
    return ChConfig.Def_Cmp_Equ  
 | 
  
 | 
## ÑéÖ¤»î¶¯ÊÇ·ñÔڻʱ¼ä¶Î£¨³¤Ê±¼ä¶Î£©  
 | 
#  @param curTime µ±Ç°Ê±¼ä  
 | 
#  @param actSect Ê±¼ä¶Î  
 | 
#  @return ²¼¶ûÖµ  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def IsAtActTime(curTime, actSect):  
 | 
    #ÎÞʱ¼ä¶ÎÏÞÖÆ  
 | 
    if not actSect:  
 | 
        return True  
 | 
      
 | 
    #Ôڻʱ¼ä¶Î  
 | 
    if GameWorld.GetDateTimeByStr(actSect[0]) \  
 | 
                <= curTime <= GameWorld.GetDateTimeByStr(actSect[1]):  
 | 
        return True  
 | 
      
 | 
    return False  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
##´¦ÀíGameServer»î¶¯×´Ì¬  
 | 
# @param dictName ×ÖµäÃû  
 | 
# @param isOpen ÊÇ·ñ¿ªÆô  
 | 
# @return ·µ»ØÖµÎÞÒâÒå  
 | 
# @remarks   
 | 
def __DoLogic_GameServer_ActionState(dictName, isOpen):  
 | 
    #===============================================================================================  
 | 
    # #ÁìµØÕù¶áÕ½  
 | 
    # if dictName == ShareDefine.Def_Notify_WorldKey_ManorWar:  
 | 
    #    PlayerManorWar.ManorWar_ChangeState(isOpen)  
 | 
    # #¿ç·þboss  
 | 
    # elif dictName == ShareDefine.Def_Notify_WorldKey_MergeBoss:  
 | 
    #    GameWorldMergeBoss.MergeBoss_ChangeState(isOpen)  
 | 
    # #¿ç·þPK  
 | 
    # elif dictName == ShareDefine.Def_Notify_WorldKey_Merge_PK:  
 | 
    #    GameWorldMergePK.OnMergePKMatchStateChange(isOpen)  
 | 
    # #¿ç·þÍõÕßÕù°Ô  
 | 
    # elif dictName == ShareDefine.Def_Notify_WorldKey_Merge_King:  
 | 
    #    GameWorldMergeKing.OnMergeKingStateChange(isOpen)  
 | 
    # #´ðÌâ»î¶¯  
 | 
    # elif dictName == ShareDefine.Def_Notify_WorldKey_Game_EXAM:  
 | 
    #    PlayerExam.Exam_ChangeState(isOpen)  
 | 
    # #ÌØ»Ý»î¶¯  
 | 
    # elif dictName in ShareDefine.TeHuiTypeKeyDict.values():  
 | 
    #    GameWorldActionTeHui.OnTeHuiActionChange(dictName, isOpen)  
 | 
    # #É̵ê״̬±ä¸ü  
 | 
    # elif dictName.startswith(ShareDefine.Def_Notify_WorldKey_ShopState[:-2]):  
 | 
    #    GameWorldShopItem.OnShopStateChange(dictName, isOpen)  
 | 
    #===============================================================================================  
 | 
          
 | 
    #ÏÉÃËÑç»á   
 | 
    if dictName == ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty:  
 | 
        PlayerFamilyParty.FamilyPartyStateChange(isOpen)  
 | 
    #ÏÉÃËÁªÈü  
 | 
    elif dictName == ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyWar:  
 | 
        GameWorldFamilyWar.OnFamilyWarStateChange(isOpen)  
 | 
    #ÏÉħ֮Õù  
 | 
    elif dictName == ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_XMZZ:  
 | 
        PlayerXMZZ.OnXMZZStateChange(dictName, isOpen)  
 | 
    #ÊØÎÀÈË»Ê  
 | 
    elif dictName == ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyInvade:  
 | 
        PlayerFamilySWRH.OnSWRHStateChange(dictName, isOpen)  
 | 
    return  
 | 
  
 | 
#------------------------------------------------------------------------------   
 | 
## Í¨Öª×Ó·þÎñÆ÷ÌìÊý  
 | 
#  @param param: None  
 | 
#  @return: None  
 | 
def SendBroadcastMergeOpenActionDay():  
 | 
    mergeServerOpenActionDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_MergeServerOpenActionDay)  
 | 
    MergeBroadcast.SendBroadcastMerge(ChConfig.Def_MergeServerOpenActionDay, 0, {"Day":mergeServerOpenActionDay})  
 | 
    return  
 | 
  
 | 
#-------------------------------------------------------------------------------  
 | 
  
 | 
## ¸ù¾Ý»î¶¯¿ªÆôµÄ»î¶¯Ê¼þOnDay  
 | 
#  @param None:   
 | 
#  @return: None  
 | 
def DoLogic_ActionByDayKeyOnDay():  
 | 
    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay)  
 | 
    isMixServer = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_IsMixServer)  
 | 
    mixServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_MixServerDay)  
 | 
    repeatDayInfo = ReadChConfig.GetEvalChConfig('ActionControlByDayKeyRepeat')  
 | 
    startRepeatOpenDay, startRepeatMixDay, repeatList = repeatDayInfo  
 | 
    # ²»ÊÇÑ»·½×¶Î   
 | 
    if openServerDay < startRepeatOpenDay or (isMixServer and mixServerDay < startRepeatMixDay):  
 | 
        GameWorld.Log("ûÓÐÕýʽ½øÈëÖÜÆÚÑ»·£¬²»´¦Àí!")  
 | 
        return  
 | 
      
 | 
    Def_RepeatOrderKey = PlayerDBGSEvent.Def_TeHuiRepeatOrderKey  
 | 
    Def_RepeatNumKey = PlayerDBGSEvent.Def_TeHuiRepeatNumKey  
 | 
      
 | 
    # Ç¿ÖƸüÐÂÒ»´ÎÊÀ½çµÈ¼¶  
 | 
    GameWorldAverageLv.OpenWorldAverageLv()  
 | 
      
 | 
    repeatOrder = PlayerDBGSEvent.GetDBGSTrig_ByKey(Def_RepeatOrderKey)  
 | 
    repeatOrder = "" if not repeatOrder else str(repeatOrder)  
 | 
    preRepeatNum = PlayerDBGSEvent.GetDBGSTrig_ByKey(Def_RepeatNumKey)  
 | 
    preRepeatNum = "" if not preRepeatNum else str(preRepeatNum)  
 | 
    worldAverageLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)  
 | 
    GameWorld.Log("´¦ÀíÖÜÆÚÑ»·: openServerDay=%s,isMixServer=%s,mixServerDay=%s" % (openServerDay, isMixServer, mixServerDay))  
 | 
    GameWorld.Log("    startRepeatOpenDay=%s,startRepeatMixDay=%s,repeatOrder=%s,preRepeatNum=%s,worldAverageLV=%s"   
 | 
                  % (startRepeatOpenDay, startRepeatMixDay, repeatOrder, preRepeatNum, worldAverageLV))  
 | 
      
 | 
    # ¿ªÊ¼Ñ»·  
 | 
    if openServerDay == startRepeatOpenDay or (isMixServer and mixServerDay == startRepeatMixDay):  
 | 
        repeatOrder = ""  
 | 
        for i, repeatInfo in enumerate(repeatList, 1):  
 | 
            if i > 9:  
 | 
                break  
 | 
            needWorldAverageLV = repeatInfo[0]  
 | 
            if worldAverageLV < needWorldAverageLV:  
 | 
                continue  
 | 
            repeatOrder = "%s%s" % (repeatOrder, i)  
 | 
        PlayerDBGSEvent.SetDBGSTrig_ByKey(Def_RepeatOrderKey, GameWorld.ToIntDef(repeatOrder))  
 | 
        GameWorld.Log("    ¿ªÊ¼Ñ»·, Éú³ÉÑ»·±àºÅ˳Ðò: %s" % repeatOrder)  
 | 
          
 | 
    # »¹Ã»È«²¿¿ªÊ¼Ñ»·£¬ÔòÅжÏÊÇ·ñÓж¯Ì¬Ð²åÈëµÄÑ»·  
 | 
    elif len(repeatOrder) < len(repeatList):  
 | 
        GameWorld.Log("    »¹Ã»È«²¿¿ªÊ¼Ñ»·£¬ÅжÏÊÇ·ñÓж¯Ì¬Ð²åÈëµÄÑ»·..")  
 | 
        for i, repeatInfo in enumerate(repeatList, 1):  
 | 
            if i > 9:  
 | 
                break  
 | 
            if str(i) in repeatOrder: # ÒѾÔÚÑ»·ÀïµÄ²»´¦Àí  
 | 
                continue  
 | 
            needWorldAverageLV = repeatInfo[0]  
 | 
            if worldAverageLV < needWorldAverageLV:  
 | 
                continue  
 | 
              
 | 
            # ²åÈëÐÂÑ»·  
 | 
            if preRepeatNum in repeatOrder:  
 | 
                insertIndex = repeatOrder.index(preRepeatNum)  
 | 
                repeatOrder = repeatOrder[:insertIndex + 1] + str(i) + repeatOrder[insertIndex + 1:]  
 | 
            else:  
 | 
                repeatOrder = str(i)  
 | 
            PlayerDBGSEvent.SetDBGSTrig_ByKey(Def_RepeatOrderKey, GameWorld.ToIntDef(repeatOrder))  
 | 
            GameWorld.Log("        ±àºÅ%s, needWorldAverageLV=%s,²åÈëÑ»·,¸üÐÂÑ»·±àºÅ˳Ðò: %s" % (i, needWorldAverageLV, repeatOrder))  
 | 
            break  
 | 
              
 | 
    if not repeatOrder:  
 | 
        GameWorld.Log("    Ã»ÓпÉÑ»·µÄ»î¶¯!")  
 | 
        return  
 | 
      
 | 
    # ½øÈëÏÂÒ»ÌìÑ»·±àºÅ  
 | 
    if preRepeatNum and preRepeatNum in repeatOrder:  
 | 
        nextRepeatIndex = repeatOrder.index(preRepeatNum) + 1  
 | 
        nextRepeatIndex = 0 if nextRepeatIndex >= len(repeatOrder) else nextRepeatIndex  
 | 
    else:  
 | 
        nextRepeatIndex = 0  
 | 
    nextRepeatNum = GameWorld.ToIntDef(repeatOrder[nextRepeatIndex])  
 | 
    PlayerDBGSEvent.SetDBGSTrig_ByKey(Def_RepeatNumKey, nextRepeatNum)  
 | 
    if nextRepeatNum <= 0 or nextRepeatNum > len(repeatList):  
 | 
        GameWorld.Log("    ÏÂÒ»¸öÑ»·±àºÅ´íÎó!nextRepeatNum=%s" % nextRepeatNum)  
 | 
        return  
 | 
      
 | 
    GameWorld.Log("    ¹ýÌì±ä¸üÑ»·»î¶¯×´Ì¬, nextRepeatNum=%s" % nextRepeatNum)  
 | 
      
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    nextRepeatDict = repeatList[nextRepeatNum - 1][1]  
 | 
    for dictName, signID in nextRepeatDict.items():  
 | 
        # ÒѾÊÇÕâ¸öÖµ²»´¦Àí  
 | 
        if gameWorld.GetDictByKey(dictName) == signID:  
 | 
            #GameWorld.DebugLog("    ÒѾÊÇÕâ¸öÖµ²»´¦ÀídictName=%s,signID=%s"  % (dictName,signID))  
 | 
            continue  
 | 
          
 | 
        # Ä¬Èϵ±Ç°µÄ0µã¿ªÊ¼µ½µ±ÌìµÄ23µã59·Ö  
 | 
        curDay, beginDay, beginH, beginM, endDay, endH, endM = 0, 0, 0, 0, 0, 23, 59  
 | 
        __ChangeDA_ActionSign(gameWorld, dictName, signID, curDay, beginDay, beginH, beginM, endDay, endH, endM)  
 | 
              
 | 
    return  
 | 
  
 | 
  
 | 
  
 | 
## ´¦ÀíÖØ¿ª·þÎñÆ÷ºó, »î¶¯¼ÌÐø¿ªÆôÂß¼¸ù¾ÝÌìÊýkey  
 | 
#  @param None  
 | 
#  @return None  
 | 
def Dispose_ActionGoOnByDayKey():  
 | 
    if GameWorld.IsMergeServer():  
 | 
        return  
 | 
    GameWorld.DebugLog("´¦ÀíÌØ»Ý״̬ÐÅÏ¢...")  
 | 
    openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay)  
 | 
    isMixServer = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_IsMixServer)  
 | 
    mixServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_MixServerDay)  
 | 
    allActionGoOnInfo = ReadChConfig.GetEvalChConfig("ActionControlByDayKeyGoOn")  
 | 
      
 | 
    if not isMixServer:  
 | 
        __DoActionGoOnByDayKeyCheck(allActionGoOnInfo[0], openServerDay)  
 | 
    else:  
 | 
        __DoActionGoOnByDayKeyCheck(allActionGoOnInfo[1], mixServerDay)  
 | 
          
 | 
    return  
 | 
  
 | 
  
 | 
## °´Ì쿪Æô¿ÉÑ»·»î¶¯¼ì²é  
 | 
#  @param controlList:   
 | 
#  @return: None  
 | 
def __DoActionGoOnByDayKeyCheck(goOnList, curDay):  
 | 
    curTime = GameWorld.GetServerTime()  
 | 
    gameWorld = GameWorld.GetGameWorld()  
 | 
    for goOnControl in goOnList:  
 | 
        beginDay, beginH, beginM = goOnControl[0]  
 | 
        endDay, endH, endM = goOnControl[1]  
 | 
        if curDay < beginDay or curDay > endDay:  
 | 
            #»î¶¯²»ÔÚÕâһʱ¼ä¶Î  
 | 
            #GameWorld.DebugLog("»î¶¯²»ÔÚÕâһʱ¼ä¶ÎcurDay=%s < beginDay=%s or curDay > endDay=%s"   
 | 
            #                   % (curDay,beginDay,endDay))  
 | 
            continue  
 | 
          
 | 
        dictName = goOnControl[2]  # ×ÖµäÃû  
 | 
        signID = goOnControl[3]  # ±ê¼Ç  
 | 
          
 | 
        # ÒѾÊÇÕâ¸öÖµ²»´¦Àí  
 | 
        if gameWorld.GetDictByKey(dictName) == signID:  
 | 
            #GameWorld.DebugLog("ÒѾÊÇÕâ¸öÖµ²»´¦ÀídictName=%s,signID=%s"  % (dictName,signID))  
 | 
            continue  
 | 
  
 | 
        beginTime = ['-', '-', '-', '-', beginH, beginM]  
 | 
        endTime = ['-', '-', '-', '-', endH, endM]  
 | 
        #»¹Ã»¿ªÊ¼  
 | 
        if curDay == beginDay and CompareActTime(curTime, beginTime) == ChConfig.Def_Cmp_Lower:  
 | 
            #GameWorld.DebugLog("»¹Ã»¿ªÊ¼...")  
 | 
            continue  
 | 
          
 | 
        #ÒѾ½áÊø  
 | 
        if curDay == endDay and CompareActTime(curTime, endTime) == ChConfig.Def_Cmp_Greater:  
 | 
            #GameWorld.DebugLog("ÒѾ½áÊø...")  
 | 
            continue  
 | 
          
 | 
        __ChangeDA_ActionSign(gameWorld, dictName, signID, curDay, beginDay, beginH, beginM, endDay, endH, endM)  
 | 
                  
 | 
    return  
 | 
  
 | 
def __ChangeDA_ActionSign(gameWorld, dictName, signID, curDay, beginDay, beginH, beginM, endDay, endH, endM):  
 | 
    # ¼ÆË㿪ʼ¼°½áÊøÈÕÆÚ  
 | 
    beginTime, endTime = GetBeginEndTimeByDay(dictName, curDay, beginDay, beginH, beginM, endDay, endH, endM)  
 | 
      
 | 
    actionID = int(time.time())  
 | 
    GameWorld.Log('»î¶¯×´Ì¬±ä¸ü: dictName=%s,signID=%s,beginTime=%s,endTime=%s,actionID=%s'   
 | 
                  % (dictName, signID, beginTime, endTime, actionID))  
 | 
      
 | 
    #DZ¹æÔò£ºÔÚChConfig»î¶¯Ïà¹ØÉèÖÃÖУ¬ÌáÈ¡ÁË×ÖµäÃû  
 | 
    gameWorld.SetDict(dictName, signID)  
 | 
    gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_DayAction_BeginTime % dictName, beginTime)  
 | 
    gameWorld.SetDict(ShareDefine.Def_Notify_WorldKey_DayAction_EndTime % dictName, endTime)  
 | 
    # ±ê¼Ç»î¶¯Î¨Ò»id  
 | 
    actionIDKey = ShareDefine.Def_Notify_WorldKey_DayAction_ID % dictName  
 | 
    gameWorld.SetDict(actionIDKey, actionID)  
 | 
      
 | 
    #֪ͨMapserver,ÉèÖÃ×Öµä  
 | 
    GameWorld.SendMapServerMsgEx(actionIDKey, actionID)  
 | 
    GameWorld.SendMapServerMsgEx(dictName, signID)  
 | 
              
 | 
    #´¦ÀíGameServer»î¶¯Âß¼  
 | 
    __DoLogic_GameServer_ActionState(dictName, signID)  
 | 
    return  
 | 
  
 | 
## »ñÈ¡¿ªÆô½áÊøÊ±¼ä  
 | 
#  @param tick   
 | 
#  @return None  
 | 
def GetBeginEndTimeByDay(dictName, curDay, beginDay, beginH, beginM, endDay, endH, endM):  
 | 
    beginDiffDays = max(0, curDay - beginDay)  
 | 
    beginDateTime = GameWorld.GetDatetimeBySubDays(beginDiffDays)  
 | 
    beginDateTimeStr = str(beginDateTime).split(".")[0]  
 | 
    beginDateTimeStr = "%s %02d:%02d:00" % (beginDateTimeStr[:10], beginH, beginM)  
 | 
    beginTimeNum = GameWorld.ChangeTimeStrToNum(beginDateTimeStr, ChConfig.TYPE_Time_Format)  
 | 
  
 | 
    endDiffDays = max(0, endDay - curDay)  
 | 
    endDateTime = GameWorld.GetDatetimeByDiffDays(endDiffDays)  
 | 
    endDateTimeStr = str(endDateTime).split(".")[0]  
 | 
    endDateTimeStr = "%s %02d:%02d:59" % (endDateTimeStr[:10], endH, endM)  
 | 
    endTimeNum = GameWorld.ChangeTimeStrToNum(endDateTimeStr, ChConfig.TYPE_Time_Format)  
 | 
    return beginTimeNum, endTimeNum  
 | 
  
 | 
  
 |