Exemplo n.º 1
0
        private bool IsInWeekRangeActTimes(DateTime time)
        {
            _CoupleArenaWarTimePoint first = this._WarTimePointList.First <_CoupleArenaWarTimePoint>();
            _CoupleArenaWarTimePoint last  = this._WarTimePointList.Last <_CoupleArenaWarTimePoint>();
            int wd = TimeUtil.GetWeekDay1To7(time);

            return(((wd == first.Weekday && time.TimeOfDay.Ticks > first.DayStartTicks) || wd > first.Weekday) && (wd < last.Weekday || (wd == last.Weekday && time.TimeOfDay.Ticks < last.DayEndTicks)));
        }
Exemplo n.º 2
0
        private int CurrRankWeek(DateTime time)
        {
            int currWeekDay = TimeUtil.GetWeekDay1To7(time);
            _CoupleArenaWarTimePoint first = this._WarTimePointList.First <_CoupleArenaWarTimePoint>();
            int result;

            if (currWeekDay < first.Weekday || (currWeekDay == first.Weekday && time.TimeOfDay.Ticks < first.DayStartTicks))
            {
                result = TimeUtil.MakeFirstWeekday(time.AddDays(-7.0));
            }
            else
            {
                result = TimeUtil.MakeFirstWeekday(time);
            }
            return(result);
        }
Exemplo n.º 3
0
        public void StartUp()
        {
            try
            {
                XElement xml  = null;
                string   file = "";

                file = @"Config\CoupleWar.xml";
                xml  = XElement.Load(KuaFuServerManager.GetResourcePath(file, KuaFuServerManager.ResourcePathTypes.GameRes));
                foreach (var xmlItem in xml.Elements())
                {
                    string[] fields = xmlItem.Attribute("TimePoints").Value.Split(new char[] { ',', '-', '|' });
                    for (int i = 0; i < fields.Length; i += 3)
                    {
                        var tp = new _CoupleArenaWarTimePoint();
                        tp.Weekday = Convert.ToInt32(fields[i]);
                        if (tp.Weekday < 1 || tp.Weekday > 7)
                        {
                            throw new Exception("weekday error!");
                        }
                        tp.DayStartTicks = DateTime.Parse(fields[i + 1]).TimeOfDay.Ticks;
                        tp.DayEndTicks   = DateTime.Parse(fields[i + 2]).TimeOfDay.Ticks;

                        _WarTimePointList.Add(tp);
                    }

                    _WarTimePointList.Sort((_l, _r) => { return(_l.Weekday - _r.Weekday); });

                    break;
                }

                file = @"Config\CoupleDuanWei.xml";
                xml  = XElement.Load(KuaFuServerManager.GetResourcePath(file, KuaFuServerManager.ResourcePathTypes.GameRes));
                foreach (var xmlItem in xml.Elements())
                {
                    var cfg = new _CoupleArenaDuanWeiCfg();
                    cfg.NeedJiFen    = Convert.ToInt32(xmlItem.Attribute("NeedCoupleDuanWeiJiFen").Value.ToString());
                    cfg.DuanWeiType  = Convert.ToInt32(xmlItem.Attribute("Type").Value.ToString());
                    cfg.DuanWeiLevel = Convert.ToInt32(xmlItem.Attribute("Level").Value.ToString());
                    cfg.WinJiFen     = Convert.ToInt32(xmlItem.Attribute("WinJiFen").Value.ToString());
                    cfg.LoseJiFen    = Convert.ToInt32(xmlItem.Attribute("LoseJiFen").Value.ToString());

                    _DuanWeiCfgList.Add(cfg);
                }
                _DuanWeiCfgList.Sort((_l, _r) => { return(_l.NeedJiFen - _r.NeedJiFen); });

                DateTime now = TimeUtil.NowDateTime();
                Persistence.CheckClearRank(CurrRankWeek(now));
                SyncData.RankList = Persistence.LoadRankFromDb();
                SyncData.BuildRoleDict();
                SyncData.ModifyTime = now;

                this.IsNeedSort = false;
                for (int i = 1; i < SyncData.RankList.Count && !this.IsNeedSort; i++)
                {
                    this.IsNeedSort |= SyncData.RankList[i].CompareTo(SyncData.RankList[i - 1]) < 0;
                    this.IsNeedSort |= this.SyncData.RankList[i].Rank != this.SyncData.RankList[i - 1].Rank + 1;
                }

                CheckRebuildRank(now);
                CheckFlushRank2Db();
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, "CoupleArenaService.InitConfig failed!", ex);
            }
        }
