コード例 #1
0
ファイル: FileData.cs プロジェクト: jayras/hearthstone
        internal bool UpdateSeason(Season season)
        {
            if (!RemoveSeason(season))
            {
                return false;
            }

            Seasons.Add(season);

            using (StreamWriter seasonFile = new StreamWriter(_seasonPath,false))
            {
                seasonFile.WriteLine("#Seasons");
                seasonFile.WriteLine("#ID\tNumber\tStart\tEnd\tDescription");

                foreach (Season thisSeason in Seasons.OrderBy(s=> s.ID))
                {
                    seasonFile.WriteLine(thisSeason.ToString());
                }

                seasonFile.Flush();
            }
            return true;
        }
コード例 #2
0
ファイル: FileData.cs プロジェクト: jayras/hearthstone
        private void LoadSeasons()
        {
            if (!File.Exists(_seasonPath))
            {
                throw new ArgumentException("Missing Season and/or Rank file(s).");
            }

            if (AllRanks.Count == 0)
            {
                LoadRanks();
            }

            using (StreamReader seasonFile = new StreamReader(_seasonPath))
            {
                string seasonLine;
                while ((seasonLine = seasonFile.ReadLine()) != null)
                {
                    if (seasonLine.StartsWith("#"))
                    {
                        continue;
                    }
                    string[] seasonData = seasonLine.Split('\t');

                    if (seasonData.Length >= 5 )
                    {
                        Season thisSeason = new Season();
                        thisSeason.ID = int.Parse(seasonData[0]);
                        thisSeason.Number = int.Parse(seasonData[1]);
                        thisSeason.Start = DateTime.Parse(seasonData[2]);
                        thisSeason.End = DateTime.Parse(seasonData[3]);
                        thisSeason.Description = seasonData[4];
                        thisSeason.Ranks = AllRanks.Where(r => r.ExpirationDate > thisSeason.Start).ToList();
                        Seasons.Add(thisSeason);
                    }

                }
            }
        }
コード例 #3
0
ファイル: FileData.cs プロジェクト: jayras/hearthstone
 internal bool RemoveSeason(Season season)
 {
     if (Seasons.Any(s => s.ID == season.ID))
     {
         Seasons.Remove(Seasons.First(s => s.ID == season.ID));
         return RemoveSeason(season);
     }
     return true;
 }
コード例 #4
0
ファイル: FileData.cs プロジェクト: jayras/hearthstone
 internal bool AddSeason(Season season)
 {
     return UpdateSeason(season);
 }
コード例 #5
0
ファイル: HearthstoneData.cs プロジェクト: jayras/hearthstone
 public bool UpdateSeason(Season season)
 {
     return _fileData.UpdateSeason(season);
 }
コード例 #6
0
ファイル: HearthstoneData.cs プロジェクト: jayras/hearthstone
 public bool DeleteSeason(Season season)
 {
     return _fileData.RemoveSeason(season);
 }
コード例 #7
0
ファイル: HearthstoneData.cs プロジェクト: jayras/hearthstone
 public bool AddSeason(Season season)
 {
     return _fileData.AddSeason(season);
 }