Beispiel #1
0
        public void AddToStock(IIngredient ingredient, Measure measure, double quantity)
        {
            double factor = measure.GetEquivalence(ingredient.PackingMeasure, ingredient);

            quantity *= factor;

            var ingStock = this.CurrentStock.SingleOrDefault(c => c.Ingredient == ingredient);

            if (ingStock == null)
            {
                ingStock = new IngredientStock
                {
                    Ingredient = ingredient,
                    Quantity   = quantity
                };

                this.CurrentStock.Add(ingStock);
            }
            else
            {
                ingStock.Quantity += quantity;
            }

            if (ingStock.Quantity < 0)
            {
                _notifier.Notify("Stock", "La cantidad de un ingrediente en stock NO puede ser menor a cero!", Severity.Warning);
            }
        }
Beispiel #2
0
        public double GetEquivalence(Measure measureTo, IIngredient ingredient)
        {
            double factor;

            if (this.Equals(measureTo))
            {
                factor = 1.0;
            }
            else
            {
                var equiv = Equivalences.SingleOrDefault(e => e.From == this && e.To == measureTo && e.Ingredient == ingredient);

                if (equiv == null)
                {
                    //pruebo la equivalencia opuesta
                    equiv = Equivalences.SingleOrDefault(e => e.From == measureTo && e.To == this && e.Ingredient == ingredient);

                    if (equiv == null)
                    {
                        _notifier.Notify("Equivalence", $"Equivalencia inexistente entre {this.Name} y {measureTo.Name}!", Severity.Error);
                        return(0.0);
                    }

                    factor = 1.0 / equiv.Factor; //invierto la equivalencia
                }
                else
                {
                    factor = equiv.Factor;
                }
            }

            return(factor);
        }
 public void OnIngredientAdd(ISubject subject, IIngredient ingredient)
 {
     for (var i = 0; i < _dishEvents.onDishAddIngredient.Count; ++i)
     {
         _dishEvents.onDishAddIngredient[i].TryInvoke(ingredient.GetIngredientType());
     }
 }
Beispiel #4
0
        public void AddIngredient(int ingredientId, IIngredient ingredient)
        {
            Validator.ValidateIntRange(ingredientId, 0, int.MaxValue, IdCannotBeNegativeNumber);
            Validator.ValidateNull(ingredient, string.Format(CannotAddNullObject, nameof(ingredient)));

            this.ingredients.Add(ingredientId, ingredient);
        }
        public void VisitIngredients(IIngredient ingredient)
        {
            if (ingredient.HealthRating == HealthRating.NotRated ||
                ingredient.Calories == 0)
            {
                return;
            }

            string padding = "";

            if (string.IsNullOrEmpty(ingredient.IngredientName))
            {
                Console.WriteLine("--- Item {0} ---", ingredient.GetType().Name);
            }
            else
            {
                Console.WriteLine("   --- Ingredient {0} ---", ingredient.IngredientName);
                padding = "        ";
            }
            Console.WriteLine(padding + "Health Rating: {0}", ingredient.HealthRating);
            Console.WriteLine(padding + "Calories: {0}", ingredient.Calories);
            Console.WriteLine(padding + "Carbs: {0}", ingredient.Carbs);
            Console.WriteLine(padding + "Protein: {0}", ingredient.Protein);
            Console.WriteLine();
        }
Beispiel #6
0
    public void OnIngredientAdd(ISubject subject, IIngredient ingredient)
    {
        var sideDish = subject as Dish;

        if (sideDish != null)
        {
            for (var i = 0; i < _sideDishesLeft.Count; ++i)
            {
                if (sideDish == _sideDishesLeft[i])
                {
                    if (_debugLog)
                    {
                        Debug.Log(sideDish + " found");
                    }
                    for (var j = 0; j < _sideDishesMeshIngredientTypes.Count; ++j)
                    {
                        if (_sideDishesMeshIngredientTypes[j] == ingredient.GetIngredientType())
                        {
                            if (_debugLog)
                            {
                                Debug.Log(ingredient + " is one of the meshes");
                            }
                            _sideDishMeshesToEnable[i].Add(_sideDishMeshes[j]);
                            _sideDishesMeshIngredientTypes.RemoveAt(j);
                            _sideDishMeshes.RemoveAt(j);
                            break;
                        }
                    }

                    break;
                }
            }
        }
    }
