From d9f13c5e9a02f31cad2f58357acd3140809e88c1 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期二, 11 九月 2018 19:57:27 +0800
Subject: [PATCH] fix:3477【后端】【1.0.15】【1.1.0】娲皇遗迹新增Vip特权:副本购买次数

---
 ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py |  171 ++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 121 insertions(+), 50 deletions(-)

diff --git a/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py b/ServerPython/CoreServerGroup/GameServer/Script/GameWorldLogic/GameWorldActionControl.py
index b33131c..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
 
@@ -71,11 +72,7 @@
         ipyData = operationActionDict[ShareDefine.OperationActionName_ExpRate][0]
         if ipyData:
             Sync_OperationAction_ExpRate(ipyData, curPlayer)
-    # BOSS复活活动进行中
-    if ShareDefine.OperationActionName_BossReborn in operationActionDict:
-        ipyData = operationActionDict[ShareDefine.OperationActionName_BossReborn][0]
-        if ipyData:
-            GameWorldBoss.Sync_OperationAction_BossReborn(ipyData, curPlayer)
+
     # 仙界盛典活动进行中
     if ShareDefine.OperationActionName_FairyCeremony in operationActionDict:
         ipyData = operationActionDict[ShareDefine.OperationActionName_FairyCeremony][0]
@@ -327,7 +324,11 @@
                              ShareDefine.ActKey_ShopTypeList:todayShopType}
     # Boss复活活动
     elif actName == ShareDefine.OperationActionName_BossReborn:
-        mapServerInfoDict = {ShareDefine.ActKey_ID:actID}
+        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()
@@ -347,7 +348,9 @@
     # 多倍修行点活动
     if actName == ShareDefine.OperationActionName_RealmPoint:
         mapServerInfoDict = {ShareDefine.ActKey_LVLimit:ipyData.GetLVLimit(),
-                             ShareDefine.ActKey_RealmPointMulti:ipyData.GetMultiple()}
+                             ShareDefine.ActKey_RealmPointMulti:ipyData.GetMultiple(),
+                             ShareDefine.ActKey_StartDate:ipyData.GetStartDate(),
+                             ShareDefine.ActKey_EndDate:ipyData.GetEndDate(),}
     return mapServerInfoDict
 
 def Dispose_OperationActionState(reloadRefresh=False):
@@ -397,7 +400,8 @@
                 PlayerControl.WorldNotify(0, notifyKey, paramList)
                 
         dictName = ChConfig.Def_WorldKey_OperationActionState % actName
-        if not isReload and gameWorld.GetDictByKey(dictName) == state:
+        preState = gameWorld.GetDictByKey(dictName)
+        if not isReload and preState == state:
             #已经是这个状态了
             continue
         #更新字典值
@@ -408,6 +412,11 @@
         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复活点
@@ -416,10 +425,7 @@
                 #重置仙界盛典
                 PlayerFairyCeremony.ResetFairyCeremony()
             
-            if actName in ShareDefine.NeedWorldLVOperationActNameList:
-                #记录开启时世界等级
-                worldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
-                PlayerDBGSEvent.SetDBGSTrig_ByKey(PlayerDBGSEvent.Def_OActWorldLV % actName, worldLV)
+            
                 
         if state == 1 and actName in ShareDefine.NeedWorldLVOperationActNameList:
             actWorldLV = PlayerDBGSEvent.GetDBGSTrig_ByKey(PlayerDBGSEvent.Def_OActWorldLV % actName)
@@ -434,11 +440,12 @@
                 pass
         elif actName == ShareDefine.OperationActionName_BossReborn:
             if isReload and ipyData:
-                GameWorldBoss.Sync_OperationAction_BossReborn(ipyData)
+                GameWorldBoss.SetBossRebornNeedPoint(True)
+
         elif actName == ShareDefine.OperationActionName_FairyCeremony:
             if isReload and ipyData:
                 PlayerFairyCeremony.Sync_OperationAction_FairyCeremony(ipyData)
-            if state == 0:
+            if preState != state and state == 0:
                 PlayerFairyCeremony.OnFairyCeremonyEnd()
         elif actName == ShareDefine.OperationActionName_RealmPoint:
             if isReload and ipyData:
@@ -449,7 +456,7 @@
         sendMapServerMsgDict[ShareDefine.ActKey_State] = state
         GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_OperationActionInfo % actName, sendMapServerMsgDict)
         
-        GameWorld.Log("运营活动变更: actName=%s,state=%s,dictName=%s, %s" % (actName, state, dictName, 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):
@@ -526,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 = [] # [(时,分), ...]
@@ -559,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)
             
@@ -568,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 开启状态
@@ -585,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("本日日常活动信息加载完毕!")
@@ -669,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()):
@@ -678,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]
@@ -691,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
@@ -737,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)
@@ -757,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:
@@ -771,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