Exemple #1
0
        private static void Download()
        {
            var newMatchRecords = Honzor.GetMatchHistory()
                                  .Where(mr => !mr.Id.In(_matches.Select(m => m.Id)))
                                  .ToList();

            if (!newMatchRecords.Any())
            {
                Logger.Log(_matches.Any()
                    ? "No new matches."
                    : "No matches found.");

                return;
            }

            Logger.Log($"Found {newMatchRecords.Count} {(_matches.Any() ? "new" : "")} matches.");

            var matches = HonApi.GetMultiMatch(newMatchRecords).OrderBy(m => m.Time).ToList();

            if (!matches.Any())
            {
                Logger.Log("Failed to download matches.");
                return;
            }

            Logger.Log($"Matches downloaded: {matches.Count}");
            Logger.Log($"Last match: {matches.Last().Id} - {matches.Last().Time.ToLocalTime()}");

            _matches.AddRange(matches);
            _matches = _matches.OrderBy(m => m.Time).ToList();
        }
Exemple #2
0
        public static MatchType CalcMatchType(this Match match)
        {
            if (!match.PlayerResults.All(pr => Honzor.IsMember(pr.Player)))
            {
                return(MatchType.Other);
            }

            var legionCount     = match.PlayerResults.Count(p => p.Team == Team.Legion);
            var hellbourneCount = match.PlayerResults.Count(p => p.Team == Team.Hellbourne);

            if (legionCount == 1 && hellbourneCount == 1)
            {
                return(MatchType.OneVsOne);
            }

            if ((legionCount == 2 && hellbourneCount == 1) ||
                (legionCount == 1 && hellbourneCount == 2))
            {
                return(MatchType.TwoVsOne);
            }

            if (legionCount == 2 && hellbourneCount == 2)
            {
                return(MatchType.TwoVsTwo);
            }

            if ((legionCount == 3 && hellbourneCount == 2) ||
                (legionCount == 2 && hellbourneCount == 3))
            {
                return(MatchType.ThreeVsTwo);
            }

            return(MatchType.Other);
        }