예제 #1
0
        public void CheckScore()
        {
            if (Directory.Exists(Config.StatFolderName))
            {
                List <string> files = Directory.GetFiles(Config.StatFolderName, "match_*.json").ToList();
                if (files.Count == 0)
                {
                    this.SetScore(0, 0, 0);
                    return;
                }
                files.Reverse();

                int wins, loses, rating;
                wins = loses = rating = 0;

                foreach (string filePath in files)
                {
                    MatchRecord tokenMatch = MatchRecord.Load(filePath);

                    if (tokenMatch.MatchEnd.ToLocalTime().Date < DateTime.Today)
                    {
                        break;
                    }

                    if (tokenMatch.RatingGain > 0)
                    {
                        wins++;
                    }
                    else
                    {
                        loses++;
                    }

                    rating += tokenMatch.RatingGain;
                }

                this.SetScore(wins, loses, rating);
            }
            else
            {
                this.SetScore(0, 0, 0);
                return;
            }
        }