Beispiel #7
0
 protected void InformObserversAddIngredient(IIngredient ingredient)
 {
     for (var i = 0; i < _observers.Count; ++i)
     {
         _observers[i].OnIngredientAdd(this, ingredient);
     }
 }
        public void AddIngredient(IIngredient ingredient)
        {
            if (ingredient == null)
            throw new ArgumentNullException ("ingredient");

             m_list.Add (ingredient);
        }
Beispiel #9
0
        public static void Main(string[] args)
        {
            Chef chef = new Chef();

            IIngredient[] list = new IIngredient[] { new Carrot(), new Potato() };
            chef.Cook(list);
        }
        public static void Postfix(ITechData data, ref List <TooltipIcon> icons)
        {
            if (data == null)
            {
                return;
            }
            int ingredientCount = data.ingredientCount;

            for (int i = 0; i < ingredientCount; i++)
            {
                IIngredient ingredient = data.GetIngredient(i);
                TechType    techType   = ingredient.techType;
                if (!KnownTech.Contains(techType) && PDAScanner.ContainsCompleteEntry(techType))
                {
                    KnownTech.Add(techType);
                    continue;
                }
                if (!CrafterLogic.IsCraftRecipeUnlocked(techType))
                {
                    TooltipIcon icon = icons.Find((TooltipIcon) => TooltipIcon.sprite == SpriteManager.Get(techType) && TooltipIcon.text.Contains(Language.main.GetOrFallback(TooltipFactory.techTypeIngredientStrings.Get(techType), techType)));
                    if (icons.Contains(icon))
                    {
                        icons.Remove(icon);
                        var tooltipIcon = new TooltipIcon()
                        {
                            sprite = SpriteManager.Get(TechType.None), text = Main.config.UnKnownTitle
                        };
                        icons.Add(tooltipIcon);
                    }
                }
            }
        }
Beispiel #11
0
        public void ContainerResolvesIngredientThroughExtensionMethod()
        {
            var         context    = new XmlApplicationContext("sauce.xml");
            IIngredient ingredient = context.Resolve <IIngredient>();

            Assert.IsAssignableFrom <SauceBéarnaise>(ingredient);
        }
Beispiel #12
0
        public Task <bool> AddIngredient(Guid recipeId, IIngredient ingredient)
        {
            return(Task.Run(() =>
            {
                using var context = new HomeAppDbContext(myDbOptions);

                DbProduct product = context.Products.FirstOrDefault(p => p.Id.Equals(ingredient.ProductId));
                if (product == null)
                {
                    return false;
                }
                DbRecipe recipe = context.Recipes.FirstOrDefault(p => p.Id.Equals(recipeId));
                if (product == null)
                {
                    return false;
                }
                context.Ingredients.AddAsync(new DbIngredient
                {
                    Product = product,
                    Recipe = recipe,
                    UnitQuantity = ingredient.UnitQuantity,
                    UnitQuantityType = ingredient.UnitQuantityType
                });
                context.SaveChanges();
                return true;
            }));
        }
        public static bool ConsumeResources(TechType techType)
        {
            if (!IsCraftRecipeFulfilled(techType))
            {
                ErrorMessage.AddWarning(Language.main.Get("DontHaveNeededIngredients"));
                return(false);
            }

            var       itemsContainers = FindAllItemsContainersInRange();
            ITechData techData        = CraftData.Get(techType, false);

            if (techData == null)
            {
                return(false);
            }
            int i = 0;
            int ingredientCount = techData.ingredientCount;

            while (i < ingredientCount)
            {
                IIngredient ingredient = techData.GetIngredient(i);
                TechType    techType2  = ingredient.techType;
                int         j          = 0;
                int         amount     = ingredient.amount;
                while (j < amount)
                {
                    DestroyItemInContainers(techType2, itemsContainers);
                    uGUI_IconNotifier.main.Play(techType2, uGUI_IconNotifier.AnimationType.To, null);
                    j++;
                }
                i++;
            }
            return(true);
        }
