|  |  | 
 |  |  | import PlayerFamilyRedPacket
 | 
 |  |  | import PlayerFairyCeremony
 | 
 |  |  | import PlayerNewFairyCeremony
 | 
 |  |  | import PlayerActFamilyCTGAssist
 | 
 |  |  | import PlayerActGarbageSorting
 | 
 |  |  | import PlayerActBossTrial
 | 
 |  |  | import PlayerUniversalGameRec
 | 
 |  |  | 
 |  |  | def SendMapServerOperationActionState():
 | 
 |  |  |     # 地图启动成功时通知本日运行活动相关状态
 | 
 |  |  |     
 | 
 |  |  |     CrossActionControl.SendMapServerCrossActionState()
 | 
 |  |  |      | 
 |  |  |     if GameWorld.IsCrossServer():
 | 
 |  |  |         # 跨服不处理运营活动
 | 
 |  |  |         return
 | 
 |  |  |     CrossActionControl.SendMapServerCrossActionState()
 | 
 |  |  |     
 | 
 |  |  |     isReload, OperationActionInfo = __GetOperationActionInfo()
 | 
 |  |  |     mapServerInfoDict = OperationActionInfo[OperationAction_MapServerInfo]
 | 
 |  |  | 
 |  |  |                 GameWorld.Log("        非法配置,未知活动类型,不处理! cfgID=%s,actNum=%s" % (cfgID, actNum))
 | 
 |  |  |                 continue
 | 
 |  |  |             
 | 
 |  |  |             if hasattr(ipyData, "GetJoinStartTime") and hasattr(ipyData, "GetJoinEndTime"):
 | 
 |  |  |                 joinStartTimeStr = ipyData.GetJoinStartTime()
 | 
 |  |  |                 joinEndTimeStr = ipyData.GetJoinEndTime()
 | 
 |  |  |             else:
 | 
 |  |  |                 joinStartTimeStr = ""
 | 
 |  |  |                 joinEndTimeStr = ""
 | 
 |  |  |                  | 
 |  |  |             if hasattr(ipyData, "GetStartTimeList") and hasattr(ipyData, "GetEndTimeList"):
 | 
 |  |  |                 startHMStrList = ipyData.GetStartTimeList()
 | 
 |  |  |                 endHMStrList = ipyData.GetEndTimeList()
 | 
 |  |  | 
 |  |  |                                  % (actName, cfgID, startHMStrList, endHMStrList))
 | 
 |  |  |                 continue
 | 
 |  |  |             
 | 
 |  |  |             isDayRest = 0 if not hasattr(ipyData, "GetIsDayReset") else ipyData.GetIsDayReset()
 | 
 |  |  |             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)
 | 
 |  |  | 
 |  |  |             GameWorld.Log("        startList=%s" % (startList))
 | 
 |  |  |             GameWorld.Log("        end  List=%s" % (endList))
 | 
 |  |  |             
 | 
 |  |  |             joinStartTimeList, joinEndTimeList = [], [] # 可指定活动可参与的时间点,不影响活动状态,只影响活动某些功能的参与时机,如上榜类
 | 
 |  |  |             if joinStartTimeStr:
 | 
 |  |  |                 if isDayRest:
 | 
 |  |  |                     joinStartTimeList.append(datetime.datetime.strptime("%d-%d-%d %s:00" % (curDateTime.year, curDateTime.month, curDateTime.day, joinStartTimeStr), ChConfig.TYPE_Time_Format))
 | 
 |  |  |                     joinEndTimeList.append(datetime.datetime.strptime("%d-%d-%d %s:00" % (curDateTime.year, curDateTime.month, curDateTime.day, joinEndTimeStr), ChConfig.TYPE_Time_Format))
 | 
 |  |  |                 else:
 | 
 |  |  |                     joinStartTimeList.append(datetime.datetime.strptime("%s %s:00" % (startDateStr, joinStartTimeStr), ChConfig.TYPE_Time_Format))
 | 
 |  |  |                     joinEndTimeList.append(datetime.datetime.strptime("%s %s:00" % (endDateStr, joinEndTimeStr), ChConfig.TYPE_Time_Format))                     | 
 |  |  |             GameWorld.Log("        joinStartTimeList=%s" % (joinStartTimeList))
 | 
 |  |  |             GameWorld.Log("        joinEndTime  List=%s" % (joinEndTimeList))
 | 
 |  |  |              | 
 |  |  |             for dtIndex, startDateTime in enumerate(startList):
 | 
 |  |  |                 endDateTime = endList[dtIndex]
 | 
 |  |  |                 # 广播 - 相对实际开始时间
 | 
 |  |  | 
 |  |  |             if actName in ShareDefine.MultiActNumOperationActNameList:
 | 
 |  |  |                 if actName not in operationTodayActionDict:
 | 
 |  |  |                     operationTodayActionDict[actName] = {} # 今日有需要处理的才初始化
 | 
 |  |  |                 operationTodayActionDict[actName][actNum] = [ipyData, startList, endList, notifyDict]
 | 
 |  |  |                 operationTodayActionDict[actName][actNum] = [ipyData, startList, endList, notifyDict, joinStartTimeList, joinEndTimeList]
 | 
 |  |  |             else:
 | 
 |  |  |                 operationTodayActionDict[actName] = [ipyData, startList, endList, notifyDict]
 | 
 |  |  |                 operationTodayActionDict[actName] = [ipyData, startList, endList, notifyDict, joinStartTimeList, joinEndTimeList]
 | 
 |  |  |                 
 | 
 |  |  |             if isActTime:
 | 
 |  |  |                 activityInfoDict = {ShareDefine.ActKey_CfgID:cfgID, ShareDefine.ActKey_ActNum:actNum}
 | 
 |  |  | 
 |  |  |                     
 | 
 |  |  |                 dayIndex = (curDateTime - startDayDate).days
 | 
 |  |  |                 actIDDateTime = startDayDate
 | 
 |  |  |                 isDayRest = 0 if not hasattr(ipyData, "GetIsDayReset") else ipyData.GetIsDayReset()
 | 
 |  |  |                 # 按时段开的默认每天重置
 | 
 |  |  |                 if isDayRest or (startHMStrList and endHMStrList):
 | 
 |  |  |                     actIDDateTime += datetime.timedelta(days=dayIndex)
 | 
 |  |  | 
 |  |  |         for sendMapServerMsgDict in curActMapInfoDictList:
 | 
 |  |  |             
 | 
 |  |  |             state = 0 # 默认关闭
 | 
 |  |  |             stateJoin = 0 # 可参与状态
 | 
 |  |  |             ipyData = None
 | 
 |  |  |             
 | 
 |  |  |             actNum = sendMapServerMsgDict.get(ShareDefine.ActKey_ActNum, 0)
 | 
 |  |  | 
 |  |  |                 else:
 | 
 |  |  |                     todayActInfoList = operationTodayActionDict[actName]
 | 
 |  |  |                     
 | 
 |  |  |                 if isinstance(todayActInfoList, list) and len(todayActInfoList) == 4:
 | 
 |  |  |                 if isinstance(todayActInfoList, list) and len(todayActInfoList) == 6:
 | 
 |  |  |                     #startList = [] # [startDateTime, ...]
 | 
 |  |  |                     #endList = [] # [endDateTime, ...]
 | 
 |  |  |                     #notifyDict = {} # {notifyDateTime:[notifyKey, [参数]], ...}
 | 
 |  |  |                     #ipyData 可能为 None
 | 
 |  |  |                     ipyData, startList, endList, notifyDict = todayActInfoList
 | 
 |  |  |                     ipyData, startList, endList, notifyDict, joinStartTimeList, joinEndTimeList = todayActInfoList
 | 
 |  |  |                     
 | 
 |  |  |                     # ״̬
 | 
 |  |  |                     for dIndex, startDateTime in enumerate(startList):
 | 
 |  |  | 
 |  |  |                         if startDateTime <= curDateTime < endDateTime:
 | 
 |  |  |                             state = dIndex + 1 # 代表第几个时间段
 | 
 |  |  |                             break
 | 
 |  |  |                          | 
 |  |  |                     if joinStartTimeList:
 | 
 |  |  |                         for jIndex, joinStartDateTime in enumerate(joinStartTimeList):
 | 
 |  |  |                             endJoinDateTime = joinEndTimeList[jIndex]
 | 
 |  |  |                             if joinStartDateTime <= curDateTime < endJoinDateTime:
 | 
 |  |  |                                 stateJoin = state
 | 
 |  |  |                                 break
 | 
 |  |  |                     else:
 | 
 |  |  |                         stateJoin = state
 | 
 |  |  |                         
 | 
 |  |  |                     # 全服广播提示信息
 | 
 |  |  |                     if curDateTime in notifyDict:
 | 
 |  |  | 
 |  |  |             if actName in ShareDefine.MultiActNumOperationActNameList:
 | 
 |  |  |                 dictName += "_%s" % actNum
 | 
 |  |  |             preState = gameWorld.GetDictByKey(dictName)
 | 
 |  |  |             if not isReload and preState == state:
 | 
 |  |  |              | 
 |  |  |             dictNameJoin = ChConfig.Def_WorldKey_OperationActionStateJoin % actName
 | 
 |  |  |             if actName in ShareDefine.MultiActNumOperationActNameList:
 | 
 |  |  |                 dictNameJoin += "_%s" % actNum
 | 
 |  |  |             preStateJoin = gameWorld.GetDictByKey(dictNameJoin)
 | 
 |  |  |              | 
 |  |  |             if not isReload and preState == state and preStateJoin == stateJoin:
 | 
 |  |  |                 #已经是这个状态了
 | 
 |  |  |                 continue
 | 
 |  |  |             GameWorld.Log("运营活动变更: actName=%s,actNum=%s,preState=%s,state=%s,dictName=%s" % (actName, actNum, preState, state, dictName))
 | 
 |  |  |             GameWorld.Log("运营活动变更: actName=%s,actNum=%s,preState=%s,state=%s,preStateJoin=%s,stateJoin=%s" % (actName, actNum, preState, state, preStateJoin, stateJoin))
 | 
 |  |  |             #更新字典值
 | 
 |  |  |             gameWorld.SetDict(dictName, state)
 | 
 |  |  |             gameWorld.SetDict(dictNameJoin, stateJoin)
 | 
 |  |  |             
 | 
 |  |  |             dbOperationActIDKey = PlayerDBGSEvent.Def_OperationActID % actName
 | 
 |  |  |             dbOperationActWorldLVKey = PlayerDBGSEvent.Def_OActWorldLV % actName
 | 
 |  |  | 
 |  |  |                         PlayerActGarbageSorting.OnActStart(actNum)
 | 
 |  |  |                     elif actName == ShareDefine.OperationActionName_BossTrial:
 | 
 |  |  |                         PlayerActBossTrial.OnActStart(actNum)
 | 
 |  |  |                     elif actName == ShareDefine.OperationActionName_FamilyCTGAssist:
 | 
 |  |  |                         PlayerActFamilyCTGAssist.OnActStart(actNum)
 | 
 |  |  |                 else:
 | 
 |  |  |                     if actName == ShareDefine.OperationActionName_GarbageSorting:
 | 
 |  |  |                         PlayerActGarbageSorting.OnActEnd(actNum)
 | 
 |  |  | 
 |  |  |             #GameWorld.SendMapServerMsgEx(dictName, state) # 运营活动不单独通知活动状态,需与活动信息整合后一起通知
 | 
 |  |  |             
 | 
 |  |  |             sendMapServerMsgDict[ShareDefine.ActKey_State] = state
 | 
 |  |  |             sendMapServerMsgDict[ShareDefine.ActKey_StateJoin] = stateJoin
 | 
 |  |  |             GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_OperationActionInfo % actName, sendMapServerMsgDict)
 | 
 |  |  |             
 | 
 |  |  |             GameWorld.Log("    sendMapServerMsgDict: %s" % (sendMapServerMsgDict))
 |