Exemplo n.º 1
0
        public void GetPlayers_Throws_Exception_When_NotFound()
        {
            var playerService = new PubgPlayerService(Storage.ApiKey);

            var filter = new GetPubgPlayersRequest
            {
                PlayerNames = new string[] { "NonExistantPlayerHopefully" }
            };

            Assert.Throws <PubgNotFoundException>(() => playerService.GetPlayers(PubgRegion.PCEurope, filter));
        }
Exemplo n.º 2
0
        public void GetByName(string playerName)
        {
            var playerFound = playerService.GetPlayers(PubgPlatform.Steam, new GetPubgPlayersRequest
            {
                ApiKey      = Credentials.PubgToken,
                PlayerNames = new string[] { playerName }
            }).FirstOrDefault();

            Id   = playerFound.Id;
            Name = playerName;
            GetPlayerStats();
        }
Exemplo n.º 3
0
        public async Task <RequestResult <PubgPlayer> > Handle(GetRecentMatchesForPlayer request, CancellationToken cancellationToken)
        {
            var pubgPlayerService = new PubgPlayerService();
            var playersRequest    = new GetPubgPlayersRequest()
            {
                PlayerNames = new string[] { "S_T_A_R" }
            };

            var players = pubgPlayerService.GetPlayers(PubgPlatform.Steam, playersRequest);

            return(players
                   .FirstOrDefault()?
                   .AsSuccessResult());
        }
Exemplo n.º 4
0
        public void Can_Get_Players_ById()
        {
            var playerService = new PubgPlayerService(Storage.ApiKey);

            var playerIds = Storage.GetMatch(PubgRegion.PCEurope).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.PlayerId).Take(5).ToArray();

            var filter = new GetPubgPlayersRequest
            {
                PlayerIds = playerIds
            };

            var players = playerService.GetPlayers(PubgRegion.PCEurope, filter);

            Assert.NotEmpty(players);
            Assert.All(players.Select(p => p.Id), id => playerIds.Contains(id));
        }
Exemplo n.º 5
0
        public void Can_Get_Players_ByName()
        {
            var playerService = new PubgPlayerService(Storage.ApiKey);

            var playerNames = Storage.GetMatch(PubgPlatform.Steam).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.Name).Take(5).ToArray();

            var filter = new GetPubgPlayersRequest
            {
                PlayerNames = playerNames
            };

            var players = playerService.GetPlayers(PubgPlatform.Steam, filter);

            Assert.NotEmpty(players);
            Assert.All(players.Select(p => p.Name), name => playerNames.Contains(name));
        }
Exemplo n.º 6
0
        public static PubgPlayer GetPlayer(PubgPlatform platform)
        {
            var player = StoredItems.OfType<PubgPlayer>().FirstOrDefault(p => p.ShardId == platform.Serialize());

            if (player != null)
                return player;

            var playerService = new PubgPlayerService(ApiKey);

            var region = platform == PubgPlatform.Xbox ? PubgRegion.XboxEurope : PubgRegion.PCEurope;

            var playerNames = GetMatch(platform).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.Name).Take(5);
            var players = playerService.GetPlayers(platform, new GetPubgPlayersRequest { PlayerNames = playerNames.ToArray() });

            StoredItems.AddRange(players);

            return players.FirstOrDefault();
        }
Exemplo n.º 7
0
        public static PubgPlayer GetPlayer(PubgRegion region)
        {
            var player = StoredItems.OfType <PubgPlayer>().FirstOrDefault(p => p.ShardId == region.Serialize());

            if (player != null)
            {
                return(player);
            }

            var playerService = new PubgPlayerService(ApiKey);
            var playerNames   = GetMatch(region).Rosters.SelectMany(r => r.Participants).Select(p => p.Stats.Name).Take(5);
            var players       = playerService.GetPlayers(region, new GetPubgPlayersRequest {
                PlayerNames = playerNames.ToArray()
            });

            StoredItems.AddRange(players);

            return(players.FirstOrDefault());
        }