Beispiel #14
0
        public void RemoveIngredient(IIngredient ingredient)
        {
            Validator.ValidateNull(ingredient, $"The ingredient is null!");
            int index = this.Ingredients.FindIndex(item => item.Igredient.Name.Equals(ingredient.Name));

            this.Ingredients.RemoveAt(index);
        }
        public static bool IsCraftRecipeFulfilled(TechType techType)
        {
            if (Inventory.main == null)
            {
                return(false);
            }
            if (!GameModeUtils.RequiresIngredients())
            {
                return(true);
            }

            var       itemContainers = FindAllItemsContainersInRange();
            ITechData techData       = CraftData.Get(techType, false);

            if (techData != null)
            {
                int i = 0;
                int ingredientCount = techData.ingredientCount;
                while (i < ingredientCount)
                {
                    IIngredient ingredient = techData.GetIngredient(i);
                    if (GetTotalPickupCount(ingredient.techType, itemContainers) < ingredient.amount)
                    {
                        return(false);
                    }
                    i++;
                }
                return(true);
            }
            return(false);
        }
Beispiel #16
0
 /// <summary>
 /// Добавление нового ингредиента
 /// </summary>
 /// <param name="newIngredient"> Новый ингредиент</param>
 /// <returns>Возвращает  true, если добавление прошло успешно</returns>
 public bool AddNewIngredient(IIngredient newIngredient)
 {
     if (Context.context.Ingredients.Select(x => x.NameIngredient).Contains(newIngredient.NameIngredient))
     {
         return(false);
     }
     else
     {
         var ing = Context.context.Ingredients.Add(new ModelDB.Ingredient()
         {
             NameIngredient   = newIngredient.NameIngredient,
             IDTypeIngredient = newIngredient.TypeIngredient.IDTypeIngredient,
             Protein          = (float)newIngredient.Protein,
             Fat          = (float)newIngredient.Fat,
             Carbohydrate = (float)newIngredient.Carbohydrate
         });
         Context.context.Products.Add(new Product()
         {
             Price         = newIngredient.StartingPrice,
             Mass          = (float)newIngredient.MassInKg,
             BeginDate     = newIngredient.RecordDate,
             IDIngredient  = ing.IDIngredient,
             IDSubdivision = newIngredient.Subdivision.IDSubdivision
         });
         Context.context.SaveChanges();
         Context.context.Dispose();
         Context.context = new DB_MenuEntities();
         return(true);
     }
 }
Beispiel #17
0
 /// <summary>
 /// Добавление ингредиента в репозиторий
 /// </summary>
 /// <param name="NewIngredient">Добавляемый ингредиент</param>
 public void AddIngredientInRepository(IIngredient NewIngredient)
 {
     if (NewIngredient == null)
     {
         throw new ArgumentNullException("newIngredient");
     }
     _IngredientController.Add(NewIngredient);
 }
Beispiel #18
0
 public RecipesController(IIngredient ingredient, IInstruction instruction, IRecipe recipe, ISavedRecipe savedRecipe, SignInManager <ApplicationUser> signInManager)
 {
     _Ingredient    = ingredient;
     _Instruction   = instruction;
     _Recipe        = recipe;
     _SavedRecipe   = savedRecipe;
     _SignInManager = signInManager;
 }
Beispiel #19
0
 public void Assign(IIngredient ingredient)
 {
     Id = ingredient.Id;
     ProductId = ingredient.ProductId;
     RecipeId = ingredient.RecipeId;
     Amount = ingredient.Amount;
     UnitId = ingredient.UnitId;
 }
Beispiel #20
0
 public static Ingredient FromIngredient(IIngredient ingredient)
 {
     Ingredient i = new Ingredient
      {
     Name = ingredient.Name,
      };
      return i;
 }
Beispiel #21
0
        private void DrawIngredientItem(object sender, DrawItemEventArgs e)
        {
            ingredientStamp.ImageWidth = 22;

            IIngredient ingredient = ((sender as ListControl)?.DataSource as BindingSource)?[e.Index] as IIngredient;

            ingredientStamp.DrawItem(e, ingredient?.Name ?? "", ingredient?.Image);
        }
Beispiel #22
0
 public HomeController(IRecipe recipe, IInstruction instructions, IIngredient ingredient, IComment comment, ISavedRecipe savedRecipe)
 {
     _Recipe      = recipe;
     _Instruction = instructions;
     _Ingredient  = ingredient;
     _Comment     = comment;
     _SavedRecipe = savedRecipe;
 }
