Ejemplo n.º 1
0
        private async System.Threading.Tasks.Task LoadHeroUrl(string heroName, int heroIndex)
        {
            bool isInvalid = false;

            if (string.IsNullOrEmpty(heroName) || heroName == "0")
            {
                isInvalid = true;
            }

            string url = await m_client.GetCardArtUrlAsync(heroName, ArtType.Ingame);

            if (string.IsNullOrEmpty(url))
            {
                Logger.OutputError($"Cannot find URL for '{heroName}'");
            }

            if (Heroes == null)
            {
                Heroes = new List <string>();
            }

            string blankHeroImgPath = "/Images/unknown_hero.png";

            if (Heroes.Count - 1 > heroIndex)
            {
                if (isInvalid)
                {
                    Heroes.Insert(heroIndex, blankHeroImgPath);
                }
                else
                {
                    Heroes.Insert(heroIndex, url);
                }
            }
            else
            {
                if (isInvalid)
                {
                    Heroes.Add(blankHeroImgPath);
                }
                else
                {
                    Heroes.Add(url);
                }
            }
        }