Beispiel #1
0
        public List <CardStat> GetCarsUsageTopRanking(int?idlocation = null, int nbcardAssociated = 8)
        {
            var playerCards = new List <PlayerDetail>();
            var cardsUsage  = new List <CardStat>();

            try
            {
                using (var client = new CRClient(_uriBaseUrl, _credentials))
                {
                    var players = client.GetPlayerRanking(idlocation?.ToString());
                    foreach (var player in players.Items)
                    {
                        if (DemandStopping)
                        {
                            break;
                        }
                        var playerDetail = client.GetPlayer(player.Tag);
                        if (playerDetail != null && playerDetail.CurrentCards != null)
                        {
                            playerCards.Add(playerDetail);
                        }
                    }
                }
                cardsUsage = playerCards.SelectMany(p => p.CurrentCards).GroupBy(p => p.Name).Select(p => new CardStat {
                    Name = p.First().Name, Count = p.Count(), Url = p.First().IconUrls.Medium
                }).OrderByDescending(p => p.Count).ToList();
                var posi      = 0;
                var lastusage = int.MaxValue;
                foreach (var card in cardsUsage)
                {
                    if (card.Count != lastusage)
                    {
                        posi++;
                        lastusage = card.Count;
                    }
                    card.Rank            = posi;
                    card.AssociatedCards = playerCards.Where(p => p.CurrentCards.Any(c => c.Name == card.Name)).SelectMany(p => p.CurrentCards).Where(p => p.Name != card.Name).GroupBy(p => p.Name).Select(p => new CardStat {
                        Name = p.First().Name, Count = p.Count(), Url = p.First().IconUrls.Medium
                    }).OrderByDescending(p => p.Count).Take(nbcardAssociated).ToList();
                }
            }
            catch (Exception ex)
            {
                Logger?.Error(ex);
            }
            finally
            {
                DemandStopping = false;
            }
            return(cardsUsage);
        }
Beispiel #2
0
        public List <CardStat> GetCardsWinTopPlayer(int?idlocation = null)
        {
            var result = new List <CardStat>();

            try
            {
                using (var client = new CRClient(_uriBaseUrl, _credentials))
                {
                    var players = client.GetPlayerRanking(idlocation?.ToString());
                    result = InternalGetCardWin(players.Items.Cast <PlayerBase>().ToList());
                }
            }
            catch (Exception ex)
            {
                Logger?.Error(ex);
            }
            finally
            {
                DemandStopping = false;
            }
            return(result);
        }