Beispiel #23
0
        public static Ingredient FromIngredient(IIngredient ingredient)
        {
            Ingredient i = new Ingredient
            {
                Name = ingredient.Name,
            };

            return(i);
        }
        public void ToString_ReturnsCorrectStringEasyFraction()
        {
            this.amount     = 0.75;
            this.ingredient = new Ingredient(this.amount, this.foodItem);
            var expected = String.Format("3/4 - {0}", this.ingredient.Name);
            var actual   = this.ingredient.ToString();

            Assert.IsTrue(StringAssert.Equals(expected, actual));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RecipeComponent"/> class.
 /// </summary>
 public RecipeComponent(IIngredient ingredient)
 {
     _recipeComponent = new RecipeComponentDb
     {
         Ingredient = (ingredient as Ingredient).UnwrapDataObject(),
         Amount     = 0,
         Unit       = default(UnitTypes)
     };
 }
        public void ToString_ReturnsCorrectStringAnotherHardFraction()
        {
            this.amount     = 2.115;
            this.ingredient = new Ingredient(this.amount, this.foodItem);
            var expected = String.Format("2 23/200 - {0}", this.ingredient.Name);
            var actual   = this.ingredient.ToString();

            Assert.IsTrue(StringAssert.Equals(expected, actual));
        }
Beispiel #27
0
        public void AddIngredient(IIngredient ingredient)
        {
            if (ingredient == null)
            {
                throw new ArgumentNullException("ingredient");
            }

            m_list.Add(ingredient);
        }
        public void ToString_ReturnsCorrectStringNaturalNumber()
        {
            this.amount     = 1;
            this.ingredient = new Ingredient(this.amount, this.foodItem);
            var expected = String.Format("1 - {0}", this.ingredient.Name);
            var actual   = this.ingredient.ToString();

            Assert.IsTrue(StringAssert.Equals(expected, actual));
        }
Beispiel #29
0
        public Order(Client client, IIngredient salad, IDessert dessert, IDrink drink)
        {
            Client  = client;
            Salad   = salad;
            Dessert = dessert;
            Drink   = drink;

            Client.Order = this;
        }
Beispiel #30
0
        public Breading(IIngredient ingredient)
        {
            if (ingredient == null)
            {
                throw new ArgumentNullException("ingredient");
            }

            this.ingredient = ingredient;
        }
Beispiel #31
0
        public void ContainerResolvesIngredientToSauceBéarnaise()
        {
            var container = new UnityContainer();

            container.RegisterType <IIngredient, SauceBéarnaise>();
            IIngredient ingredient = container.Resolve <IIngredient>();

            Assert.IsAssignableFrom <SauceBéarnaise>(ingredient);
        }
Beispiel #32
0
        public Breading(IIngredient ingredient)
        {
            if (ingredient == null)
            {
                throw new ArgumentNullException("ingredient");
            }

            this.ingredient = ingredient;
        }
Beispiel #33
0
        public void ContainerResolvesIngredientToSauceBéarnaise()
        {
            var catalog   = new TypeCatalog(typeof(Ploeh.Samples.Menu.Mef.Attributed.Unmodified.Abstract.SauceBéarnaise));
            var container = new CompositionContainer(catalog);

            IIngredient ingredient = container.GetExportedValue <IIngredient>();

            Assert.IsAssignableFrom <SauceBéarnaise>(ingredient);
        }
        private void Init(IIngredient ingredient, Atlas.Sprite sprite, bool first, bool last)
        {
            this.ingredient = ingredient;
            bool mainIcon = ingredient == null;

            var quickSlots = GameObject.FindObjectOfType <uGUI_QuickSlots>();
            var bgSprite   = first ? quickSlots.spriteLeft : last ? quickSlots.spriteRight : quickSlots.spriteCenter;

            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, bgSprite.rect.width);
            (transform as RectTransform).SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, bgSprite.rect.height);

            layout           = gameObject.AddComponent <LayoutElement>();
            layout.minWidth  = bgSprite.rect.width;
            layout.minHeight = bgSprite.rect.height;

            background               = gameObject.AddComponent <Image>();
            background.color         = new Color(1, 1, 1, Mod.config.BackgroundAlpha);
            background.raycastTarget = false;
            background.material      = quickSlots.materialBackground;
            background.sprite        = bgSprite;

            icon = new GameObject("Icon").AddComponent <uGUI_ItemIcon>();
            icon.transform.SetParent(transform, false);
            icon.SetForegroundSprite(sprite);
            if (mainIcon)
            {
                icon.SetSize(Width, Width);
            }
            else
            {
                icon.SetSize(IconWidth, IconWidth);
            }
            icon.rectTransform.anchorMin        = new Vector2(0.5f, 0.5f);
            icon.rectTransform.anchorMax        = new Vector2(0.5f, 0.5f);
            icon.rectTransform.pivot            = new Vector2(0.5f, 0.5f);
            icon.rectTransform.anchoredPosition = new Vector2(0, 0);
            icon.raycastTarget = false;

            if (!mainIcon)
            {
                text = ModUtils.InstantiateNewText("Text", transform);
                RectTransformExtensions.SetSize(text.rectTransform, Width, Width);
                text.rectTransform.anchorMin        = new Vector2(0.5f, 0);
                text.rectTransform.anchorMax        = new Vector2(0.5f, 0);
                text.rectTransform.pivot            = new Vector2(0.5f, 0);
                text.rectTransform.anchoredPosition = new Vector2(0, 0);
                text.alignment     = TextAnchor.LowerCenter;
                text.fontSize      = Mod.config.FontSize;
                text.raycastTarget = false;

                ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorGoodColorblind : IngredientColorGood, out goodColor);
                ColorUtility.TryParseHtmlString(Mod.config.ColorblindMode ? IngredientColorBadColorblind : IngredientColorBad, out badColor);
            }

            UpdateText();
        }
		/// <summary>
		/// Determines if the ingredient is available from the partner
		/// </summary>
		public bool IngredientIsEnabled(IIngredient ingredient)
		{
			if(ingredient == null)
			{
				throw new ArgumentNullException("ingredient");
			}

			var ingType = ingredient is Fermentable ? IngredientType.Fermentable : ingredient is Hop ? IngredientType.Hop :
				ingredient is Yeast ? IngredientType.Yeast : IngredientType.Adjunct;

			return this.Ingredients.Any(x => x.IngredientTypeId == (int)ingType && x.IngredientId == ingredient.IngredientId);
		}
