Example #1
0
        public void AddMapWin(PlayerBlizzard playerBlizzard, Race myRace, Race enemyRace, string mapName, bool won)
        {
            if (playerBlizzard.heroes == null)
            {
                return;
            }

            foreach (var hero in playerBlizzard.heroes)
            {
                HeroStatsItemList.AddWin(hero.icon.ParseReforgedName(), myRace, enemyRace, mapName, won);
            }
        }
Example #2
0
        private PlayerScore CreateDetail(PlayerBlizzard playerBlizzard)
        {
            foreach (var player in playerBlizzard.heroes)
            {
                player.icon = player.icon.ParseReforgedName();
            }

            return(new PlayerScore(
                       playerBlizzard.battleTag,
                       playerBlizzard.unitScore,
                       playerBlizzard.heroes,
                       playerBlizzard.heroScore,
                       playerBlizzard.resourceScore));
        }
Example #3
0
        public static Matchup Create(MatchFinishedEvent matchFinishedEvent)
        {
            var match = matchFinishedEvent.match;

            var startTime = DateTimeOffset.FromUnixTimeMilliseconds(matchFinishedEvent.match.startTime);
            var endTime   = DateTimeOffset.FromUnixTimeMilliseconds(matchFinishedEvent.match.endTime);

            var result = new Matchup()
            {
                Id        = matchFinishedEvent.Id,
                Map       = new MapName(matchFinishedEvent.match.map).Name,
                MatchId   = match.id,
                GateWay   = match.gateway,
                GameMode  = matchFinishedEvent.match.gameMode,
                StartTime = startTime,
                EndTime   = endTime,
                Duration  = endTime - startTime,
                Season    = match.season
            };

            result.SetServerInfo(match);

            var players = match.players
                          .OrderByDescending(x => x.won)
                          .ThenBy(x => x.team)
                          .ToList();

            foreach (var player in players)
            {
                if (player.race == Race.RnD)
                {
                    PlayerBlizzard resultPlayer = null;
                    player.rndRace = Race.RnD;

                    if (matchFinishedEvent.result != null)
                    {
                        resultPlayer = matchFinishedEvent.result.players?.FirstOrDefault(p => p.battleTag == player.battleTag);
                    }

                    if (resultPlayer != null)
                    {
                        // If the player chose random for the match,
                        // set their actual randomized race from the result.
                        player.rndRace = player.race.FromRaceId((RaceId)resultPlayer.raceId);
                    }
                }
            }

            var teamGroups = SplitPlayersIntoTeams(players, match.gameMode);

            foreach (var team in teamGroups)
            {
                result.Teams.Add(CreateTeam(team.Value));
                result.Teams = result.Teams
                               .OrderByDescending(x => x.Players.Any(y => y.Won))
                               .ToList();
            }

            SetTeamPlayers(result);

            return(result);
        }