Esempio n. 1
0
        public static async Task <CardInfo> GetCardInfoAsync(this Card card, Shinden.ShindenClient client)
        {
            var response = await client.GetCharacterInfoAsync(card.Character);

            if (!response.IsSuccessStatusCode())
            {
                throw new Exception($"Couldn't get card info!");
            }

            return(new CardInfo
            {
                Info = response.Body,
                Card = card
            });
        }
Esempio n. 2
0
        public static async Task Update(this Card card, IUser user, Shinden.ShindenClient client)
        {
            var response = await client.GetCharacterInfoAsync(card.Character);

            if (!response.IsSuccessStatusCode())
            {
                card.Unique = true;
                throw new Exception($"Couldn't get card info!");
            }

            if (user != null)
            {
                if (card.FirstIdOwner == 0)
                {
                    card.FirstIdOwner = user.Id;
                }
            }

            card.Unique = false;
            card.Name   = response.Body.ToString();
            card.Image  = response.Body.HasImage ? response.Body.PictureUrl : null;
            card.Title  = response.Body?.Relations?.OrderBy(x => x.Id).FirstOrDefault()?.Title ?? "????";
        }