public void GetAccountInfo(long accountID, string name)
        {
            var account = accessor.GetAccountInfo(accountID);

            Assert.AreEqual(name, account.Name);
        }
Example #2
0
        public IEnumerable <LiveMatch> GetLiveTournamentGames()
        {
            var jsonMatches = accessor.GetAllLiveTournamentGames();

            //This filters out all unofficial teams in games like FACEIT Leagues
            jsonMatches = jsonMatches.Where(t => t.Radiant.Name != null && t.Dire.Name != null);
            List <LiveMatch> matches = new List <LiveMatch>();

            //Convert the mathes from their Json form to a more useful object
            foreach (var jsonMatch in jsonMatches)
            {
                var radiant = accessor.GetTeamInfo(jsonMatch.Radiant.ID);
                var dire    = accessor.GetTeamInfo(jsonMatch.Dire.ID);
                if (radiant == null || dire == null)
                {
                    //At least one of the teams isn't an official valve registered team meaning this can't be a tournament game
                    continue;
                }
                List <ProPlayer> radiantAccounts = new List <ProPlayer>();
                List <ProPlayer> direAccounts    = new List <ProPlayer>();
                List <Player>    radiantPlayers  = new List <Player>();
                List <Player>    direPlayers     = new List <Player>();
                //TODO: Bring this back to before where players & accounts were split. New version isn't as ideal for live games
                //This can be null when the game is live but still in the drafting stage and no hero has been picked
                if (jsonMatch.ScoreBoard.Radiant != null)
                {
                    foreach (var player in jsonMatch.ScoreBoard.Radiant.Players)
                    {
                        radiantAccounts.Add(convertJsonAccountToProPlayer(accessor.GetAccountInfo(player.AccountID)));
                        radiantPlayers.Add(convertJsonPlayerToPlayer(player));
                    }
                }
                if (jsonMatch.ScoreBoard.Dire != null)
                {
                    foreach (var player in jsonMatch.ScoreBoard.Dire.Players)
                    {
                        direAccounts.Add(convertJsonAccountToProPlayer(accessor.GetAccountInfo(player.AccountID)));
                        direPlayers.Add(convertJsonPlayerToPlayer(player));
                    }
                }
                var tournament = tournaments.Where(t => t.ID == jsonMatch.LeagueID).First();
                matches.Add(new LiveMatch
                {
                    ID         = jsonMatch.ID,
                    Tournament = new Tournament
                    {
                        ID           = tournament.ID,
                        Name         = tournament.Name.Replace("_", " "),
                        TicketItemID = tournament.TicketItemID,
                    },
                    RadiantSeriesWins = jsonMatch.RadiantSeriesWins,
                    DireSeriesWins    = jsonMatch.DireSeriesWins,
                    Duration          = new TimeSpan(0, 0, jsonMatch.ScoreBoard.Duration),
                    GameNumber        = jsonMatch.GameNumber,
                    SeriesType        = jsonMatch.SeriesType,
                    SeriesID          = jsonMatch.SeriesID,
                    Radiant           = convertJsonTeamToTeam(jsonMatch.ScoreBoard.Radiant, radiant, radiantPlayers, radiantAccounts),
                    Dire = convertJsonTeamToTeam(jsonMatch.ScoreBoard.Dire, dire, direPlayers, direAccounts),
                });
            }

            return(matches);
        }