From 28cf96828011304cd74254017a1af7a0cc8df0be Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期一, 10 九月 2018 10:23:35 +0800 Subject: [PATCH] 3245 【后端】开服限时活动定制; 增加设置开服是星期几的GM命令: SetOpenServerWeekday --- ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py | 135 +++++++++++++++++++++++++++++++++----------- 1 files changed, 100 insertions(+), 35 deletions(-) diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py index 0298efb..c003942 100644 --- a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py +++ b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py @@ -40,6 +40,7 @@ import PlayerFamilySWRH import GameWorldBoss import PlayerFairyCeremony +import GameWorldProcess import ChPyNetSendPack import NetPackCommon @@ -532,32 +533,52 @@ curTime = int(time.time()) curDateStr = GameWorld.ChangeTimeNumToStr(curTime, ChConfig.TYPE_Time_YmdFormat) # 当天日期 - GameWorld.Log("加载本日日常活动信息: %s, weekDay=%s,openServerDay=%s" % (curDateStr, weekDay, openServerDay)) + openServerWeekday = GameWorldProcess.GetOpenServerWeekday() # 服务器开服时是星期几 + GameWorld.Log("加载本日日常活动信息: %s, 当前星期%s,开服第%s天,开服是星期%s" % (curDateStr, weekDay, openServerDay, openServerWeekday)) + + customDailyIDList = [] + dailyTimeInfoList = [] + customIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("DailyActionCustom", openServerWeekday, openServerDay) + if customIpyDataList: + customIDList = [] + for customIpyData in customIpyDataList: + dataID = customIpyData.GetID() + dailyID = customIpyData.GetDailyID() + if dailyID not in customDailyIDList: + customDailyIDList.append(dailyID) + dailyTimeInfoList.append([True, customIpyData.GetOpenTimeList(), customIpyData]) + customIDList.append(dataID) + GameWorld.Log(" 本地定制日常活动条数: %s, 配置表ID列表=%s, 定制活动ID列表=%s" % (len(customIpyDataList), customIDList, customDailyIDList)) 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)) + # 是当天开服天定制活动的不处理常规活动 + if dailyID in customDailyIDList: + GameWorld.Log(" 常规活动ID配置是今天的定制活动ID,不处理!: dailyID=%s" % dailyID) continue - openTimeDict = eval(dailyIpyData.GetOpenTime()) + openTimeDict = dailyIpyData.GetOpenTimeDict() # 没有时间控制的,代表永久开放 if not openTimeDict: todayActionInfo.append([dailyID]) - GameWorld.Log(" 增加本日日常活动信息: dailyID=%s" % 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]) - notifyInfoDict = dailyIpyData.GetNotifyInfo() + GameWorld.Log(" -----------------------") + for isCustom, openTimeList, ipyData in dailyTimeInfoList: + dailyID = ipyData.GetDailyID() + notifyInfoDict = ipyData.GetNotifyInfo() openList = [] # [(时,分), ...] overList = [] # [(时,分), ...] @@ -565,7 +586,6 @@ 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) @@ -574,7 +594,7 @@ openList.append((openDateTime.hour, openDateTime.minute)) # 精确关闭时间 - overDateTime = openDateTime + datetime.timedelta(minutes=dailyIpyData.GetDuration()) + overDateTime = openDateTime + datetime.timedelta(minutes=ipyData.GetDuration()) overList.append((overDateTime.hour, overDateTime.minute)) # goon 开启状态 @@ -591,8 +611,8 @@ 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)) + 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("本日日常活动信息加载完毕!") @@ -675,8 +695,8 @@ ## ------------------------------------------------------------------------------------------------- def __GetFBStateEndTimeNotResetIDList(): key = "FBStateEndTimeNotReset" # 结束时间状态不重置为0的数据ID - FBStateEndTimeNotResetIDList = IpyGameDataPY.GetConfigEx(key) - if FBStateEndTimeNotResetIDList == None: + notResetIDList = IpyGameDataPY.GetConfigEx(key) + if notResetIDList == None: mapStateTimeDict = {} ipyDataMgr = IpyGameDataPY.IPY_Data() for i in xrange(ipyDataMgr.GetFBStateTimeCount()): @@ -684,7 +704,7 @@ dataID = fbStateTimeIpyData.GetID() dataMapID = fbStateTimeIpyData.GetDataMapID() startWeekDay, startHour, startMinute = fbStateTimeIpyData.GetStartWeekday(), fbStateTimeIpyData.GetStartHour(), fbStateTimeIpyData.GetStartMinute() - endWeekDay, endHour, endMinute = fbStateTimeIpyData.GetEndWeekday(), fbStateTimeIpyData.GetEndHour(), fbStateTimeIpyData.GetEndMinute() + endWeekDay, endHour, endMinute = startWeekDay, fbStateTimeIpyData.GetEndHour(), fbStateTimeIpyData.GetEndMinute() startTimeList, endTimeDict = mapStateTimeDict.get(dataMapID, [[], {}]) startTimeList.append([startWeekDay, startHour, startMinute]) endTimeDict[dataID] = [endWeekDay, endHour, endMinute] @@ -697,42 +717,86 @@ # 结束时间属于某一条的开启时间,则不重置,具体状态由另一条决定 if endTime in startTimeList: FBStateEndTimeNotResetIDList.append(dataID) - FBStateEndTimeNotResetIDList = IpyGameDataPY.SetConfigEx(key, FBStateEndTimeNotResetIDList) - GameWorld.Log("加载副本状态结束时间不需要重置状态值的数据ID列表: %s" % FBStateEndTimeNotResetIDList) - return FBStateEndTimeNotResetIDList + 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(): + # 结束时间属于某一条的开启时间,则不重置,具体状态由另一条决定 + if endTime in startTimeList: + FBStateEndTimeNotResetCustomIDList.append(dataID) + FBStateEndTimeNotResetCustomIDList.sort() + + notResetIDList = IpyGameDataPY.SetConfigEx(key, [FBStateEndTimeNotResetIDList, FBStateEndTimeNotResetCustomIDList]) + GameWorld.Log("加载副本状态结束时间不需要重置状态值的数据ID列表:") + GameWorld.Log(" 不需要重置的常规ID: %s" % FBStateEndTimeNotResetIDList) + GameWorld.Log(" 不需要重置的定制ID: %s" % FBStateEndTimeNotResetCustomIDList) + return notResetIDList def Dispose_FBStateTime(): ## 副本状态时间表状态处理, 支持 goon作用,开关服状态不受影响,服务器重新启动会自动变更为所有时间段的状态值 - FBStateEndTimeNotResetIDList = __GetFBStateEndTimeNotResetIDList() - openServerWeek = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_ServerWeek) + 1 + 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 - GameWorld.DebugLog("副本状态时间表状态处理...openServerWeek=%s,openServerDay=%s,curWeekDay=%s,curHour=%s,curMinute=%s,FBStateEndTimeNotResetIDList=%s" - % (openServerWeek, openServerDay, curWeekDay, curHour, curMinute, FBStateEndTimeNotResetIDList)) + 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() ipyDataMgr = IpyGameDataPY.IPY_Data() + + customMapIDList = [] + fbStateTimeInfoList = [] + customIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("FBStateTimeCustom", openServerWeekday, openServerDay) + if customIpyDataList: + customIDList = [] + for customIpyData in customIpyDataList: + dataID = customIpyData.GetID() + dataMapID = customIpyData.GetDataMapID() + if dataMapID not in customMapIDList: + customMapIDList.append(dataMapID) + isCustom, startWeekDay, endWeekDay = True, curWeekDay, curWeekDay + fbStateTimeInfoList.append([isCustom, startWeekDay, endWeekDay, customIpyData]) + customIDList.append(dataID) + GameWorld.DebugLog(" 定制副本活动条数: %s, 配置表ID列表=%s" % (len(customIpyDataList), customIDList)) + 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)) + # 是当天开服天定制活动的不处理常规活动 + if dataMapID in customMapIDList: continue + isCustom, startWeekDay, endWeekDay = False, fbStateTimeIpyData.GetStartWeekday(), fbStateTimeIpyData.GetStartWeekday() + fbStateTimeInfoList.append([isCustom, startWeekDay, endWeekDay, fbStateTimeIpyData]) - if openServerDay <= openServerDayLimit: - #GameWorld.DebugLog(" 不是副本状态开启天数: i=%s,dataMapID=%s,openServerDayLimit=%s" % (i, dataMapID, openServerDayLimit)) - continue + for isCustom, startWeekDay, endWeekDay, ipyData in fbStateTimeInfoList: + dataID = ipyData.GetID() + dataMapID = ipyData.GetDataMapID() - startWeekDay, startHour, startMinute = fbStateTimeIpyData.GetStartWeekday(), fbStateTimeIpyData.GetStartHour(), fbStateTimeIpyData.GetStartMinute() - endWeekDay, endHour, endMinute = fbStateTimeIpyData.GetEndWeekday(), fbStateTimeIpyData.GetEndHour(), fbStateTimeIpyData.GetEndMinute() + startHour, startMinute = ipyData.GetStartHour(), ipyData.GetStartMinute() + endHour, endMinute = ipyData.GetEndHour(), ipyData.GetEndMinute() # 星期配置0代表每天 if startWeekDay == 0: startWeekDay = curWeekDay @@ -743,7 +807,7 @@ #GameWorld.DebugLog(" ID=%s,dataMapID=%s,curTimeWHM=%s,startTimeWHM=%s,endTimeWHM=%s" % (dataID, dataMapID, curTimeWHM, startTimeWHM, endTimeWHM)) # 全服广播key分钟差值对比时间为开始时间, 支持正负时间差 - notifyInfoDict = fbStateTimeIpyData.GetNotifyInfoDict() + notifyInfoDict = ipyData.GetNotifyInfoDict() if notifyInfoDict: startDateTime = curDateTime + datetime.timedelta(days=(startWeekDay - curWeekDay)) startDateTime = datetime.datetime(startDateTime.year, startDateTime.month, startDateTime.day, startHour, startMinute, 0) @@ -763,7 +827,8 @@ #GameWorld.DebugLog(" 当前是开始时间!") # 是结束时间 elif curTimeWHM == endTimeWHM: - isReset = dataID not in FBStateEndTimeNotResetIDList + 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: @@ -777,8 +842,8 @@ updCanEnter = 0 updStateValue = 0 elif isUpdate: - updCanEnter = fbStateTimeIpyData.GetCanEnter() - updStateValue = fbStateTimeIpyData.GetStateValue() + updCanEnter = ipyData.GetCanEnter() + updStateValue = ipyData.GetStateValue() else: #GameWorld.DebugLog(" 当前时间副本状态不变!") continue -- Gitblit v1.8.0