| | |
| | | endDateStr = "%d-%d-%d" % (endDateTime.year, endDateTime.month, endDateTime.day)
|
| | | return startDateStr, endDateStr
|
| | |
|
| | | def GetActRelateFuncInfo(curPlayer, actName, actInfo, playerActID):
|
| | | ## 获取活动关联玩家功能开启信息
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
| | | if not cfgID:
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameDataNotLog(actName, cfgID)
|
| | | if not ipyData:
|
| | | return
|
| | | if not hasattr(ipyData, "GetRelateFuncID"):
|
| | | return
|
| | | relateFuncID = ipyData.GetRelateFuncID()
|
| | | if not relateFuncID:
|
| | | return
|
| | | funcActDays = ipyData.GetFuncActDays()
|
| | | funcLoop = ipyData.GetFuncLoop()
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | isInAct = False # 是否活动中
|
| | | actID = playerActID # 玩家实际的活动ID
|
| | | if not actInfo.get(ShareDefine.ActKey_State, 0):
|
| | | #DebugLog("关联功能非活动中默认不开活动! actName=%s,cfgID=%s" % (actName, cfgID), playerID)
|
| | | return isInAct, actID
|
| | | isOpen = GetDictValueByBit(curPlayer, ChConfig.Def_Player_Dict_GameFuncFirstTouch, relateFuncID, True)
|
| | | if not isOpen:
|
| | | DebugLog("关联功能未开启默认不开活动! actName=%s,cfgID=%s,relateFuncID=%s" % (actName, cfgID, relateFuncID), playerID)
|
| | | return isInAct, actID
|
| | | |
| | | isDayRest = 0 if not hasattr(ipyData, "GetIsDayReset") else ipyData.GetIsDayReset()
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum)
|
| | | serverTime = GetCurrentTime()
|
| | | newAct = False
|
| | | |
| | | if isDayRest:
|
| | | newAct = True
|
| | | DebugLog("关联功能活动,每日重置的活动! actName=%s,cfgID=%s,relateFuncID=%s" % (actName, cfgID, relateFuncID), playerID)
|
| | | |
| | | elif not playerActID:
|
| | | newAct = True
|
| | | DebugLog("关联功能活动,玩家首次开启活动! actName=%s,cfgID=%s,relateFuncID=%s" % (actName, cfgID, relateFuncID), playerID)
|
| | | |
| | | # 有活动期限的
|
| | | elif funcActDays:
|
| | | startDayDate, endDayDate = GetActRelateFuncDate(ipyData, playerActID)
|
| | | if startDayDate <= serverTime < endDayDate:
|
| | | isInAct = True
|
| | | DebugLog("关联功能活动,正常活动中! actName=%s,cfgID=%s,%s~%s" % (actName, cfgID, startDayDate, endDayDate), playerID)
|
| | | elif serverTime >= endDayDate:
|
| | | if funcLoop:
|
| | | newAct = True
|
| | | DebugLog("关联功能活动,活动结束,重新开始循环新活动! actName=%s,cfgID=%s,%s~%s" % (actName, cfgID, startDayDate, endDayDate), playerID)
|
| | | else:
|
| | | DebugLog("关联功能活动,活动结束,不循环! actName=%s,cfgID=%s,%s~%s" % (actName, cfgID, startDayDate, endDayDate), playerID) |
| | | else:
|
| | | DebugLog("关联功能活动,玩家活动ID超过当前时间,可能是调时间引起,重新开始循环新活动! actName=%s,cfgID=%s,%s~%s" % (actName, cfgID, startDayDate, endDayDate), playerID)
|
| | | newAct = True
|
| | | |
| | | # 永久的,默认活动中
|
| | | else:
|
| | | isInAct = True
|
| | | DebugLog("关联功能活动,永久开放的活动! actName=%s,cfgID=%s,relateFuncID=%s" % (actName, cfgID, relateFuncID), playerID)
|
| | | |
| | | if newAct:
|
| | | isInAct = True
|
| | | resetType = 0 if not hasattr(ipyData, "GetResetType") else ipyData.GetResetType() # 重置类型,0-0点重置;1-5点重置 |
| | | startDateStr = "%d-%d-%d" % (serverTime.year, serverTime.month, serverTime.day)
|
| | | if resetType == 1:
|
| | | startDayDate = datetime.datetime.strptime("%s 05:00:00" % (startDateStr), ChConfig.TYPE_Time_Format) |
| | | else:
|
| | | startDayDate = datetime.datetime.strptime("%s 00:00:00" % (startDateStr), ChConfig.TYPE_Time_Format)
|
| | | actID = int(time.mktime(startDayDate.timetuple()))
|
| | | |
| | | DebugLog("关联功能活动! actName=%s,cfgID=%s,actNum=%s,relateFuncID=%s,playerActID=%s,actID=%s,isInAct=%s" |
| | | % (actName, cfgID, actNum, relateFuncID, playerActID, actID, isInAct), playerID)
|
| | | return isInAct, actID
|
| | |
|
| | | def GetActRelateFuncDate(ipyData, startTime, returnYmdStr=False):
|
| | | funcActDays = ipyData.GetFuncActDays()
|
| | | 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 isDayRest:
|
| | | funcActDays = 1
|
| | | |
| | | startDayDate = ChangeTimeNumToDatetime(startTime, ChConfig.TYPE_Time_Format)
|
| | | if funcActDays:
|
| | | startDayStr = str(startDayDate)[:10]
|
| | | if resetType == 1:
|
| | | endDayDate = datetime.datetime.strptime("%s 04:59:59" % (startDayStr), ChConfig.TYPE_Time_Format) + datetime.timedelta(days=funcActDays)
|
| | | elif resetType == 2: |
| | | endDayDate = datetime.datetime.strptime("%s 23:59:59" % (startDayStr), ChConfig.TYPE_Time_Format) + datetime.timedelta(days=(funcActDays-1))
|
| | | else:
|
| | | endDayDate = datetime.datetime.strptime("%s 23:59:59" % (startDayStr), ChConfig.TYPE_Time_Format) + datetime.timedelta(days=(funcActDays-1))
|
| | | else:
|
| | | endDateStr = ipyData.GetEndDate()
|
| | | if resetType == 1:
|
| | | endDayDate = datetime.datetime.strptime("%s 04:59:59" % (endDateStr), ChConfig.TYPE_Time_Format)
|
| | | elif resetType == 2: |
| | | endDayDate = datetime.datetime.strptime("%s 23:59:59" % (endDateStr), ChConfig.TYPE_Time_Format)
|
| | | else:
|
| | | endDayDate = datetime.datetime.strptime("%s 23:59:59" % (endDateStr), ChConfig.TYPE_Time_Format)
|
| | | |
| | | if returnYmdStr:
|
| | | startDateStr = "%d-%d-%d" % (startDayDate.year, startDayDate.month, startDayDate.day)
|
| | | endDateStr = "%d-%d-%d" % (endDayDate.year, endDayDate.month, endDayDate.day)
|
| | | return startDateStr, endDateStr
|
| | | return startDayDate, endDayDate
|
| | |
|
| | | ##获得服务器系统时间
|
| | | # @param 无
|
| | | # @return 返回值. 时间Data格式
|