private async Task SetupRandomItems(HomeViewModel viewModel, IReadOnlyCollection <GameItemModel> gameItems) { var randomItems = gameItems .Where(x => !String.IsNullOrEmpty(x.Name.Trim()) && x.Name.Trim() != "Undefined" && !x.IsRecipe) .ToList(); var abilities = await db.GetItemAbilitiesAsync(); Random r = new Random(); GameItemViewModel itemViewModel1 = await GetRandomItem(r, randomItems, abilities); GameItemViewModel itemViewModel2 = await GetRandomItem(r, randomItems, abilities); GameItemViewModel itemViewModel3 = await GetRandomItem(r, randomItems, abilities); List <GameItemViewModel> randomGameItems = new List <GameItemViewModel>(); randomGameItems.Add(itemViewModel1); randomGameItems.Add(itemViewModel2); randomGameItems.Add(itemViewModel3); viewModel.RandomGameItems = randomGameItems.AsReadOnly(); }
/// <summary> /// Remove a single item when X is clicked for a game /// </summary> /// <param name="game"></param> private void RemoveFromMultisystemList(GameItemViewModel game) { _hyperspinManager.MultiSystemGamesList.Remove(game); MultiSystemHeader = string.Format("Multi System Generator: {0} Pending", _hyperspinManager.MultiSystemGamesList.Count); }
private async Task <GameItemViewModel> GetRandomItem(Random r, IList <GameItemModel> randomItems, IReadOnlyDictionary <uint, ItemAbilitySchemaItemModel> abilities) { int index = r.Next(0, randomItems.Count); var randomItem1 = randomItems[index]; GameItemViewModel itemViewModel = await GetItemViewModel(randomItem1); await AddAbilityToItemViewModelAsync(itemViewModel, abilities); randomItems.RemoveAt(index); return(itemViewModel); }
public GameItemController(ApplicationDbContext db, IWebHostEnvironment webHostEnvironment) { _db = db; _webHostEnvironment = webHostEnvironment; GameItemVM = new GameItemViewModel() { GameItemPVM = new Models.GameItem(), CategoryList = _db.Categories, ForWhichClassItemsList = _db.ForWhichClassItemDb, ItemQualityList = _db.ItemQualityDb }; }
public IHttpActionResult PostSaveGame(GameAddViewModel model) { if (ModelState.IsValid) { var gameSave = new GameItemViewModel { id = 3, title = model.Title, image = model.Image }; return(Content(HttpStatusCode.OK, model)); } return(Content(HttpStatusCode.BadRequest, new { title = "має бути", image = "теж саме" })); }
public void ShouldIdentifyMultipleVersions() { // setup var env = new TestEnvironment(Logger); var gameManager = env.Locator.GetService <IGameManager>(); env.Menu.Games[0].Filename = "not_same_name"; // test gameManager.Initialize(); var game = gameManager.AggregatedGames[0]; var viewModel = new GameItemViewModel(game, env.Locator); viewModel.IdentifyRelease.Execute(); // assert viewModel.IdentifiedReleases.Should().HaveCount(2); }
public void ShouldIdentifyGameInstantly() { // setup var env = new TestEnvironment(Logger); var gameManager = env.Locator.GetService <IGameManager>(); // test gameManager.Initialize(); // let's mock also IGameManager, we only need to know if LinkRelease is called. var gameManagerMock = env.Register <IGameManager>(); var game = gameManager.AggregatedGames[0]; var viewModel = new GameItemViewModel(game, env.Locator); viewModel.IdentifyRelease.Execute(); // assert /*gameManagerMock.Verify(gm => gm.LinkRelease( * It.Is<Game>(g => g.Id == game.Id), * It.Is<VpdbRelease>(r => r.Id == TestVpdbApi.AbraCaDabraReleaseId), * TestVpdbApi.AbraCaDabraV20FileId * ));*/ }
private async Task AddAbilityToItemViewModelAsync(GameItemViewModel viewModel, IReadOnlyDictionary <uint, ItemAbilitySchemaItemModel> abilities) { ItemAbilitySchemaItemModel ability = null; bool abilityExists = abilities.TryGetValue(viewModel.Id, out ability); if (abilityExists) { string joinedBehaviors = db.GetJoinedBehaviors(ability.AbilityBehavior); string joinedUnitTargetTeamTypes = db.GetJoinedUnitTargetTeamTypes(ability.AbilityUnitTargetTeam); string joinedUnitTargetTypes = db.GetJoinedUnitTargetTypes(ability.AbilityUnitTargetType); string joinedUnitTargetFlags = db.GetJoinedUnitTargetFlags(ability.AbilityUnitTargetFlags); List <HeroAbilitySpecialViewModel> abilitySpecialViewModels = new List <HeroAbilitySpecialViewModel>(); foreach (var abilitySpecial in ability.AbilitySpecials) { abilitySpecialViewModels.Add(new HeroAbilitySpecialViewModel() { Name = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, abilitySpecial.Name)), RawName = abilitySpecial.Name, Value = abilitySpecial.Value.ToSlashSeparatedString() }); } viewModel.CastPoint = ability.AbilityCastPoint.ToSlashSeparatedString(); viewModel.CastRange = ability.AbilityCastRange.ToSlashSeparatedString(); viewModel.Cooldown = ability.AbilityCooldown.ToSlashSeparatedString(); viewModel.Damage = ability.AbilityDamage.ToSlashSeparatedString(); viewModel.Duration = ability.AbilityDuration.ToSlashSeparatedString(); viewModel.ManaCost = ability.AbilityManaCost.ToSlashSeparatedString(); viewModel.Attributes = abilitySpecialViewModels; viewModel.Behaviors = joinedBehaviors; viewModel.TargetFlags = joinedUnitTargetFlags; viewModel.TargetTypes = joinedUnitTargetTypes; viewModel.TeamTargets = joinedUnitTargetTeamTypes; viewModel.Note0 = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, "Note0")); viewModel.Note1 = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, "Note1")); viewModel.Note2 = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, "Note2")); viewModel.Note3 = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, "Note3")); viewModel.Note4 = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, "Note4")); viewModel.Note5 = await db.GetLocalizationTextAsync(String.Format("{0}_{1}_{2}", "DOTA_Tooltip_ability", viewModel.Name, "Note5")); viewModel.CastsOnPickup = ability.ItemCastOnPickup; viewModel.ContributesToNetWorthWhenDropped = ability.ItemContributesToNetWorthWhenDropped; viewModel.Declarations = db.GetJoinedItemDeclarationTypes(ability.ItemDeclarations); viewModel.DisassembleRule = db.GetJoinedItemDisassembleTypes(ability.ItemDisassembleRule); viewModel.DisplayCharges = ability.ItemDisplayCharges; viewModel.InitialCharges = ability.ItemInitialCharges; viewModel.IsAlertable = ability.ItemAlertable; viewModel.IsDroppable = ability.ItemDroppable; viewModel.IsKillable = ability.ItemKillable; viewModel.IsPermanent = ability.ItemPermanent; viewModel.IsPurchasable = ability.ItemPurchasable; viewModel.IsSellable = ability.ItemSellable; viewModel.IsStackable = ability.ItemStackable; viewModel.IsSupport = ability.ItemSupport; viewModel.Shareability = db.GetJoinedItemShareabilityTypes(ability.ItemShareability); viewModel.ShopTags = GetSplitAndRejoinedShopTags(ability.ItemShopTags); viewModel.StockInitial = ability.ItemStockInitial; viewModel.StockMax = ability.ItemStockMax; viewModel.StockTime = ability.ItemStockTime; } }