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); } }
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); }
private static RecipeItem CreateIngredientItem(RecipeCounter counter, RecipeItem item) { var ingredientSum = new RecipeItem(counter) { 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); }
public List <RecipeItem> SelectRecipe(RecipeCounter counter, Item item) { var parmeter = new List <Parameter>(); parmeter.Add(new Parameter { Identifier = "id", Value = item.RecipeId }); string query = BuildRecipeQuery(); var ds = DB.SelectDataSet(query, parmeter); return(RecipeItem.Create(counter, new RecipeItem(counter) { Item = item }, ds)); }
public RecipeModel SelectRecipeModel(Item item, bool resolveDeep, bool addWorkbenchItem = true) { RecipeModel recipeModel = new RecipeModel(); RecipeCounter counter = new RecipeCounter(); recipeModel.Recipe = new RecipeItem(counter) { Item = item, Ingredients = SelectRecipe(counter, item) }; ResolveRecipe(counter, recipeModel.Recipe, 1, resolveDeep, addWorkbenchItem); CalculateRecipe(recipeModel.Recipe); recipeModel.Recipe.IngredientSum = CreateIngredientItem(counter, recipeModel.Recipe); return(recipeModel); }
public void AddWorkbenchCostItem(RecipeCounter counter, RecipeItem parent, int depth) { if (parent.Ingredients.Count > 0) { var rarity = (Rarity)parent.Item.RarityId; // We don't want common (no workbench costs) to be displayed. // Also incase the workbench costs are not based on the rarity we use the override value from the DB if (parent.Item.WorkbenchRarity > 0) { rarity = (Rarity)parent.Item.WorkbenchRarity; } if (rarity != Rarity.Common_1) { var id = GetWorkbenchItemIdByRarity(rarity); var workbenchItem = SelectItem((int)id, false); parent.Ingredients.Add(CreateIngredientWorkbenchItem(counter, parent, workbenchItem, depth)); } } }