Exemplo n.º 1
0
        public async Task <PlayerPoints> GetDkp(int id)
        {
            PointsResponse points = await client.GetPoints(id);

            Player player = points?.Players?.FirstOrDefault();

            if (player?.MainId != id)
            {
                log.LogInformation($"Character id '{id}' is an alt. Getting points for main.");
                points = await client.GetPoints(player?.MainId);

                player = points?.Players?.FirstOrDefault();
            }

            return(player?.Points?.FirstOrDefault() ?? throw new PlayerNotFoundException($"Player id '{id}' not found."));
        }
        public void PlayerPointsDeserialize()
        {
            //Arrange

            XmlSerializer serializer = new XmlSerializer(typeof(PointsResponse));

            //Act
            PointsResponse r      = serializer.Deserialize(new StringReader(TestResources.MaggDkp)) as PointsResponse;
            PlayerPoints   points = r?.Players.FirstOrDefault()?.Points?.FirstOrDefault();

            //Assert
            Assert.IsNotNull(points);
            Assert.AreEqual(959, points.PointsCurrent);
            Assert.AreEqual(547, points.PointsCurrentWithTwink);
            Assert.AreEqual(4602, points.PointsEarned);
            Assert.AreEqual(8554, points.PointsEarnedWithTwink);
            Assert.AreEqual(3793, points.PointsSpent);
            Assert.AreEqual(7957, points.PointsSpentWithTwink);
            Assert.AreEqual(150, points.PointsAdjustment);
            Assert.AreEqual(-50, points.PointsAdjustmentWithTwink);
        }
Exemplo n.º 3
0
        public async Task UpdatePlayerIds()
        {
            PointsResponse points = await client.GetPoints();

            state.PlayerIds = new ReadOnlyDictionary <string, int>(points.Players.ToDictionary(x => x.Name, x => x.Id, StringComparer.OrdinalIgnoreCase));
        }