Esempio n. 1
0
        private static decimal CalcFullCraftCost(this Project project, RecipeItem recipeItem)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }
            if (recipeItem == null)
            {
                throw new ArgumentNullException(nameof(recipeItem));
            }

            var item = project.Items.FirstOrDefault(i => i.Id == recipeItem.ItemId);

            if (item == null)
            {
                throw new Exception();
            }

            var recipe = project.Recipes.FirstOrDefault(r => r.Result != null && r.Result.ItemId == item.Id);

            if (recipe != null)
            {
                var itemCraftCost = project.CalcFullCraftCost(recipe);
                return(recipeItem.Count * itemCraftCost);
            }
            else
            if (item.Cost != null)
            {
                return(recipeItem.Count * item.Cost.Value);
            }

            return(0);
        }
Esempio n. 2
0
        public void Add(RecipeItem recipeItem)
        {
            if (recipeItem == null)
            {
                throw new ArgumentNullException(nameof(recipeItem));
            }

            if (recipeItem.Count < 1)
            {
                throw new ArgumentException(nameof(recipeItem.Count));
            }

            var list = Items.ToList();

            list.Add(recipeItem);
            Items = list.ToArray();
        }
Esempio n. 3
0
 public Recipe()
 {
     Items = new RecipeItem[0];
 }