public void CombineRecipeShouldAddNewCommonItemFromRecipe() { // Arrange var item1 = new CommonItem("CommonItem1", 1, 2, 3, 4, 5); var item2 = new CommonItem("CommonItem2", 6, 7, 8, 9, 10); this.heroInventory.AddCommonItem(item1); this.heroInventory.AddCommonItem(item2); var requiredItems = new List <string>() { "CommonItem1", "CommonItem2" }; var recipe = new RecipeItem("CommonItem3", 100, 200, 300, 400, 500, requiredItems); // Act MethodInfo method = GetMethodByName("CombineRecipe"); method.Invoke(this.heroInventory, new object[] { recipe }); var commonItemsCollection = GetCommonItems(); // Assert Assert.AreEqual(true, commonItemsCollection.ContainsKey(recipe.Name), "New common item was not added!"); }
private static RecipeItem CreateIngredientWorkbenchItem(RecipeCounter counter, RecipeItem parent, ItemModel item, int depth) { var ingredient = new RecipeItem(counter) { Id = -1, Depth = depth, Item = new Item { Id = item.Item.Id, RecipeId = item.Item.RecipeId, Name = item.Item.Name, SellPrice = item.Item.SellPrice, BuyPrice = item.Item.BuyPrice, SellOffers = item.Item.SellOffers, BuyOrders = item.Item.BuyOrders, RarityId = item.Item.RarityId, RarityName = item.Item.RarityName, CategoryId = item.Item.CategoryId, CategoryName = item.Item.CategoryName, TypeId = item.Item.TypeId, TypeName = item.Item.TypeName } }; ingredient.Number = 1; ingredient.Parent = parent; return(ingredient); }
public void AddRecipeItemWithUniqueItemsShouldAddAllItems() { // Arrange var requiredItems = new List <string>() { "i1", "i2" }; var item1 = new RecipeItem("Common Item 1", 1, 2, 3, 4, 5, requiredItems); var item2 = new RecipeItem("Common Item 2", 6, 7, 8, 9, 10, requiredItems); var item3 = new RecipeItem("Common Item 3", 11, 12, 13, 14, 15, requiredItems); var inputCollection = new List <IRecipe>() { item1, item2, item3 }; // Act this.heroInventory.AddRecipeItem(item1); this.heroInventory.AddRecipeItem(item2); this.heroInventory.AddRecipeItem(item3); IDictionary <string, IRecipe> collection = GetRecipeItems(); // Assert CollectionAssert.AreEqual(inputCollection, collection.Values.ToList(), "Returned collection did not match input collection!"); }
public void CombineRecipeShouldUpdateCommonItemsCount() { // Arrange var item1 = new CommonItem("CommonItem1", 1, 2, 3, 4, 5); var item2 = new CommonItem("CommonItem2", 6, 7, 8, 9, 10); this.heroInventory.AddCommonItem(item1); this.heroInventory.AddCommonItem(item2); var requiredItems = new List <string>() { "CommonItem1", "CommonItem2" }; var recipe = new RecipeItem("CommonItem3", 100, 200, 300, 400, 500, requiredItems); // Act /* Method should remove existing common items (CommonItem1, CommonItem2) * and add a new common item with params from recipe (CommonItem3) * Common Items count should be 1 (the newly added item) */ MethodInfo method = GetMethodByName("CombineRecipe"); method.Invoke(this.heroInventory, new object[] { recipe }); var commonItemsCollection = GetCommonItems(); // Assert Assert.AreEqual(1, commonItemsCollection.Count, "Common items count is incorrect!"); }
public void RecipeItem_ToDomainModel_ShouldMapNonNullItem() { DB.RecipeItem dbItem = new DB.RecipeItem { Id = 1, Item = new DB.Item { Id = 1, Name = "Onion" }, RequiredQuantity = new Quantity { Amount = 100, Unit = "g" }, Adjectives = new List <string> { "cooked", "chopped" } }; RecipeItem item = EntityMapper.ToDomainModel(dbItem); dbItem.Should().NotBeNull(); dbItem.Id.Should().Be(1); dbItem.Item.Should().NotBeNull(); dbItem.RequiredQuantity.Should().NotBeNull(); dbItem.RequiredQuantity.Amount.Should().Be(100); dbItem.RequiredQuantity.Unit.Should().Be("g"); dbItem.Adjectives.Should().NotBeNullOrEmpty(); dbItem.Adjectives.Should().HaveCount(2); dbItem.Adjectives.Should().Contain(new List <string> { "cooked", "chopped" }); }
public string AddRecipeToHero(IList <string> arguments) { string result = null; string itemName = arguments[0]; string heroName = arguments[1]; int strengthBonus = int.Parse(arguments[2]); int agilityBonus = int.Parse(arguments[3]); int intelligenceBonus = int.Parse(arguments[4]); int hitPointsBonus = int.Parse(arguments[5]); int damageBonus = int.Parse(arguments[6]); string[] requiredItems = arguments.Skip(7).ToArray(); RecipeItem newRecipe = new RecipeItem( itemName, strengthBonus, agilityBonus, intelligenceBonus, hitPointsBonus, damageBonus, requiredItems); this.Heroes[heroName].Inventory.AddRecipeItem(newRecipe); result = string.Format(Constants.RecipeCreatedMessage, newRecipe.Name, heroName); return(result); }
public void RecipeItem_ToDatabaseModel_ShouldMapNullItem() { RecipeItem item = null; DB.RecipeItem dbItem = EntityMapper.ToDatabaseModel(item); dbItem.Should().BeNull(); }
public void RecipeItem_ToDomainModel_ShouldMapNullItem() { DB.RecipeItem dbItem = null; RecipeItem item = EntityMapper.ToDomainModel(dbItem); item.Should().BeNull(); }
public Recipe DataToBusiness(DataRecipe dataRecipe) { Recipe returned = new Recipe(); returned.Ingredient = new List <RecipeItem>(); returned.Name = dataRecipe.Name; returned.Id = dataRecipe.Id; returned.MinutesToMake = dataRecipe.MinutesToMake; returned.Description = dataRecipe.Description; returned.Calories = dataRecipe.Calories; returned.NutritionType = dataRecipe.NutritionType; returned.Image = dataRecipe.Image; returned.Price = dataRecipe.Price; List <string> ids = dataRecipe.IngredientIdList.Split(",").ToList(); List <string> quantity = dataRecipe.IngredientQuantityList.Split(",").ToList(); for (int i = 0; i < ids.Count - 1; i++) { RecipeItem temp = new RecipeItem(); temp.IngredientId = Convert.ToInt32(ids[i]); temp.Amount = Convert.ToInt32(quantity[i]); returned.Ingredient.Add(temp); } return(returned); }
private string GetIcon(RecipeItem item, bool inputIngots) { String name = Utils.OreGot(item.name, !inputIngots); bool range = item.start != 0 || item.stop != 0; string value; if (item.value == 0) { value = String.Format("{0}-{1}", Utils.FormatNumber(item.start), Utils.FormatNumber(item.stop)); } else { value = Utils.FormatNumber(item.value); } var imgName = name; if (name == "Carbon" || name == "Hydrocarbon") { imgName = "ItemCoalOre"; } String className = range ? "stationeers-icon icon-range" : "stationeers-icon"; return(String.Format("<div class=\"{0}\">[[File:{1}.png|link={2}]] <div class=\"stationeers-icon-text\">{3}</div></div>", className, imgName, GetTranslatedName(name), value)); }
public override string Execute() { try { string heroName = args[1]; IHero hero = this.manager.heroes[heroName]; string itemName = args[0]; int strengthBonus = int.Parse(args[2]); int agilityBonus = int.Parse(args[3]); int intelligenceBonus = int.Parse(args[4]); int hitPointsBonus = int.Parse(args[5]); int damageBonus = int.Parse(args[6]); List <string> neededList = args.Skip(7).ToList(); IRecipe recipeItem = new RecipeItem(itemName, strengthBonus, agilityBonus, intelligenceBonus, hitPointsBonus, damageBonus, neededList); hero.AddRecipe(recipeItem); return(string.Format(Constants.RecipeCreatedMessage, itemName, heroName)); } catch (Exception e) { return(e.Message); } }
public string AddRecipe(IList <string> arguments) { string itemName = arguments[0]; string heroName = arguments[1]; int strengthBonus = int.Parse(arguments[2]); int agilityBonus = int.Parse(arguments[3]); int intelligenceBonus = int.Parse(arguments[4]); int hitPointsBonus = int.Parse(arguments[5]); int damageBonus = int.Parse(arguments[6]); var requiredItems = arguments.Skip(7).ToList().Where(i => i != "").ToList(); var newItem = new RecipeItem( itemName, strengthBonus, agilityBonus, intelligenceBonus, hitPointsBonus, damageBonus, requiredItems); this.heroes[heroName].AddRecipe(newItem); string result = string.Format(Constants.RecipeCreateMessage, itemName, heroName); return(result); }
public IActionResult DeleteData(RecipeFormViewModelData recipe) { RecipeItem newRecipe = new RecipeItem(); newRecipe.RecipeName = recipe.RecipeName; newRecipe.ServingSize = recipe.ServingSize; newRecipe.Description = recipe.Description; newRecipe.RecipeId = recipe.RecipeId; Ingredient newIngredient = new Ingredient(); newIngredient.IngredientName = recipe.Ingredient; newIngredient.IngredientId = recipe.RecipeId; Equipment newEquipment = new Equipment(); newEquipment.EquipmentName = recipe.Equipment; newEquipment.EquipmentId = recipe.RecipeId; newRecipe.Instructions = recipe.Instructions; Review newReview = new Review(); newReview.ReviewText = recipe.Review; newReview.ReviewId = recipe.RecipeId; repository.DeleteRecipe(newRecipe); repository.DeleteReview(newReview); repository.DeleteIngredient(newIngredient); repository.DeleteEquipment(newEquipment); return(RedirectToAction("DataPage", "Home")); }
public void ResolveRecipe(RecipeCounter counter, RecipeItem parent, int depth, bool resolveDeep, bool addWorkbenchItem) { foreach (var ingredient in parent.Ingredients) { ingredient.Parent = parent; ingredient.Depth = depth; if (ingredient.Item.RecipeId > 0 && resolveDeep) { ingredient.Ingredients = SelectRecipe(counter, ingredient.Item); ++depth; ResolveRecipe(counter, ingredient, depth, true, addWorkbenchItem); CalculateRecipe(ingredient); if (ingredient.Depth > 0) { ingredient.IngredientSum = CreateIngredientItem(counter, ingredient); } parent.MaxDepth = Math.Max(depth, ingredient.MaxDepth); depth--; } } if (addWorkbenchItem) { AddWorkbenchCostItem(counter, parent, depth); } }
public async Task <Product> CreateOrderAsync(int id, string basketId) { // get basket from the repo var basket = await _basketRepo.GetBasketAsync(basketId); // get items from the product repo var items = new List <RecipeItem>(); foreach (var item in basket.Items) { var productItem = await _unitOfWork.Repository <Ingredient>().GetByIdAsync(item.Id); var itemOrdered = new IngredientItemAdded(productItem.Id, productItem.Name); var orderItem = new RecipeItem(itemOrdered, productItem.Price, item.Quantity); items.Add(orderItem); } // create order var order = new Product(items); _unitOfWork.Repository <Product>().Add(order); // save to db var result = await _unitOfWork.Complete(); if (result <= 0) { return(null); } // return order return(order); }
public string AddRecipeToHero(List <string> arguments) { string result = null; string recipeName = arguments[0]; string heroName = arguments[1]; long strengthBonus = long.Parse(arguments[2]); long agilityBonus = long.Parse(arguments[3]); long intelligenceBonus = long.Parse(arguments[4]); long hitPointsBonus = long.Parse(arguments[5]); long damageBonus = long.Parse(arguments[6]); List <string> requiredItems = arguments.Skip(7).ToList(); IRecipe newRecipe = new RecipeItem(recipeName, strengthBonus, agilityBonus, intelligenceBonus, hitPointsBonus, damageBonus, requiredItems); this.heroes[heroName].AddRecipe(newRecipe); result = string.Format(Constants.RecipeCreatedMessage, newRecipe.Name, heroName); return(result); }
public override void _Ready() { click = (AudioStreamPlayer)GetTree().GetRoot().GetNode("SceneSwitcher/Click"); paper = (NinePatchRect)GetNode("ReferenceRect/NinePatchRect"); holder = (ReferenceRect)GetNode("ReferenceRect"); riPrefab = (PackedScene)ResourceLoader.Load("res://Instances/RecipeItem.tscn"); GetRecipes(); Vector2 pos = new Vector2(53, 192); foreach (Recipe r in recipes) { RecipeItem recipeItem = (RecipeItem)riPrefab.Instance(); recipeItem.name = r.name; recipeItem.ingredients = r.ingredients; recipeItem.SetPosition(pos); GetNode("ReferenceRect").AddChild(recipeItem); pos.y += 139; } Button button = (Button)GetNode("ReferenceRect/Button"); pos.x = 29; pos.y += 30; button.SetPosition(pos); NinePatchRect ninePatchRect = (NinePatchRect)GetNode("ReferenceRect/NinePatchRect"); ninePatchRect.SetSize(new Vector2(ninePatchRect.GetSize().x, pos.y + 102)); }
public async Task <ActionResult <RecipeItem> > PostRecipeItem(RecipeItem item) { _context.RecipeItems.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetRecipeItem), new { id = item.Id }, item)); }
private static bool RemoveRequiredItemsFromInventory(GameSession session, RecipeMetadata recipe) { List <Item> playerInventoryItems = new(session.Player.Inventory.Items.Values); List <RecipeItem> ingredients = recipe.GetIngredients(); for (int i = 0; i < ingredients.Count; i++) { RecipeItem ingredient = ingredients.ElementAt(i); Item item = playerInventoryItems.FirstOrDefault(x => x.Id == ingredient.Id); if (item == null) { continue; } // check if whole stack will be used, and remove the item // otherwise we want to just want to subtract the amount if (ingredient.Amount == item.Amount) { InventoryController.Remove(session, item.Uid, out Item _); } else { InventoryController.Update(session, item.Uid, item.Amount - ingredient.Amount); } } return(true); }
public async Task <IActionResult> PutRecipeItem(int id, RecipeItem recipeItem) { if (id != recipeItem.ID) { return(BadRequest()); } _context.Entry(recipeItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Retrieve all recipe items owned by a recipe. /// </summary> /// <param name="owner">The owner of the desired recipe items.</param> /// <returns>The owned recipe items.</returns> public IList <RecipeItem> GetRecipeItemsByOwner(Recipe owner) { List <RecipeItem> res = new List <RecipeItem>(); string cmd = $"SELECT {RI_TABLE_NAME}.{RI_ID_COL}, {RI_TABLE_NAME}.{RI_PERCENTAGE_COL}, " + $"{FLAVOR_TABLE_NAME}.{FLAVOR_ID_COL}, {FLAVOR_TABLE_NAME}.{FLAVOR_NAME_COL}, " + $"{FLAVOR_TABLE_NAME}.{FLAVOR_PG_COL}, {FLAVOR_TABLE_NAME}.{FLAVOR_RECPER_COL} " + $"FROM {RI_TABLE_NAME} JOIN {FLAVOR_TABLE_NAME} " + $"ON {RI_TABLE_NAME}.{RI_FLAVOR_COL}={FLAVOR_TABLE_NAME}.{FLAVOR_ID_COL} " + $"JOIN {RECIPE_RI_TABLE_NAME} " + $"ON {RI_TABLE_NAME}.{RI_ID_COL}={RECIPE_RI_TABLE_NAME}.{RECIPE_RI_RI_ID} " + $"WHERE {RECIPE_RI_RECIPE_ID}={owner.ID};"; try { ICursor iter = ReadableDatabase.RawQuery(cmd, null); while (iter.MoveToNext()) { RecipeItem ri = ParseRecipeItem(iter); if (ri != null) { res.Add(ri); } } iter.Close(); } catch (SQLiteAbortException e) { Console.WriteLine(e.Message); } return(res); }
/// <summary> /// Execute RemoveRecipeItemCommand /// </summary> /// <param name="item">Selected item to be processed.</param> private void ExecuteRemoveRecipeItemCommand(RecipeItem item) { try { if (item == null) { throw new ArgumentNullException("item"); } //this.Item.Recipes.Remove(item); if (this.Item.Recipes.Contains(item)) { this.Item.Recipes.Remove(item); List <RecipeItem> list = (List <RecipeItem>)(this.Item.Recipes as IEditableCollection).GetDeletedList(); string message = "Deleted List: \n"; foreach (RecipeItem recipeItem in list) { message += recipeItem.MaterialInfo.Name + "\n"; } this.MessageBoxService.ShowInformation(message); } else { this.MessageBoxService.ShowInformation("This item is not in the list."); } } catch (Exception ex) { this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } }
public void Chech_Add_Recipe_To_Inventory_Without_Making_Item() { HeroInventory heroInventory = new HeroInventory(); var item1 = new CommonItem("a", 1, 1, 1, 1, 1); var item2 = new CommonItem("b", 1, 1, 1, 1, 1); heroInventory.AddCommonItem(item1); heroInventory.AddCommonItem(item2); var combine = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b", "c" }); heroInventory.AddRecipeItem(combine); Type type = heroInventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(heroInventory); Assert.AreEqual(2, items.Count); var item3 = new CommonItem("c", 1, 1, 1, 1, 1); heroInventory.AddCommonItem(item3); Assert.AreEqual(1, items.Values.Count); }
public void Check_Combine_Method_In_HeroInventory() { var inventory = new HeroInventory(); var item1 = new CommonItem("a", 1, 1, 1, 1, 1); var item2 = new CommonItem("b", 1, 1, 1, 1, 1); var item3 = new CommonItem("c", 1, 1, 1, 1, 1); var item4 = new CommonItem("d", 1, 1, 1, 1, 1); var combine = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b" }); inventory.AddCommonItem(item1); inventory.AddCommonItem(item2); inventory.AddCommonItem(item3); inventory.AddCommonItem(item4); inventory.AddRecipeItem(combine); Type type = inventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(inventory); Assert.AreEqual(3, items.Values.Count); }
private static RecipeItem CreateIngredientItem(RecipeItem item) { var ingredientSum = new RecipeItem { Id = -1, Depth = item.Depth, Item = new Item { Id = item.Item.Id, RecipeId = item.Item.RecipeId, Name = item.Item.Name, SellPrice = item.SumSell, BuyPrice = item.SumBuy, SellOffers = item.Item.SellOffers, BuyOrders = item.Item.BuyOrders, RarityId = item.Item.RarityId, RarityName = item.Item.RarityName, CategoryId = item.Item.CategoryId, CategoryName = item.Item.CategoryName, TypeId = item.Item.TypeId, TypeName = item.Item.TypeName } }; ingredientSum.Parent = item; ingredientSum.IsSumRow = true; return(ingredientSum); }
private void HandleAddNewIngredientCommand(object parameter) { RecipeItem selectedRecipeItem = parameter as RecipeItem; selectedRecipeItem.RecipeItems_Ingredients.Add(new RecipeItems_Ingredients()); this.OnPropertyChanged("Recipe"); }
public AddRecipeResponse AddRecipes(AddRecipeRequest request) { var response = new AddRecipeResponse(); var recipe = new Recipe { Title = request.model.Title }; if (request.model.Ingredients != null && request.model.Ingredients.Count() > 0) { var items = new List <RecipeItem>(); foreach (var item in request.model.Ingredients) { var newItem = new RecipeItem { IngredientId = item.IngredientId, Measure = (Measure)item.Measure, Quantity = item.Quantity }; items.Add(newItem); } recipe.Ingredients = items.AsEnumerable(); } if (!recipe.isValid()) { throw new BusinessRuleException("There was some errors", recipe.getBrokedRules()); } _recipeRepository.Insert(recipe); _unitOfWork.Commit(); response.recipe = recipe.ToRecipeViewModel(); return(response); }
public void TestAddingNewRecipeItemInInventory() { //Arrange CommonItem item = new CommonItem("item", 1, 2, 3, 4, 5); CommonItem item2 = new CommonItem("item2", 1, 2, 3, 4, 5); IRecipe recipe = new RecipeItem("recipe", 10, 20, 30, 40, 50, new List <string>() { item.Name, item2.Name }); //Act this.inventory.AddCommonItem(item); this.inventory.AddCommonItem(item2); this.inventory.AddRecipeItem(recipe); Type inventoryType = typeof(HeroInventory); var fieldItemColl = inventoryType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .FirstOrDefault(f => f.GetCustomAttributes(typeof(ItemAttribute)) != null); var collectionItem = (Dictionary <string, IItem>)fieldItemColl.GetValue(this.inventory); var fieldRecipeColl = inventoryType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic).Skip(1) .FirstOrDefault(); var collectionRecipe = (Dictionary <string, IRecipe>)fieldRecipeColl.GetValue(this.inventory); //Assert Assert.AreEqual(10, this.inventory.TotalStrengthBonus); Assert.AreEqual(20, this.inventory.TotalAgilityBonus); Assert.AreEqual(30, this.inventory.TotalIntelligenceBonus); Assert.AreEqual(40, this.inventory.TotalHitPointsBonus); Assert.AreEqual(50, this.inventory.TotalDamageBonus); Assert.AreEqual(1, collectionItem.Count); Assert.AreEqual(1, collectionRecipe.Count); }
public ViewResult InsertPage(RecipeFormViewModelData recipe) { if (ModelState.IsValid) { RecipeItem newRecipe = new RecipeItem(); newRecipe.RecipeName = recipe.RecipeName; newRecipe.ServingSize = recipe.ServingSize; newRecipe.Description = recipe.Description; Ingredient newIngredient = new Ingredient(); newIngredient.IngredientName = recipe.Ingredient; Equipment newEquipment = new Equipment(); newEquipment.EquipmentName = recipe.Equipment; newRecipe.Instructions = recipe.Instructions; repository.AddRecipe(newRecipe); repository.AddIngredient(newIngredient); repository.AddEquipment(newEquipment); repository.AddReview(new Review()); return(View("DataPage", repository.Recipes)); } else { return(View()); } }
public async Task <List <Recipe> > GetRecipes() { List <Recipe> recipes = new List <Recipe>(); List <Models.DB.Recipe> fromDB = await this.foodDatabase.GetRecipes(); foreach (var recipeFromDB in fromDB) { Recipe recipe = ConvertFromDb(recipeFromDB); recipes.Add(recipe); List <Models.DB.RecipeItem> items = await this.foodDatabase.GetRecipeItems(recipeFromDB.Id); foreach (var recipeItemDB in items) { Models.DB.Food foodDb = await this.foodDatabase.FoodById(recipeItemDB.FoodId); RecipeItem recipeItem = ConvertFromDb(recipeItemDB); recipeItem.Food = FoodRepository.ConvertFromDb(foodDb); recipe.Items.Add(recipeItem); } } return(recipes); }
public void Init(RecipeItem recipeItem,bool WithButtons) { base.Init(recipeItem,true, WithButtons); mainIcon.sprite = recipeItem.IconSprite; NameLabel.text = recipeItem.Name; RecipeButton.gameObject.SetActive(WithButtons); // SlotLabel.sprite = DataBaseController.Instance.SlotIcon(recipeItem.Slot); }
public void OnAddToCauldron(RecipeItem item) { var matchingIcon = recipeIcons.Find(i => i.itemName == item.itemName); if (matchingIcon != null) { StartCoroutine(ShowOnRecipeCo(matchingIcon)); } }
public void InsertRecipe() { var recipe = new PrivateRecipe(); var item1= new RecipeItem {Description = "Step 1"}; var item2= new RecipeItem {Description = "Step 2"}; recipe.Add(item1); recipe.Add(item2); privateRecipeRepository.Insert(recipe); }
public void ClearShouldRemoveAllItems() { var sut = new PrivateRecipe(_author, _title); var recipeItem1 = new RecipeItem(_itemDescription, sut); var recipeItem2 = new RecipeItem(_itemDescription, sut); sut.Add(recipeItem1); sut.Add(recipeItem2); sut.Clear(); sut.Items.Count.ShouldEqual(0); }
public void Init(RecipeItem recipeItem,Action<BaseItem> OnCraftComplete ) { this.OnCraftComplete = OnCraftComplete; gameObject.SetActive(true); if (recipeItem.recipeSlot != Slot.Talisman) { string icon; RenderCam.Instance.DoRender(recipeItem.recipeSlot, out icon); Utils.LoadTexture(icon,out iconSprite); } else { // iconSprite = DataBaseController.Instance.TalismanIcon() } selectedCatalysItem = null; CraftInfoPlace.Init(recipeItem,null); this.recipeItem = recipeItem; elements.Clear(); BaseWindow.ClearTransform(CraftItemsLayout); canCraft = true; foreach (var craftElement in recipeItem.ItemsToCraft()) { if (craftElement.count > 0) { CraftItemElement craftItemElement = DataBaseController.GetItem<CraftItemElement>(CraftItemPrefab); craftItemElement.transform.SetParent(CraftItemsLayout, false); craftItemElement.Init(craftElement); if (!craftItemElement.IsEnought) { failElement = craftItemElement; canCraft = false; } } } var allCatalys = MainController.Instance.PlayerData.GetAllItems().Where(x => x is ExecCatalysItem); BaseWindow.ClearTransform(CatalysItemsLayout); foreach (var cat in allCatalys) { CatalysItemElement catalysItemElement = DataBaseController.GetItem<CatalysItemElement>(CatalysItemPrefab); catalysItemElement.Init(cat as ExecCatalysItem, OnCatalysClick); catalysItemElement.transform.SetParent(CatalysItemsLayout,false); catalysElements.Add(catalysItemElement); } CatalysItemElement catalysItemElementFree = DataBaseController.GetItem<CatalysItemElement>(CatalysItemPrefab); catalysItemElementFree.Init(null, OnCatalysClick); catalysItemElementFree.transform.SetParent(CatalysItemsLayout, false); catalysElements.Add(catalysItemElementFree); CraftResultPlace.Init(iconSprite, null); }
public unsafe void WriteOrder(RecipeItem[] item, int startIndex) { if (item == null || ((item.Length - startIndex) < 8)) return; for (int i = 0; i < 8; i++) { id[i] = (ushort) item[startIndex + i].id; count[i] = (byte) item[startIndex + i].count; order[i] = (byte) item[startIndex + i].order; } int addr; MemoryProvider.ReadProcessMemory(windower.pol.Handle, (IntPtr) ((int) windower.pol.BaseAddress + Offset.Get("ORDER_INFO")), &addr, sizeof(int), null); fixed (ushort* buf = id) { MemoryProvider.WriteProcessMemory(windower.pol.Handle, (IntPtr) (addr + 0x2a + sizeof(ushort)), buf, sizeof(ushort) * 8, null); } fixed (byte* buf = count) { MemoryProvider.WriteProcessMemory(windower.pol.Handle, (IntPtr) (addr + 0x40), buf, sizeof(byte) * 8, null); } fixed (byte* buf = order) { MemoryProvider.WriteProcessMemory(windower.pol.Handle, (IntPtr) (addr + 0x14 + sizeof(byte)), buf, sizeof(byte) * 8, null); } }
IEnumerator AddItemCo(ObtainableItem item, RecipeItem recipeItem) { Debug.Log(item+" has been added to the cauldron."); ingredientsUsed += 1; recipeItem.collected += 1; var itemRigidbody = item.GetComponent<Rigidbody>(); if (itemRigidbody != null) { itemRigidbody.useGravity = false; itemRigidbody.isKinematic = true; } LeanTween.move(item.gameObject, transform.position + Vector3.up * 1f, 1f).setEase(LeanTweenType.easeOutCubic); yield return new WaitForSeconds(1f); var targetPosition = pointInside.position; LeanTween.move(item.gameObject, targetPosition, 0.5f); audioPlayer.PlayOneShotAfterSec(0, 0.25f); if (ingredientsUsed == 1 && GetComponent<PlaysAudioRemarkOnRadio>() != null && !potionIsReady) GetComponent<PlaysAudioRemarkOnRadio>().Play(0); yield return new WaitForSeconds(0.5f); foreach (GameObject subscriber in subscribers) { subscriber.SendMessage("OnAddToCauldron", recipeItem, SendMessageOptions.DontRequireReceiver); } item.gameObject.SetActive(false); isAbleToInteract = true; if (potionIsReady) GivePotion(); }
private string AddPrivateRecipeItem(Command command) { var itemDesc = command.MainObjPair.Value; if (string.IsNullOrEmpty(itemDesc)) return "Item cannot be empty"; if (command.OptionalCommandPairs == null || command.OptionalCommandPairs.Count == 0) { return "Add item must associate with a recipe"; } int recipeId; if (int.TryParse(command.OptionalCommandPairs[0].Value, out recipeId) == false) { return "Add item must specify a recipe ID"; } var recipe = _privateRecipeRepository.GetById(recipeId); if (recipe == null) return $"Recipe with ID [{recipeId}] not found"; var item = new RecipeItem(itemDesc, recipe); recipe.Add(item); _privateRecipeRepository.Update(recipe); return "Item created successfully"; }
public void OpenCraft(RecipeItem recipe) { CraftWindow.Init(recipe, OnCraftComplete); }
public void Init(RecipeItem recipeItem,CatalysItemType? type) { Utils.ClearTransform(LayoutSpecials); var totalPoints = Formuls.GetPlayerItemPointsByLvl(recipeItem.Level) * Formuls.GetSlotCoef(recipeItem.recipeSlot); float min; float max; switch (recipeItem.recipeSlot) { case Slot.physical_weapon: case Slot.magic_weapon: if (type.HasValue) { var spedAbilities = RecipeItem.PosibleAbilities(type.Value); foreach (var specialAbility in spedAbilities) { var icon = DataBaseController.Instance.SpecialAbilityIcon(specialAbility); var img = Instantiate(PrefabSpecialIcon).GetComponent<Image>(); img.sprite = icon; img.transform.SetParent(LayoutSpecials,false); } } min = totalPoints * 0.5f; max = totalPoints; MainParameterField.text = min.ToString("0") + " - " + max.ToString("0"); switch (recipeItem.recipeSlot) { case Slot.physical_weapon: MainParameterIcon.sprite = DataBaseController.Instance.ParameterIcon(ParamType.PPower); break; case Slot.magic_weapon: MainParameterIcon.sprite = DataBaseController.Instance.ParameterIcon(ParamType.MPower); break; } break; case Slot.body: case Slot.helm: min = totalPoints * 0.5f; max = totalPoints; switch (recipeItem.recipeSlot) { case Slot.body: MainParameterIcon.sprite = DataBaseController.Instance.ParameterIcon(ParamType.PDef); break; case Slot.helm: MainParameterIcon.sprite = DataBaseController.Instance.ParameterIcon(ParamType.MDef); break; } var secondary = HeroShopRandomItem.GetSecondaryParam(totalPoints, recipeItem.recipeSlot); var prm = Instantiate(PrefabSecondaryParam); var img2 = prm.GetComponent<Image>(); var filed = prm.GetComponentInChildren<Text>(); var minS = secondary.Value*0.5f; var maxS = secondary.Value; MainParameterField.text = min.ToString("0") + " - " + max.ToString("0"); string info = ""; Sprite spr = null; if (type.HasValue) { switch (type.Value) { case CatalysItemType.red: min *= 1.25f; max *= 1.25f; MainParameterField.text = min.ToString("0") + " - " + max.ToString("0"); break; case CatalysItemType.blue: break; case CatalysItemType.green: info = "Chance to get new talisman."; break; case CatalysItemType.black: min *= 1f; max *= 1.5f; MainParameterField.text = min.ToString("0") + " - " + max.ToString("0"); break; case CatalysItemType.white: info = "cost x2"; spr = DataBaseController.Instance.ItemIcon(ItemId.money); break; } } else { info = minS.ToString("0") + " - " + maxS.ToString("0"); spr = DataBaseController.Instance.ParameterIcon(secondary.Key); } filed.text = info; if (spr == null) { img2.enabled = false; } img2.sprite = spr; img2.transform.SetParent(LayoutSpecials, false); break; case Slot.Talisman: break; } }
public object Clone() { RecipeItem item = new RecipeItem(); item.id = this.id; item.count = this.count; item.name = this.name; item.check = this.check; return item; }
public void InsertShouldInsertItemAtSpecifiedIndex() { var sut = new PrivateRecipe(_author, _title); var recipeItem1 = new RecipeItem(_itemDescription, sut); var recipeItem2 = new RecipeItem(_itemDescription, sut); sut.Add(recipeItem1); sut.Insert(recipeItem2, 0); sut.Items[0].ShouldBeSameAs(recipeItem2); }
public RecipeItemViewModel(RecipeItem model, IWorkspace workspace, IInventoryService inventoryService) { Model = model; _workspace = workspace; _inventoryService = inventoryService; }
public void RemoveShouldRemoveItem() { var sut = new PrivateRecipe(_author, _title); var recipeItem1 = new RecipeItem(_itemDescription, sut); var recipeItem2 = new RecipeItem(_itemDescription, sut); sut.Add(recipeItem1); sut.Add(recipeItem2); sut.Remove(recipeItem1); sut.Items.Count.ShouldEqual(1); sut.Items[0].ShouldBeSameAs(recipeItem2); }
public void ClearShouldUpdateLastModifiedTime() { var sut = new PrivateRecipe(_author, _title); var recipeItem1 = new RecipeItem(_itemDescription, sut); var recipeItem2 = new RecipeItem(_itemDescription, sut); sut.Add(recipeItem1); sut.Add(recipeItem2); var oldTime = sut.TimeLastModified; Thread.Sleep(100); sut.Clear(); var newTime = sut.TimeLastModified; newTime.ShouldNotEqual(oldTime); }