Beispiel #36
0
 private static void Cut(IIngredient ingredient)
 {
     Console.WriteLine("{0} is cut", ingredient.GetType().Name);
 }
Beispiel #37
0
 public IngredientView(IIngredient ingredient)
 {
     Assign(ingredient);
 }
Beispiel #38
0
 public DbIngredient(IIngredient ingredient)
 {
     Assign(ingredient);
 }
Beispiel #39
0
		/// <summary>
		/// Sets the Ingredient
		/// </summary>
		public void SetIngredient(IIngredient ingredient)
		{
			this.Hop = (Hop)ingredient;
		}
Beispiel #40
0
    	/// <summary>
    	/// Sets the Ingredient
    	/// </summary>
    	public void SetIngredient(IIngredient ingredient)
    	{
			this.Yeast = (Yeast)ingredient;
    	}
		/// <summary>
		/// Sets the Ingredient
		/// </summary>
		public void SetIngredient(IIngredient ingredient)
		{
			this.Fermentable = (Fermentable)ingredient;
		}
 public CaesarSalad()
 {
     this.extra = new NullIngredient();
 }
Beispiel #43
0
 public void Add(IIngredient ingredient)
 {
     this.Ingredients.Add(ingredient);
 }
Beispiel #44
0
 public RecipeView(IRecipe recipe, IIngredient[] ingredient)
 {
     Assign(recipe);
     Ingredients = new IngredientCollectionView(ingredient);
 }
 /// <summary>
 /// Sets the Ingredient
 /// </summary>
 public void SetIngredient(IIngredient ingredient)
 {
     this.MashStep = (MashStep)ingredient;
 }
		/// <summary>
		/// Sets the Ingredient
		/// </summary>
		public void SetIngredient(IIngredient ingredient)
		{
			this.Adjunct = (Adjunct)ingredient;
		}
Beispiel #47
0
 private static void Peel(IIngredient ingredient)
 {
     Console.WriteLine("{0} is peeled", ingredient.GetType().Name);
 }