#!/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 PlayerManorWar #import GameWorldShopItem #import GameWorldActionTeHui import GameWorldAverageLv import CrossRealmPK import GameWorldFamilyWar import PlayerFamilyParty import IpyGameDataPY import PlayerXMZZ import PlayerFamilySWRH import GameWorldBoss import PlayerFairyCeremony import GameWorldProcess import ChPyNetSendPack import NetPackCommon import PlayerStore from types import IntType import time #--------------------------------------------------------------------- #ÄêÔÂÈÕʱ¼ä¸ñʽ Time_YmdFormat = ChConfig.TYPE_Time_YmdFormat ATTR_CALL_TIME = ['weekday', 'year', 'month', 'day', 'hour', 'minute'] ( OperationAction_ReloadSign, # ÐÅÏ¢ÖØÔØ±ê¼Ç 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, {}) 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) serverTime = GameWorld.GetServerTime() curHour = serverTime.hour reloadSignHour = 0 if curHour < 5 else 5 reloadSign = "%s_%s" % (openServerDay, reloadSignHour) if OperationActionInfo and OperationActionInfo[OperationAction_ReloadSign] == reloadSign: #GameWorld.DebugLog("ÒѾ­¼ÓÔØ¹ý±¾ÈÕÔËÓª»î¶¯´¦ÀíÐÅÏ¢£¡openServerDay=%s" % openServerDay) return False, OperationActionInfo # ÒòΪºóÃæµÄʱ¼äÅж϶¼ÊǾ«È·µ½·ÖµÄ£¬¶ø´¦Àí´ËÂß¼­µÄʱºò¿ÉÄܲ»ÊÇ0Ã룬ËùÒÔÕâÀïµÄdatetimeÈ¡µ±Ç°Ê±¼ä¾«È·µ½·ÖµÄ 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) customMaxServerDay = IpyGameDataPY.GetFuncCfg("OperationAction", 1) # ¶¨ÖÆÔËÓª»î¶¯×î´ó¿ª·þÌì operationActionDict = {} mapServerOperationActionDict = {} serverID = GameWorld.GetServerID() ipyDataMgr = IpyGameDataPY.IPY_Data() GameWorld.Log("===== ¼ÓÔØ±¾ÈÕÔËÓª»î¶¯ÐÅÏ¢: %s, serverID=%s,openServerDay=%s,customMaxServerDay=%s,reloadSign=%s =====" % (curDateTime, serverID, openServerDay, customMaxServerDay, reloadSign)) for actName in ShareDefine.OperationActionNameList: # È¡³ö±¾»î¶¯ËùÊô±¾·þIDµÄËùÓÐÅäÖà curServerActIpyDataList = __GetOperationActionServerIpyDataList(ipyDataMgr, serverID, actName) GameWorld.Log("¼ÓÔØÔËÓª»î¶¯: actName=%s,¿É´¦ÀíÌõÊý=%s" % (actName, len(curServerActIpyDataList))) needStartList = [] # [startDateTime, ...] needEndList = [] # [endDateTime, ...] needNotifyDict = {} # {notifyDateTime:[notifyKey, [²ÎÊý]], ...} activityIpyData = None # »î¶¯ÖеĵÄÅäÖã¬È¡ÐèÒª´¦ÀíµÄÅäÖÃÖпªÊ¼Ê±¼ä×îÍíµÄ£¬·´Ö®¿ª¹ØÊ±¼äͷβÏàÁ¬µÄʱºòÎÞ·¨¿ªÆôºóÃæµÄ»î¶¯ # ×¢Ò⣺ÿ¸ö»î¶¯ÅäÖûáÓжà¸ö»î¶¯Ê±¼äµã£¬µ«ÊÇÓÐÇÒÖ»ÄÜÉúЧһÌõ»î¶¯ÅäÖ㬻»¾ä»°Ëµ¾ÍÊÇÿ¸ö»î¶¯ÅäÖÃʱ¼ä²»ÔÊÐí½»²æ for ipyData in curServerActIpyDataList: cfgID = ipyData.GetCfgID() startDateStr = ipyData.GetStartDate() endDateStr = ipyData.GetEndDate() GameWorld.Log(" cfgID=%s,mark=%s,serverIDList=%s,startDateStr=%s,endDateStr=%s,openServerDay=%s,curDateTime=%s" % (cfgID, ipyData.GetActMark(), ipyData.GetServerIDList(), startDateStr, endDateStr, openServerDay, curDateTime)) # °´¿ª·þÌ쿪µÄ if startDateStr.isdigit() and endDateStr.isdigit(): startServerDay, endServerDay = int(startDateStr), int(endDateStr) #½áÊøÈÕ¿ÉÄÜ»¹ÐèÒª´¦Àí¹ã²¥Ö®À࣬ËùÒÔÕâÀïÐèÒª+1 if openServerDay > endServerDay + 1: GameWorld.Log(" µ±Ç°¿ª·þÌ쳬¹ý»î¶¯½áÊø¿ª·þÌ죬²»´¦Àí! cfgID=%s,%s ~ %s < openServerDay(%s)" % (cfgID, startDateStr, endDateStr, openServerDay)) continue openServerDateTime = curDateTime + datetime.timedelta(days=(startServerDay-openServerDay)) endServerDateTime = curDateTime + datetime.timedelta(days=(endServerDay-openServerDay)) startDateStr = "%d-%d-%d" % (openServerDateTime.year, openServerDateTime.month, openServerDateTime.day) endDateStr = "%d-%d-%d" % (endServerDateTime.year, endServerDateTime.month, endServerDateTime.day) GameWorld.Log(" ¿ª·þÌìת»¯ÎªÈÕÆÚ: %s ~ %s" % (startDateStr, endDateStr)) else: if openServerDay <= customMaxServerDay: GameWorld.Log(" °´ÈÕÆÚ¿ªµÄÔÚ¿ª·þ¶¨ÖÆÏÞÖÆÌìÄÚ£¬²»´¦Àí! cfgID=%s,%s ~ %s,openServerDay=%s" % (cfgID, startDateStr, endDateStr, openServerDay)) continue customMaxServerDateTime = curDateTime + datetime.timedelta(days=(customMaxServerDay-openServerDay)) curStartDateTime = datetime.datetime.strptime("%s %02d:%02d:%02d" % (startDateStr, customMaxServerDateTime.hour, customMaxServerDateTime.minute, customMaxServerDateTime.second), ChConfig.TYPE_Time_Format) if curStartDateTime <= customMaxServerDateTime: GameWorld.Log(" °´ÈÕÆÚ¿ªµÄ¿ªÊ¼ÈÕÆÚÔÚ¿ª·þ¶¨ÖÆÏÞÖÆÌìÄÚ£¬²»´¦Àí! cfgID=%s,curStartDateTime=%s,customMaxServerDateTime=%s" % (cfgID, curStartDateTime, customMaxServerDateTime)) continue 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 {} notifyInfoLoopInfo = ipyData.GetNotifyInfoLoop() if hasattr(ipyData, "GetNotifyInfoLoop") else {} # [Ñ­»··ÖÖÓ, ¹ã²¥key, [¹ã²¥²ÎÊýÁбí¿ÉÑ¡]] if len(startHMStrList) != len(endHMStrList): GameWorld.ErrLog(" »î¶¯ÅäÖÿªÊ¼¼°½áÊøÊ±¼ä¸öÊý²»Æ¥Åä! actName=%s,cfgID=%s,startHMStrList=%s,endHMStrList=%s" % (actName, cfgID, startHMStrList, endHMStrList)) continue resetType = 0 if not hasattr(ipyData, "GetResetType") else ipyData.GetResetType() # ÖØÖÃÀàÐÍ£¬0-0µãÖØÖã»1-5µãÖØÖà if resetType == 1: startDayDate = datetime.datetime.strptime("%s 05:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) endDayDate = datetime.datetime.strptime("%s 05:00:00" % (endDateStr), ChConfig.TYPE_Time_Format) # ½áÊøÈÕÆÚ5µã elif resetType == 2: startDayDate = datetime.datetime.strptime("%s 05:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) endDayDate = datetime.datetime.strptime("%s 00:00:00" % (endDateStr), ChConfig.TYPE_Time_Format) + datetime.timedelta(days=1) # ½áÊøÈÕÆÚ¸ôÌì0µã else: startDayDate = datetime.datetime.strptime("%s 00:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) endDayDate = datetime.datetime.strptime("%s 00:00:00" % (endDateStr), ChConfig.TYPE_Time_Format) + datetime.timedelta(days=1) # ½áÊøÈÕÆÚ¸ôÌì0µã advanceMinutes = 0 if not hasattr(ipyData, "GetAdvanceMinutes") else ipyData.GetAdvanceMinutes() # Ìáǰ֪ͨʱ¼ä£¬·ÖÖÓ£¬ÔÝÖ»Ö§³Ö°´ÌìµÄ GameWorld.Log(" resetType=%s,startDayDate=%s,endDayDate=%s,startHMStrList=%s,endHMStrList=%s,advanceMinutes=%s" % (resetType, startDayDate, endDayDate, startHMStrList, endHMStrList, advanceMinutes)) startList = [] # [startDateTime, ...] endList = [] # [endDateTime, ...] startNotifyDict = {} # {notifyDateTime:notifyInfo, ...} endNotifyDict = {} # {notifyDateTime:notifyInfo, ...} loopNotifyDict = {} # {notifyDateTime:notifyInfo, ...} isActivity = False # ÓÐÐèÒª´¦Àí¿ª¹ØÊ±¼äµÄ£¨¿ªÊ¼¡¢½áÊø£© isNotify = False isAdvanceNotice = False isEnd = False # ûÅäÖÃʱ·ÖµÄ´ú±íÈ«Ìì, Ö»Òª¿ªÊ¼»ò½áÊøÊ±·ÖûÅä¶¼Ëã if not startHMStrList or not endHMStrList: startDateTime = startDayDate endDateTime = endDayDate startList.append(startDateTime) endList.append(endDateTime) # ͬһ¸ö»î¶¯ÀàÐÍÊDz»ÔÊÐíʱ¼äÉÏÅäÖÃÓÐÖØµþµÄ£¬ËùÒÔÒ»¸ö»î¶¯ÀàÐÍÂú×ã»î¶¯ÖеÄʱ¼äµÄÓÐÇÒ½öÓÐÒ»ÌõÅäÖà # ²ß»®¿ÉÄÜͬʱÅäÖöà¸öʱ¼ä£¬µ«ÊǻÖеÄÓÐÇÒ½öÓÐÒ»ÌõÅäÖà if startDayDate <= curDateTime <= endDayDate: needStartList.append(startDateTime) needEndList.append(endDateTime) isActivity = True isEnd = (curDateTime == endDayDate) # ÿÌ찴ʱ¶Î¿ªÆôµÄ£¬Ö§³Ö¶àʱ¶Î else: if startDayDate <= curDateTime <= endDayDate: isEnd = (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 if advanceMinutes and startDayDate: advanceNoticeDateTime = startDayDate + datetime.timedelta(minutes=-advanceMinutes) if advanceNoticeDateTime.year == curDateTime.year and advanceNoticeDateTime.month == curDateTime.month and advanceNoticeDateTime.day == curDateTime.day: isAdvanceNotice = True GameWorld.Log(" advanceNoticeDateTime=%s,isAdvanceNotice=%s" % (advanceNoticeDateTime, isAdvanceNotice)) GameWorld.Log(" startList=%s" % (startList)) GameWorld.Log(" end List=%s" % (endList)) GameWorld.Log(" needStartList=%s" % (needStartList)) GameWorld.Log(" need EndList=%s" % (needEndList)) 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: startNotifyDict[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: endNotifyDict[notifyDateTime] = notifyInfo isNotify = True # ¹ã²¥ - Ñ­»·¹ã²¥ if notifyInfoLoopInfo and len(notifyInfoLoopInfo) >= 2: loopMinutes, loopNotifyKey = notifyInfoLoopInfo[:2] loopNotifyParamList = notifyInfoLoopInfo[2] if len(notifyInfoLoopInfo) > 2 else [] notifyInfo = [loopNotifyKey, loopNotifyParamList] # Ñ­»·¹ã²¥µÄĬÈÏÎÞ²ÎÊý loopCount, loopMaxCount = 0, 100 while loopMinutes and loopNotifyKey and loopCount < loopMaxCount: loopCount += 1 notifyDateTime = startDateTime + datetime.timedelta(minutes=loopMinutes*loopCount) if notifyDateTime >= endDateTime: break if notifyDateTime.year == curDateTime.year and notifyDateTime.month == curDateTime.month and notifyDateTime.day == curDateTime.day: loopNotifyDict[notifyDateTime] = notifyInfo isNotify = True if startNotifyDict or endNotifyDict or loopNotifyDict: GameWorld.Log(" startNotifyDict: minutes=%s, %s" % (notifyInfoDictStart.keys(), startNotifyDict)) GameWorld.Log(" end NotifyDict: minutes=%s, %s" % (notifyInfoDictEnd.keys(), endNotifyDict)) GameWorld.Log(" loop NotifyDict: lopInfo=%s, %s" % (notifyInfoLoopInfo, loopNotifyDict.keys())) needNotifyDict.update(startNotifyDict) needNotifyDict.update(endNotifyDict) needNotifyDict.update(loopNotifyDict) if not isActivity and not isNotify and not isAdvanceNotice: continue GameWorld.Log(" ÐèÒª´¦ÀíµÄÔËÓª»î¶¯ÐÅÏ¢: cfgID=%s,isAdvanceNotice=%s,isActivity=%s,isEnd=%s,isNotify=%s" % (cfgID, isAdvanceNotice, isActivity, isEnd, isNotify)) # µ±ÌìÓÐÐèÒª¼¤»î»î¶¯»òÕßÌáǰԤ¸æ»î¶¯µÄÈ¡·Ç½áÊøµÄΪ׼£¬Èç¹ûÓжà¸ö·Ç½áÊøµÄÒ»°ã¾ÍÊDz߻®Ôڻʱ¼äÉÏÅäÖý»²æ£¬ÕâÖÖÊDz»ÔÊÐíµÄ if isActivity or isAdvanceNotice: if not activityIpyData or (isActivity and not isEnd): activityIpyData = ipyData activityInfoDict = {ShareDefine.ActKey_CfgID:cfgID} if startDayDate <= curDateTime < endDayDate: dayIndex = 0 actIDDateTime = startDayDate isDayRest = 0 if not hasattr(ipyData, "GetIsDayReset") else ipyData.GetIsDayReset() # °´Ê±¶Î¿ªµÄĬÈÏÿÌìÖØÖà if isDayRest or (startHMStrList and endHMStrList): dayIndex = (curDateTime - startDayDate).days actIDDateTime += datetime.timedelta(days=dayIndex) actID = int(time.mktime(actIDDateTime.timetuple())) # ĬÈÏÈ¡¿ªÊ¼Ê±¼äµãµÄtimeÖµ×÷Ϊ»î¶¯ID activityInfoDict[ShareDefine.ActKey_DayIndex] = dayIndex activityInfoDict[ShareDefine.ActKey_ID] = actID GameWorld.Log(" isDayRest=%s,actIDDateTime=%s,actID=%s" % (isDayRest, actIDDateTime, actID)) needStartList.sort() needEndList.sort() mapServerOperationActionDict[actName] = activityInfoDict GameWorld.Log(" activityInfoDict=%s" % (activityInfoDict)) if activityIpyData or needStartList or needEndList or needNotifyDict: # activityIpyData ¿ÉÄÜΪNone operationActionDict[actName] = [activityIpyData, needStartList, needEndList, needNotifyDict] OperationActionInfo = IpyGameDataPY.SetConfigEx(key, [reloadSign, operationActionDict, mapServerOperationActionDict]) GameWorld.Log("±¾ÈÕÔËÓª»î¶¯ÐÅÏ¢¼ÓÔØÍê±Ï!reloadSign=%s,isRefreshState=%s" % (reloadSign, isRefreshState)) GameWorld.Log(" operationActionDict=%s" % operationActionDict) GameWorld.Log(" mapServerOperationActionDict=%s" % mapServerOperationActionDict) GameWorld.Log("=============================================================") if isRefreshState: Dispose_OperationActionState(True) return True, OperationActionInfo def __GetOperationActionServerIpyDataList(ipyDataMgr, serverID, actName): ## »ñÈ¡ÔËÓª»î¶¯±¾·þÎñÆ÷¶ÔÓ¦µÄÅäÖÃÊý¾ÝÁбí # ËùÓÐÅäÖÃÏȰ´»î¶¯±êʶ¹é×é platform = GameWorld.GetPlatform() 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() platformList = [] if not hasattr(ipyData, "GetPlatformList") else ipyData.GetPlatformList() if platformList and platform not in platformList: GameWorld.Log("·Ç±¾Æ½Ì¨»î¶¯£¬²»È¡£¡platform=%s,platformList=%s,actName=%s,cfgID=%s" % (platform, platformList, actName, ipyData.GetCfgID())) continue 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 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, {}) 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) elif actName == ShareDefine.OperationActionName_FlashSale: if ipyData and preState != state: dayIndex = sendMapServerMsgDict.get(ShareDefine.ActKey_DayIndex, 0) PlayerStore.ResetFlashSaleBuyCnt(ipyData, dayIndex, state) #֪ͨ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 openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1 multiExpRateInfo = ChPyNetSendPack.tagGCMultiExpRateInfo() multiExpRateInfo.Clear() multiExpRateInfo.StartDate = GameWorld.GetOperationActionDateStr(ipyData.GetStartDate(), openServerDay) multiExpRateInfo.EndtDate = GameWorld.GetOperationActionDateStr(ipyData.GetEndDate(), openServerDay) 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 openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1 multiRealmPointInfo = ChPyNetSendPack.tagGCMultiRealmPointInfo() multiRealmPointInfo.Clear() multiRealmPointInfo.StartDate = GameWorld.GetOperationActionDateStr(ipyData.GetStartDate(), openServerDay) multiRealmPointInfo.EndtDate = GameWorld.GetOperationActionDateStr(ipyData.GetEndDate(), openServerDay) multiRealmPointInfo.Multiple = ipyData.GetMultiple() multiRealmPointInfo.LimitLV = ipyData.GetLVLimit() multiRealmPointInfo.LimitPoint = ipyData.GetPointLimit() 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) # µ±ÌìÈÕÆÚ openServerWeekday = GameWorldProcess.GetOpenServerWeekday() # ·þÎñÆ÷¿ª·þʱÊÇÐÇÆÚ¼¸ curMaxCustomServerDay = IpyGameDataPY.GetFuncCfg("OperationAction", 1) - openServerWeekday + 1 # ×î´óÓÐЧ¶¨ÖÆ¿ª·þÌì GameWorld.Log("===== ¼ÓÔØ½ñÌìÈÕ³£»î¶¯ÐÅÏ¢ =====") GameWorld.Log(" ¿ª·þÊÇÐÇÆÚ%s, ¿ª·þµÚ%sÌì, µ±Ç°ÐÇÆÚ%s" % (openServerWeekday, openServerDay, weekDay)) GameWorld.Log(" ×î´óÓÐЧ¶¨ÖÆ¿ª·þÌì: %s" % (curMaxCustomServerDay)) customDailyIDList = [] dailyTimeInfoList = [] # Ôݹ̶¨Ç°2Öܶ¨ÖÆÓÐЧ, Ϊ·½±ãGMÃüÁî²âÊÔ£¬ÕâÀïÓÿª·þÌì×öÅжϣ¬²»Óÿª·þÖÜ if openServerDay <= curMaxCustomServerDay: customIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("DailyActionCustom", openServerWeekday) GameWorld.Log(" ±¾Öܶ¨ÖƵÄÈÕ³£»î¶¯ÌõÊý: %s" % len(customIpyDataList)) customIDList = [] todayCustomIDList = [] for customIpyData in customIpyDataList: dataID = customIpyData.GetID() dailyID = customIpyData.GetDailyID() if dailyID not in customDailyIDList: customDailyIDList.append(dailyID) customIDList.append(dataID) if customIpyData.GetOpenServerDay() == openServerDay: todayCustomIDList.append(dataID) isCustom = True dailyTimeInfoList.append([isCustom, customIpyData.GetOpenTimeList(), customIpyData]) GameWorld.Log(" Ôö¼Ó±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢: isCustom=%s,dailyID=%s,dataID=%s" % (isCustom, dailyID, dataID)) GameWorld.Log(" ±¾Öܶ¨ÖƵÄÈÕ³£ÅäÖñíIDÁбí: %s" % (customIDList)) GameWorld.Log(" ±¾Öܶ¨ÖƵÄÈÕ³£»î¶¯IDÁбí: %s" % (customDailyIDList)) GameWorld.Log(" ½ñÌì¶¨ÖÆµÄÈÕ³£±íIDÁбí=%s" % (todayCustomIDList)) else: GameWorld.Log(" ³¬¹ý×î´ó¶¨ÖÆ¿ª·þÌ죬²»¶¨ÖÆ£¬×ß³£¹æÈÕ³£ÅäÖã¡") GameWorld.Log(" ´¦Àí³£¹æÈÕ³£»î¶¯ÅäÖÃ") ipyDataMgr = IpyGameDataPY.IPY_Data() dailyActionCount = ipyDataMgr.GetDailyActionCount() for i in xrange(dailyActionCount): dailyIpyData = ipyDataMgr.GetDailyActionByIndex(i) dailyID = dailyIpyData.GetDailyID() # Êǵ±Ì쿪·þÌì¶¨ÖÆ»î¶¯µÄ²»´¦Àí³£¹æ»î¶¯ if dailyID in customDailyIDList: GameWorld.Log(" ³£¹æ»î¶¯IDÅäÖÃÊǽñÌìµÄ¶¨ÖƻID£¬²»´¦Àí£¡: dailyID=%s" % dailyID) continue openTimeDict = dailyIpyData.GetOpenTimeDict() # ûÓÐʱ¼ä¿ØÖƵ쬴ú±íÓÀ¾Ã¿ª·Å 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 openTimeList = openTimeDict["0"] if "0" in openTimeDict else openTimeDict[weekDay] dailyTimeInfoList.append([False, openTimeList, dailyIpyData]) GameWorld.Log(" -----------------------") for isCustom, openTimeList, ipyData in dailyTimeInfoList: dailyID = ipyData.GetDailyID() notifyInfoDict = ipyData.GetNotifyInfo() openList = [] # [(ʱ,·Ö), ...] overList = [] # [(ʱ,·Ö), ...] goonStateDict = {} # {״̬:[(aDateTime, bDateTime)], ...} notifyDict = {} # {(ʱ,·Ö):[notifyKey, [²ÎÊý]], ...} OpenState = 1 # ¶¨Ò忪Æô״̬Ϊ1 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=ipyData.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(" Ôö¼Ó±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢: isCustom=%s,dailyID=%s,openList=%s,overList=%s,goonStateDict=%s,notifyDict=%s" % (int(isCustom), dailyID, openList, overList, goonStateDict, notifyDict)) TodayDailyActionInfo = IpyGameDataPY.SetConfigEx(key, [openServerDay, todayActionInfo]) GameWorld.Log("±¾ÈÕÈÕ³£»î¶¯ÐÅÏ¢¼ÓÔØÍê±Ï!") 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 if state: # Æï³èÕù¶á»î¶¯¿ªÊ¼Ç°Í¬²½ÓÐЧÈËÊýµ½µØÍ¼ if dailyActionID == ShareDefine.DailyActionID_FamilyRobBoss: GameWorldBoss.SyncMapServer_HorsePetRobBossPlayerCount() #֪ͨ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 notResetIDList = IpyGameDataPY.GetConfigEx(key) if notResetIDList == 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 = startWeekDay, 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.sort() # ¼ÓÔØ¶¨ÖƱí customStateTimeDict = {} for i in xrange(ipyDataMgr.GetFBStateTimeCustomCount()): customIpyData = ipyDataMgr.GetFBStateTimeCustomByIndex(i) dataID = customIpyData.GetID() dataMapID = customIpyData.GetDataMapID() openWeek, openDay = customIpyData.GetOpenServerWeek(), customIpyData.GetOpenServerDay() startHour, startMinute = customIpyData.GetStartHour(), customIpyData.GetStartMinute() endHour, endMinute = customIpyData.GetEndHour(), customIpyData.GetEndMinute() startTimeList, endTimeDict = customStateTimeDict.get(dataMapID, [[], {}]) startTimeList.append([openWeek, openDay, startHour, startMinute]) endTimeDict[dataID] = [openWeek, openDay, endHour, endMinute] customStateTimeDict[dataMapID] = [startTimeList, endTimeDict] FBStateEndTimeNotResetCustomIDList = [] for dataMapID, timeInfo in customStateTimeDict.items(): startTimeList, endTimeDict = timeInfo for dataID, endTime in endTimeDict.items(): # ½áÊøÊ±¼äÊôÓÚijһÌõµÄ¿ªÆôʱ¼ä£¬Ôò²»ÖØÖ㬾ßÌå״̬ÓÉÁíÒ»Ìõ¾ö¶¨ if endTime in startTimeList: FBStateEndTimeNotResetCustomIDList.append(dataID) FBStateEndTimeNotResetCustomIDList.sort() notResetIDList = IpyGameDataPY.SetConfigEx(key, [FBStateEndTimeNotResetIDList, FBStateEndTimeNotResetCustomIDList]) GameWorld.Log("¼ÓÔØ¸±±¾×´Ì¬½áÊøÊ±¼ä²»ÐèÒªÖØÖÃ״ֵ̬µÄÊý¾ÝIDÁбí:") GameWorld.Log(" ²»ÐèÒªÖØÖõij£¹æID: %s" % FBStateEndTimeNotResetIDList) GameWorld.Log(" ²»ÐèÒªÖØÖõ͍֯ID: %s" % FBStateEndTimeNotResetCustomIDList) return notResetIDList def __GetTodayFBStateTimeInfo(): key = "TodayFBStateTimeInfo" openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1 TodayFBStateTimeInfo = IpyGameDataPY.GetConfigEx(key) if TodayFBStateTimeInfo and TodayFBStateTimeInfo[0] == openServerDay: #GameWorld.DebugLog("ÒѾ­¼ÓÔØ¹ý±¾ÈÕ¸±±¾×´Ì¬´¦ÀíÐÅÏ¢£¡openServerDay=%s" % openServerDay) return TodayFBStateTimeInfo[1] openServerDay = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerDay) + 1 curDateTime = GameWorld.GetServerTime() curWeekDay, curHour, curMinute = curDateTime.weekday() + 1, curDateTime.hour, curDateTime.minute openServerWeekday = GameWorldProcess.GetOpenServerWeekday() # ·þÎñÆ÷¿ª·þʱÊÇÐÇÆÚ¼¸ if openServerWeekday <= 0: GameWorld.ErrLog("»ñÈ¡¿ª·þÊÇÐÇÆÚ¼¸Êý¾Ý´íÎó£¡openServerWeekday=%s" % openServerWeekday) return [] curMaxCustomServerDay = IpyGameDataPY.GetFuncCfg("OperationAction", 1) - openServerWeekday + 1 # ×î´óÓÐЧ¶¨ÖÆ¿ª·þÌì GameWorld.Log("===== ¼ÓÔØ½ñÌ츱±¾×´Ì¬Ê±¼ä±í =====") GameWorld.Log(" ¿ª·þÊÇÐÇÆÚ%s, ¿ª·þµÚ%sÌì, µ±Ç°ÐÇÆÚ%s,%sµã%s·Ö £¡" % (openServerWeekday, openServerDay, curWeekDay, curHour, curMinute)) GameWorld.Log(" ×î´óÓÐЧ¶¨ÖÆ¿ª·þÌì: %s" % (curMaxCustomServerDay)) ipyDataMgr = IpyGameDataPY.IPY_Data() customMapIDList = [] # ±¾ÖÜÓж¨ÖƵĸ±±¾Êý¾ÝµØÍ¼IDÁбí fbStateTimeInfoList = [] # Ôݹ̶¨Ç°2Öܶ¨ÖÆÓÐЧ, Ϊ·½±ãGMÃüÁî²âÊÔ£¬ÕâÀïÓÿª·þÌì×öÅжϣ¬²»Óÿª·þÖÜ if openServerDay <= curMaxCustomServerDay: customIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("FBStateTimeCustom", openServerWeekday) GameWorld.Log(" ±¾Öܶ¨ÖƵĸ±±¾»î¶¯ÌõÊý: %s" % len(customIpyDataList)) customIDList = [] # ±¾Öܶ¨ÖƵÄÊý¾Ý±íID todayCustomIDList = [] # ½ñÌì¶¨ÖÆµÄÊý¾Ý±íID for customIpyData in customIpyDataList: dataID = customIpyData.GetID() dataMapID = customIpyData.GetDataMapID() if dataMapID not in customMapIDList: customMapIDList.append(dataMapID) customIDList.append(dataID) if customIpyData.GetOpenServerDay() == openServerDay: todayCustomIDList.append(dataID) isCustom, startWeekDay, endWeekDay = True, curWeekDay, curWeekDay fbStateTimeInfoList.append([isCustom, startWeekDay, endWeekDay, customIpyData]) GameWorld.Log(" ½ñÌìÒª´¦ÀíµÄ¸±±¾×´Ì¬ÅäÖÃ: ÊÇ·ñ¶¨ÖÆ=%s,dataID=%s" % (isCustom, dataID)) GameWorld.Log(" ±¾Öܶ¨ÖƵÄÅäÖñíIDÁбí: %s" % (customIDList)) GameWorld.Log(" ±¾Öܶ¨ÖƵĸ±±¾µØÍ¼Áбí: %s" % (customMapIDList)) GameWorld.Log(" ½ñÌì¶¨ÖÆµÄ±íIDÁбí=%s" % (todayCustomIDList)) else: GameWorld.Log(" ³¬¹ý×î´ó¶¨ÖÆ¿ª·þÌ죬²»¶¨ÖÆ£¬×ß³£¹æ¸±±¾×´Ì¬Ê±¼ä£¡") GameWorld.Log(" ´¦Àí³£¹æ¸±±¾×´Ì¬Ê±¼äÅäÖÃ") for i in xrange(ipyDataMgr.GetFBStateTimeCount()): fbStateTimeIpyData = ipyDataMgr.GetFBStateTimeByIndex(i) dataID = fbStateTimeIpyData.GetID() dataMapID = fbStateTimeIpyData.GetDataMapID() # Êǵ±Ì쿪·þÌì¶¨ÖÆ»î¶¯µÄ²»´¦Àí³£¹æ»î¶¯ if dataMapID in customMapIDList: GameWorld.Log(" dataID=%s,dataMapID=%s, ÔÚ±¾Öܶ¨ÖƵĸ±±¾µØÍ¼ÁбíÀï,²»´¦Àí£¡" % (dataID, dataMapID)) continue # Ôݲ»Ö§³Ö¿çÌìµÄ»î¶¯ isCustom, startWeekDay, endWeekDay = False, fbStateTimeIpyData.GetStartWeekday(), fbStateTimeIpyData.GetStartWeekday() if curWeekDay != startWeekDay: GameWorld.Log(" dataID=%s,dataMapID=%s, ²»ÊDZ¾ÌìµÄ¸±±¾»î¶¯,²»´¦Àí£¡curWeekDay=%s,startWeekDay=%s" % (dataID, dataMapID, curWeekDay, startWeekDay)) continue fbStateTimeInfoList.append([isCustom, startWeekDay, endWeekDay, fbStateTimeIpyData]) GameWorld.Log(" ½ñÌìÒª´¦ÀíµÄ¸±±¾×´Ì¬ÅäÖÃ: ÊÇ·ñ¶¨ÖÆ=%s,dataID=%s" % (isCustom, dataID)) TodayFBStateTimeInfo = IpyGameDataPY.SetConfigEx(key, [openServerDay, fbStateTimeInfoList]) GameWorld.Log("±¾ÈÕ¸±±¾»î¶¯×´Ì¬ÐÅÏ¢¼ÓÔØÍê±Ï!") GameWorld.Log("=============================================================") return TodayFBStateTimeInfo[1] def Dispose_FBStateTime(): ## ¸±±¾×´Ì¬Ê±¼ä±í״̬´¦Àí, Ö§³Ö goon×÷Ó㬿ª¹Ø·þ״̬²»ÊÜÓ°Ï죬·þÎñÆ÷ÖØÐÂÆô¶¯»á×Ô¶¯±ä¸üΪËùÓÐʱ¼ä¶ÎµÄ״ֵ̬ FBStateEndTimeNotResetIDList, FBStateEndTimeNotResetCustomIDList = __GetFBStateEndTimeNotResetIDList() 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 openServerWeekday = GameWorldProcess.GetOpenServerWeekday() # ·þÎñÆ÷¿ª·þʱÊÇÐÇÆÚ¼¸ GameWorld.DebugLog("¸±±¾×´Ì¬Ê±¼ä±í״̬´¦Àí...¿ª·þÊÇÐÇÆÚ%s, ¿ª·þµÚ%sÌì, µ±Ç°ÐÇÆÚ%s,%sµã%s·Ö" % (openServerWeekday, openServerDay, curWeekDay, curHour, curMinute)) GameWorld.DebugLog(" FBStateEndTimeNotResetIDList=%s" % (FBStateEndTimeNotResetIDList)) GameWorld.DebugLog(" FBStateEndTimeNotResetCustomIDList=%s" % (FBStateEndTimeNotResetCustomIDList)) gameWorld = GameWorld.GetGameWorld() fbStateTimeInfoList = __GetTodayFBStateTimeInfo() for isCustom, startWeekDay, endWeekDay, ipyData in fbStateTimeInfoList: dataID = ipyData.GetID() dataMapID = ipyData.GetDataMapID() GameWorld.DebugLog(" isCustom=%s,dataID=%s,dataMapID=%s" % (isCustom, dataID, dataMapID)) startHour, startMinute = ipyData.GetStartHour(), ipyData.GetStartMinute() endHour, endMinute = ipyData.GetEndHour(), ipyData.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 = ipyData.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: if (isCustom and dataID not in FBStateEndTimeNotResetCustomIDList) or (not isCustom and dataID not in FBStateEndTimeNotResetIDList): isReset = True #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 = ipyData.GetCanEnter() updStateValue = ipyData.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.IsCrossServer(): return Dispose_ActionGoOnByDayKey() return ## µ±Ç°Ê±¼äÓëÖ¸¶¨Ê±¼ä±È½Ï # @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) # #´ðÌâ»î¶¯ # 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) #Æï³èÕù¶á elif dictName == ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyRobBoss: GameWorldBoss.OnHorsePetRobBossActionChange(isOpen) #¿ç·þPK elif dictName == ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_CrossReamPK: CrossRealmPK.OnCrossRealmPKDailyActionStateChange(isOpen) 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.IsCrossServer(): 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