| | |
| | | #删除所有的任务发布
|
| | | missionPubManager = GameWorld.GetGameWorld().GetDBMissionPubManager()
|
| | | missionPubManager.Clear()
|
| | | #仙盟
|
| | | PlayerFamily.FamilyOnDay()
|
| | |
|
| | | for i in xrange(playerManager.GetPlayerCount()):
|
| | | curPlayer = playerManager.GetPlayerByIndex(i)
|
| | |
| | | continue
|
| | |
|
| | | PlayerOnDay(curPlayer)
|
| | | PlayerOnDayEx(curPlayer)
|
| | | |
| | | DoLogic_OnDayEx(tick)
|
| | | |
| | | PlayerBillboard.OnDay()
|
| | | PlayerViewCache.OnDay()
|
| | | return
|
| | |
|
| | | def DoLogic_OnDayEx(tick):
|
| | | GameWorld.Log("MapServer -> OnDayEx!")
|
| | | |
| | | |
| | | PlayerMail.OnDayEx()
|
| | | PlayerControl.RemoveTimeoutLeaveServerPlayerInfo(tick)
|
| | | PlayerBillboard.OnDay()
|
| | | PlayerViewCache.OnDay()
|
| | | return
|
| | |
|
| | | def DoLogic_OnHour(tick):
|
| | |
| | | continue
|
| | |
|
| | | PlayerOnWeek(curPlayer)
|
| | | PlayerOnWeekEx(curPlayer)
|
| | |
|
| | | #副本OnWeek事件响应
|
| | | FBLogic.OnWeek(tick)
|
| | |
| | | continue
|
| | |
|
| | | PlayerOnMonth(curPlayer)
|
| | | PlayerOnMonthEx(curPlayer)
|
| | |
|
| | | return
|
| | |
|
| | |
| | | GameWorld.Log("PlayerOnDay! ondayValue=%s" % (ondayValue), playerID)
|
| | |
|
| | | __DoPlayerOnDay(curPlayer, ShareDefine.Def_OnEventType)
|
| | | |
| | | GameWorld.Log("PlayerOnDay OK!", playerID)
|
| | | return
|
| | | |
| | | def PlayerOnDayEx(curPlayer):
|
| | | #记录玩家字典值,待初始化后执行
|
| | | if not curPlayer.GetGameServerInitOK():
|
| | | GameServerRefresh.Set_PlayerGameServerInitOK_OnDayEx(curPlayer , 1)
|
| | | return
|
| | | |
| | | ondayValue = __Get_Can_OnDayEx(curPlayer)
|
| | | if not ondayValue:
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OnDayEx, ondayValue)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.Log("PlayerOnDayEx! ondayValue=%s" % (ondayValue), playerID)
|
| | | |
| | | __DoPlayerOnDay(curPlayer, ShareDefine.Def_OnEventTypeEx)
|
| | |
|
| | | GameWorld.Log("PlayerOnDayEx OK!", playerID)
|
| | | GameWorld.Log("PlayerOnDay OK!", playerID)
|
| | | return
|
| | |
|
| | | def __DoPlayerOnDay(curPlayer, onEventType):
|
| | |
| | | GameWorld.Log("PlayerOnWeek! onWeekValue=%s" % (onWeekValue), playerID)
|
| | |
|
| | | __DoPlayerOnWeek(curPlayer, ShareDefine.Def_OnEventType)
|
| | | |
| | | GameWorld.Log("PlayerOnWeek OK!", playerID)
|
| | | return
|
| | |
|
| | | def PlayerOnWeekEx(curPlayer):
|
| | | #记录玩家字典值,待初始化后执行
|
| | | if not curPlayer.GetGameServerInitOK():
|
| | | GameServerRefresh.Set_PlayerGameServerInitOK_OnWeekEx(curPlayer , 1)
|
| | | return
|
| | | |
| | | onWeekValue = __Get_Can_OnWeekEx(curPlayer)
|
| | | if not onWeekValue:
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OnWeekEx, onWeekValue)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.Log("PlayerOnWeekEx! onWeekValue=%s" % (onWeekValue), playerID)
|
| | | |
| | | __DoPlayerOnWeek(curPlayer, ShareDefine.Def_OnEventTypeEx)
|
| | |
|
| | | GameWorld.Log("PlayerOnWeekEx OK!", playerID)
|
| | | GameWorld.Log("PlayerOnWeek OK!", playerID)
|
| | | return
|
| | |
|
| | | def __DoPlayerOnWeek(curPlayer, onEventType):
|
| | |
| | | GameWorld.Log("PlayerOnMonth! onMonthValue=%s" % (onMonthValue), playerID)
|
| | |
|
| | | __DoPlayerOnMonth(curPlayer, ShareDefine.Def_OnEventType)
|
| | | |
| | | GameWorld.Log("PlayerOnMonth OK!", playerID)
|
| | | return
|
| | |
|
| | | def PlayerOnMonthEx(curPlayer):
|
| | | #记录玩家字典值,待初始化后执行
|
| | | if not curPlayer.GetGameServerInitOK():
|
| | | GameServerRefresh.Set_PlayerGameServerInitOK_OnMonthEx(curPlayer , 1)
|
| | | return
|
| | | |
| | | onMonthValue = __Get_Can_OnMonthEx(curPlayer)
|
| | | if not onMonthValue:
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_OnMonthEx, onMonthValue)
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | GameWorld.Log("PlayerOnMonthEx! onMonthValue=%s" % (onMonthValue), playerID)
|
| | | |
| | | __DoPlayerOnMonth(curPlayer, ShareDefine.Def_OnEventTypeEx)
|
| | |
|
| | | GameWorld.Log("PlayerOnMonthEx OK!", playerID)
|
| | | GameWorld.Log("PlayerOnMonth OK!", playerID)
|
| | | return
|
| | |
|
| | | def __DoPlayerOnMonth(curPlayer, onEventType):
|
| | |
| | | PlayerOnDay(curPlayer)
|
| | |
|
| | | #OnDayEx事件
|
| | | if __Get_Can_OnDayEx(curPlayer):
|
| | | PlayerOnDayEx(curPlayer)
|
| | | #if __Get_Can_OnDayEx(curPlayer):
|
| | | # PlayerOnDayEx(curPlayer)
|
| | |
|
| | | #OnWeek事件
|
| | | if __Get_Can_OnWeek(curPlayer):
|
| | | PlayerOnWeek(curPlayer)
|
| | |
|
| | | #OnWeekEx事件
|
| | | if __Get_Can_OnWeekEx(curPlayer):
|
| | | PlayerOnWeekEx(curPlayer)
|
| | | #if __Get_Can_OnWeekEx(curPlayer):
|
| | | # PlayerOnWeekEx(curPlayer)
|
| | |
|
| | | #OnMonth事件
|
| | | if __Get_Can_OnMonth(curPlayer):
|
| | | PlayerOnMonth(curPlayer)
|
| | |
|
| | | #OnMonthEx事件
|
| | | if __Get_Can_OnMonthEx(curPlayer):
|
| | | PlayerOnMonthEx(curPlayer)
|
| | | #if __Get_Can_OnMonthEx(curPlayer):
|
| | | # PlayerOnMonthEx(curPlayer)
|
| | |
|
| | | #OnYear事件
|
| | | if __Get_Can_OnYear(curPlayer):
|
| | |
| | | return dateTime_Day
|
| | | return 0
|
| | |
|
| | | def __Get_Can_OnDayEx(curPlayer):
|
| | | '''判断可否凌晨X点过天
|
| | | @return: 0-不可; >0-可以, 且代表的是过天需记录的值
|
| | | '''
|
| | | curDateTime = GameWorld.GetCurrentTime()
|
| | | |
| | | # 上次过天记录格式: 年月日, 如20171027
|
| | | lastOndayEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OnDayEx)
|
| | | #GameWorld.DebugLog("__Get_Can_OnDayEx lastOndayEx=%s" % (lastOndayEx))
|
| | | if lastOndayEx:
|
| | | lastOndayEx_Year = lastOndayEx / 10000
|
| | | lastOndayEx_Month = lastOndayEx % 10000 / 100
|
| | | lastOndayEx_Day = lastOndayEx % 100
|
| | | #GameWorld.DebugLog("lastOndayEx_Year=%s,lastOndayEx_Month=%s,lastOndayEx_Day=%s" % (lastOndayEx_Year, lastOndayEx_Month, lastOndayEx_Day))
|
| | | |
| | | # 上次过天的日期0点
|
| | | lastDatetime = datetime.datetime(lastOndayEx_Year, lastOndayEx_Month, lastOndayEx_Day, 0, 0, 0)
|
| | | passTime = curDateTime - lastDatetime
|
| | | passDays = passTime.days
|
| | | passSeconds = passTime.seconds
|
| | | |
| | | # 如果时间差没有超过1天,代表还未过天
|
| | | if passDays == 0:
|
| | | #GameWorld.DebugLog("如果时间差没有超过1天,代表还未过天, passDays=%s" % passDays)
|
| | | return 0
|
| | | # 等于1天的, 时间差需 >= X时才可过天, 即 X * 3600 秒
|
| | | if passDays == 1 and passSeconds < ShareDefine.Def_OnEventHour * 3600:
|
| | | #GameWorld.DebugLog("等于1天的, 时间差需 >= X时才可过天, 即 X * 3600 秒, passSeconds=%s" % passSeconds)
|
| | | return 0
|
| | | #if passDays < 0:
|
| | | # GameWorld.DebugLog("时间天差小于0,一般为异常情况,只有时间往回调才回出现!默认允许过天,passDays=%s" % passDays)
|
| | | # 大于1天的无论什么时间点都可以过天
|
| | | |
| | | if curDateTime.hour < ShareDefine.Def_OnEventHour:
|
| | | curDateTime = curDateTime - datetime.timedelta(days=1)
|
| | | #GameWorld.Log("OnDayEx 特殊X点之前过天的,代表天差大于1天的时间过天,这时候的过天值需设置为昨天 %s" % curDateTime)
|
| | | |
| | | dateTime_Day = curDateTime.day
|
| | | dateTime_Month = curDateTime.month
|
| | | dateTime_Year = curDateTime.year
|
| | | #GameWorld.DebugLog("可以过天")
|
| | | return dateTime_Year * 10000 + dateTime_Month * 100 + dateTime_Day
|
| | |
|
| | | ## 检查玩家是否可以OnWeek
|
| | | # @param curPlayer 当前玩家
|
| | | # @param curMission 当前任务
|
| | |
| | | if (dateTime_Week != player_Week):
|
| | | return dateTime_Week
|
| | | return 0
|
| | |
|
| | | def __Get_Can_OnWeekEx(curPlayer):
|
| | | '''判断可否凌晨X点过周
|
| | | @return: 0-不可; >0-可以, 且代表的是过周需记录的值
|
| | | '''
|
| | | curDateTime = GameWorld.GetCurrentTime()
|
| | | isocalendar = datetime.datetime.isocalendar(curDateTime)
|
| | | dateTime_year, dateTime_week, dateTime_day = isocalendar
|
| | | |
| | | # 上次过周记录格式: 年周, 如201752
|
| | | lastOnWeekEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OnWeekEx)
|
| | | #GameWorld.DebugLog("__Get_Can_OnWeekEx lastOnWeekEx=%s,dateTime_year=%s,week=%s,day=%s" |
| | | # % (lastOnWeekEx, dateTime_year, dateTime_week, dateTime_day))
|
| | | if lastOnWeekEx:
|
| | | lastOnWeekEx_Year = lastOnWeekEx / 100
|
| | | lastOnWeekEx_Week = lastOnWeekEx % 100
|
| | | # 本周已经过周过
|
| | | if dateTime_year == lastOnWeekEx_Year and dateTime_week == lastOnWeekEx_Week:
|
| | | #GameWorld.DebugLog("本周已经过周过")
|
| | | return 0
|
| | | |
| | | # 当前天为每周第一天的时候,需判断周差为1时当前时间点是否超过5点
|
| | | if dateTime_day == 1:
|
| | | preWeekDateTime = curDateTime - datetime.timedelta(days=7) # 上一周的datetime(即周差为1)
|
| | | preWeek_year, preWeek_week, preWeek_day = datetime.datetime.isocalendar(preWeekDateTime)
|
| | | |
| | | # 上次过周的刚好是周差1, 则需判断当前时间点是否超过X时
|
| | | if preWeek_year == lastOnWeekEx_Year and preWeek_week == lastOnWeekEx_Week:
|
| | | if curDateTime.hour < ShareDefine.Def_OnEventHour:
|
| | | #GameWorld.DebugLog("本周第一天,未到达过周时间点, hour=%s" % curDateTime.hour)
|
| | | return 0
|
| | | |
| | | # 周差不为1的时候,则无论什么时间点均可过周
|
| | | else:
|
| | | #GameWorld.DebugLog("周差不为1的时候,则无论什么时间点均可过周, 可以过周")
|
| | | pass
|
| | | |
| | | # 不是每周第一天的时候,则无论什么时间点均可过周
|
| | | else:
|
| | | #GameWorld.DebugLog("不是每周第一天的时候,则无论什么时间点均可过周, 可以过周")
|
| | | pass
|
| | | |
| | | if dateTime_day == 1 and curDateTime.hour < ShareDefine.Def_OnEventHour:
|
| | | onWeekDateTime = curDateTime - datetime.timedelta(days=7) # 上一周的datetime(即周差为1)
|
| | | dateTime_year, dateTime_week, dateTime_day = datetime.datetime.isocalendar(onWeekDateTime)
|
| | | #GameWorld.Log("OnWeekEx 周一特殊X点之前过天的,代表周差大于1天的周一过周,这时候的过周值需设置为上周 %s" % onWeekDateTime)
|
| | | |
| | | #GameWorld.DebugLog("可以过周")
|
| | | return dateTime_year * 100 + dateTime_week
|
| | |
|
| | | ## 检查玩家是否可以OnMonth
|
| | | # @param curPlayer 当前玩家
|
| | |
| | | if (dateTime_Month != player_Month or dateTime_Year != player_Year):
|
| | | return dateTime_Month
|
| | | return 0
|
| | |
|
| | | def __Get_Can_OnMonthEx(curPlayer):
|
| | | '''判断可否凌晨X点过月
|
| | | @return: 0-不可; >0-可以, 且代表的是过月需记录的值
|
| | | '''
|
| | | curDateTime = GameWorld.GetCurrentTime()
|
| | | dateTime_day = curDateTime.day
|
| | | dateTime_month = curDateTime.month
|
| | | dateTime_year = curDateTime.year
|
| | | |
| | | # 上次过月记录格式: 年月, 如201712
|
| | | lastOnMonthEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_OnMonthEx)
|
| | | #GameWorld.DebugLog("__Get_Can_OnMonthEx lastOnMonthEx=%s,dateTime_year=%s,dateTime_month=%s" |
| | | # % (lastOnMonthEx, dateTime_year, dateTime_month))
|
| | | if lastOnMonthEx:
|
| | | lastOnMonthEx_Year = lastOnMonthEx / 100
|
| | | lastOnMonthEx_Month = lastOnMonthEx % 100
|
| | | # 本月已经过月过
|
| | | if dateTime_year == lastOnMonthEx_Year and dateTime_month == lastOnMonthEx_Month:
|
| | | #GameWorld.DebugLog("本月已经过月过")
|
| | | return 0
|
| | | |
| | | # 当前天为每月第一天的时候,需判断月差为1时当前时间点是否超过5点
|
| | | if dateTime_day == 1:
|
| | | preMonth_month = 12 if dateTime_month == 1 else dateTime_month - 1 # 上一月
|
| | | preMonth_year = dateTime_year if preMonth_month != 12 else dateTime_year - 1 # 上一月所属年
|
| | | |
| | | # 上次过月的刚好是月差1, 则需判断当前时间点是否超过X时
|
| | | if preMonth_year == lastOnMonthEx_Year and preMonth_month == lastOnMonthEx_Month:
|
| | | if curDateTime.hour < ShareDefine.Def_OnEventHour:
|
| | | #GameWorld.DebugLog("本月第一天,未到达过月时间点, hour=%s" % curDateTime.hour)
|
| | | return 0
|
| | | |
| | | # 月差不为1的时候,则无论什么时间点均可过月
|
| | | else:
|
| | | #GameWorld.DebugLog("月差不为1的时候,则无论什么时间点均可过月, 可以过月")
|
| | | pass
|
| | | |
| | | # 不是每月第一天的时候,则无论什么时间点均可过月
|
| | | else:
|
| | | #GameWorld.DebugLog("不是每月第一天的时候,则无论什么时间点均可过月, 可以过月")
|
| | | pass
|
| | | |
| | | if dateTime_day == 1 and curDateTime.hour < ShareDefine.Def_OnEventHour:
|
| | | dateTime_month = 12 if dateTime_month == 1 else dateTime_month - 1 # 上一月
|
| | | dateTime_year = dateTime_year if dateTime_month != 12 else dateTime_year - 1 # 上一月所属年
|
| | | #GameWorld.Log("OnMonthEx 月1号特殊X点之前过天的,代表月差大于1的月1号过月,这时候的过月值需设置为上月。%d%02d" % (dateTime_year, dateTime_month))
|
| | | |
| | | #GameWorld.DebugLog("可以过月")
|
| | | return dateTime_year * 100 + dateTime_month
|
| | |
|
| | | ## 检查玩家是否可以OnYear
|
| | | # @param curPlayer 当前玩家
|