Exemplo n.º 4
0
 public void StartUp()
 {
     try
     {
         int  num;
         bool flag;
         IEnumerator <XElement> objA = XElement.Load(KuaFuServerManager.GetResourcePath(@"Config\CoupleWar.xml", KuaFuServerManager.ResourcePathTypes.GameRes)).Elements().GetEnumerator();
         try
         {
             flag = objA.MoveNext();
             if (flag)
             {
                 string[] strArray = objA.Current.Attribute("TimePoints").Value.Split(new char[] { ',', '-', '|' });
                 num = 0;
                 while (true)
                 {
                     flag = num < strArray.Length;
                     if (!flag)
                     {
                         this._WarTimePointList.Sort((_l, _r) => _l.Weekday - _r.Weekday);
                         break;
                     }
                     _CoupleArenaWarTimePoint item = new _CoupleArenaWarTimePoint
                     {
                         Weekday = Convert.ToInt32(strArray[num])
                     };
                     if ((item.Weekday < 1) || (item.Weekday > 7))
                     {
                         throw new Exception("weekday error!");
                     }
                     item.DayStartTicks = DateTime.Parse(strArray[num + 1]).TimeOfDay.Ticks;
                     item.DayEndTicks   = DateTime.Parse(strArray[num + 2]).TimeOfDay.Ticks;
                     this._WarTimePointList.Add(item);
                     num += 3;
                 }
             }
         }
         finally
         {
             if (!ReferenceEquals(objA, null))
             {
                 objA.Dispose();
             }
         }
         objA = XElement.Load(KuaFuServerManager.GetResourcePath(@"Config\CoupleDuanWei.xml", KuaFuServerManager.ResourcePathTypes.GameRes)).Elements().GetEnumerator();
         try
         {
             while (true)
             {
                 flag = objA.MoveNext();
                 if (!flag)
                 {
                     break;
                 }
                 XElement current            = objA.Current;
                 _CoupleArenaDuanWeiCfg item = new _CoupleArenaDuanWeiCfg
                 {
                     NeedJiFen    = Convert.ToInt32(current.Attribute("NeedCoupleDuanWeiJiFen").Value.ToString()),
                     DuanWeiType  = Convert.ToInt32(current.Attribute("Type").Value.ToString()),
                     DuanWeiLevel = Convert.ToInt32(current.Attribute("Level").Value.ToString()),
                     WinJiFen     = Convert.ToInt32(current.Attribute("WinJiFen").Value.ToString()),
                     LoseJiFen    = Convert.ToInt32(current.Attribute("LoseJiFen").Value.ToString())
                 };
                 this._DuanWeiCfgList.Add(item);
             }
         }
         finally
         {
             if (!ReferenceEquals(objA, null))
             {
                 objA.Dispose();
             }
         }
         this._DuanWeiCfgList.Sort((_l, _r) => _l.NeedJiFen - _r.NeedJiFen);
         DateTime time = TimeUtil.NowDateTime();
         this.Persistence.CheckClearRank(this.CurrRankWeek(time));
         this.SyncData.RankList = this.Persistence.LoadRankFromDb();
         this.SyncData.BuildRoleDict();
         this.SyncData.ModifyTime = time;
         this.IsNeedSort          = false;
         num = 1;
         while (true)
         {
             flag = (num < this.SyncData.RankList.Count) && !this.IsNeedSort;
             if (!flag)
             {
                 this.CheckRebuildRank(time);
                 this.CheckFlushRank2Db();
                 break;
             }
             this.IsNeedSort |= this.SyncData.RankList[num].CompareTo(this.SyncData.RankList[num - 1]) < 0;
             this.IsNeedSort |= this.SyncData.RankList[num].Rank != (this.SyncData.RankList[num - 1].Rank + 1);
             num++;
         }
     }
     catch (Exception exception)
     {
         LogManager.WriteLog(LogTypes.Error, "CoupleArenaService.InitConfig failed!", exception, true);
     }
 }