Exemplo n.º 1
0
        private async Task <List <HeroItemBuildGroupViewModel> > GetItemGroupsAsync(ItemBuildSchemaItemModel itemBuild)
        {
            List <HeroItemBuildGroupViewModel> itemGroupViewModels = new List <HeroItemBuildGroupViewModel>();

            foreach (var itemGroup in itemBuild.Items)
            {
                HeroItemBuildGroupViewModel itemGroupViewModel = new HeroItemBuildGroupViewModel();
                itemGroupViewModel.Title = await db.GetLocalizationTextAsync(itemGroup.Name.Remove(0, 1));

                List <HeroItemBuildItemViewModel> itemViewModels = new List <HeroItemBuildItemViewModel>();

                var tasks = itemGroup.Items.Select(async(x) => new HeroItemBuildItemViewModel()
                {
                    IconPath = String.Format("http://cdn.dota2.com/apps/dota2/images/items/{0}_lg.png", x.Replace("item_", "")),
                    Name     = await db.GetLocalizationTextAsync(String.Format("DOTA_Tooltip_Ability_{0}", x))
                });
                var selectedItems = await Task.WhenAll(tasks);

                itemGroupViewModel.Items = selectedItems
                                           .GroupBy(x => new { x.Name, x.IconPath })
                                           .Select(x => new HeroItemBuildItemViewModel()
                {
                    IconPath = x.Key.IconPath,
                    Name     = x.Key.Name,
                    Quantity = x.Count()
                })
                                           .ToList();

                itemGroupViewModels.Add(itemGroupViewModel);
            }

            return(itemGroupViewModels);
        }
Exemplo n.º 2
0
 private async Task <GameItemViewModel> GetItemViewModel(GameItemModel randomItem1)
 {
     return(new GameItemViewModel()
     {
         Cost = randomItem1.Cost,
         Name = await db.GetLocalizationTextAsync(String.Format("DOTA_Tooltip_Ability_{0}", randomItem1.Name)),
         Description = await db.GetLocalizationTextAsync(String.Format("DOTA_Tooltip_ability_{0}_Description", randomItem1.Name)),
         Lore = await db.GetLocalizationTextAsync(String.Format("DOTA_Tooltip_ability_{0}_Lore", randomItem1.Name)),
         Id = randomItem1.Id,
         IsRecipe = randomItem1.IsRecipe,
         SecretShop = randomItem1.IsAvailableAtSecretShop,
         SideShop = randomItem1.IsAvailableAtSideShop,
         IconPath = String.Format("http://cdn.dota2.com/apps/dota2/images/items/{0}_lg.png", randomItem1.IsRecipe ? "recipe" : randomItem1.Name.Replace("item_", "")),
     });
 }
Exemplo n.º 3
0
        private async Task <List <ItemAutographViewModel> > GetAutographItemsAsync(SchemaModel schema)
        {
            List <ItemAutographViewModel> autographs = new List <ItemAutographViewModel>();

            foreach (var autograph in schema.ItemAutographs)
            {
                var autographViewModel = new ItemAutographViewModel()
                {
                    Name         = autograph.Name,
                    Autograph    = autograph.Autograph,
                    Language     = autograph.Language,
                    WorkshopLink = autograph.WorkshopLink,
                    Modifier     = !String.IsNullOrEmpty(autograph.Modifier) ? await db.GetLocalizationTextAsync(autograph.Modifier.Remove(0, 1)) : String.Empty,
                    IconPath     = autograph.GetIconPath()
                };

                autographs.Add(autographViewModel);
            }

            return(autographs);
        }