예제 #1
0
        private int ComputeCurrentSeasonID(DateTime now, int CurrentSeasonID)
        {
            int result;

            if (!this.CheckOpenState(now))
            {
                result = 0;
            }
            else if (!KuaFuServerManager.IsGongNengOpened(114))
            {
                result = 0;
            }
            else
            {
                lock (this.MutexConfig)
                {
                    DateTime OpenTime = ZorkBattleUtils.GetSeasonDateTm(CurrentSeasonID);
                    if (OpenTime == DateTime.MinValue)
                    {
                        TimeSpan start = TimeSpan.MaxValue;
                        foreach (ZorkBattleSceneInfo item in this.SceneDataDict.Values)
                        {
                            for (int i = 0; i < item.TimePoints.Count - 1; i += 2)
                            {
                                TimeSpan startTm = item.TimePoints[i];
                                if (startTm.Days == 0)
                                {
                                    startTm += new TimeSpan(7, 0, 0, 0);
                                }
                                if (startTm < start)
                                {
                                    start = startTm;
                                }
                            }
                        }
                        start -= new TimeSpan(1, 0, 0, 0);
                        int spanday = TimeUtil.NowDateTime().DayOfWeek - DayOfWeek.Monday;
                        spanday = ((spanday >= 0) ? (-spanday) : (-(7 + spanday)));
                        TimeSpan nowfromMonday = new TimeSpan(Math.Abs(spanday), now.Hour, now.Minute, now.Second);
                        if (nowfromMonday < start)
                        {
                            OpenTime = TimeUtil.NowDateTime().AddDays((double)spanday);
                        }
                        else
                        {
                            OpenTime = TimeUtil.NowDateTime().AddDays((double)(spanday + 7));
                        }
                    }
                    else if ((now - OpenTime).Days >= this.SeasonWeeks * 7)
                    {
                        int spanday = TimeUtil.NowDateTime().DayOfWeek - DayOfWeek.Monday;
                        spanday  = ((spanday >= 0) ? (-spanday) : (-(7 + spanday)));
                        OpenTime = TimeUtil.NowDateTime().AddDays((double)spanday);
                    }
                    result = ZorkBattleUtils.MakeSeason(OpenTime);
                }
            }
            return(result);
        }
예제 #2
0
        private int GetCurrentRoundByTime(DateTime now, int CurrentSeasonID)
        {
            int result;

            if (!this.CheckOpenState(now))
            {
                result = 0;
            }
            else if (!KuaFuServerManager.IsGongNengOpened(114))
            {
                result = 0;
            }
            else
            {
                lock (this.MutexConfig)
                {
                    ZorkBattleSceneInfo sceneConfig = this.SceneDataDict.Values.FirstOrDefault <ZorkBattleSceneInfo>();
                    if (null == sceneConfig)
                    {
                        result = 0;
                    }
                    else
                    {
                        DateTime curSeasonTime = ZorkBattleUtils.GetSeasonDateTm(CurrentSeasonID);
                        if (now < curSeasonTime)
                        {
                            result = 1;
                        }
                        else
                        {
                            TimeSpan fromMonday = new TimeSpan((int)now.DayOfWeek, now.Hour, now.Minute, now.Second);
                            if (fromMonday.Days == 0)
                            {
                                fromMonday += new TimeSpan(7, 0, 0, 0);
                            }
                            int weekRound = 0;
                            for (int i = 0; i < sceneConfig.TimePoints.Count - 1; i += 2)
                            {
                                TimeSpan myTmp = sceneConfig.TimePoints[i + 1];
                                if (myTmp.Days == 0)
                                {
                                    myTmp += new TimeSpan(7, 0, 0, 0);
                                }
                                if (fromMonday > myTmp)
                                {
                                    weekRound++;
                                }
                            }
                            int week  = (now - curSeasonTime).Days % (7 * this.SeasonWeeks) / 7;
                            int round = week * sceneConfig.TimePoints.Count / 2 + weekRound + 1;
                            result = Math.Min(round, sceneConfig.SeasonFightRound + 1);
                        }
                    }
                }
            }
            return(result);
        }