Ejemplo n.º 1
0
 /// <summary>
 /// Gets the display name of this cooking recipe component (i.e. ingredient), not including
 /// any units or additional phrases.
 /// </summary>
 public static string GetComponentSimpleName(this ICookingRecipeComponent component)
 {
     if (component is PreparedCookingRecipieComponentDomain componentDomain)
     {
         return(componentDomain.ingredientType);
     }
     if (component is PreparedCookingRecipieComponentLiquid componentLiquid)
     {
         return(LiquidVolume.getLiquid(componentLiquid.liquid).GetName());
     }
     if (component is PreparedCookingRecipieComponentBlueprint componentBlueprint)
     {
         return(componentBlueprint.ingredientDisplayName);
     }
     return("{{K|<unknown ingredient>}}");
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the amount associated with this cooking recipe component (i.e. ingredient). I believe
 /// this will always be 1 for cooking ingredients, but not 100% sure.
 /// </summary>
 public static int GetComponentAmount(this ICookingRecipeComponent component)
 {
     if (component is PreparedCookingRecipieComponentDomain componentDomain)
     {
         return(componentDomain.amount);
     }
     if (component is PreparedCookingRecipieComponentLiquid componentLiquid)
     {
         return(componentLiquid.amount);
     }
     if (component is PreparedCookingRecipieComponentBlueprint componentBlueprint)
     {
         return(componentBlueprint.amount);
     }
     return(1);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the formatted string representing the list of ingredients required to cook this recipe.
        /// Shorter than the default game version of the ingredient list, which repeats "1 serving of "
        /// before every ingrient. Instead, this function returns a string similar to "1 serving each
        /// of <ingredient_one>, <ingredient_two>, and <ingredient_three>". This slightly shorter
        /// phrasing helps ensure the ingredient list can always fit on two lines in the menu.
        /// </summary>
        /// <remarks>
        ///  * I am 99% sure a recipe can never call for an amount > 1 of any single ingredient.
        ///    However, I've implemented logic below to account for this possiblity just to be safe.
        ///  * This method defaults to using the "serving" language always, even for liquids. The
        ///    default game uses "drams" but "serving" seems an appropriate adjective for liquids
        ///    in the context of cooking a recipe, and allows us to use simpler phrasing herein.
        /// </remarks>
        public static string GetBriefIngredientList(this CookingRecipe recipe)
        {
            string        ingredientList      = string.Empty;
            int           maxAmount           = 0;
            List <string> ingredientNamesOnly = new List <string>(recipe.Components.Count);
            List <int>    ingredientAmounts   = new List <int>(recipe.Components.Count);

            for (int i = 0; i < recipe.Components.Count; i++)
            {
                ICookingRecipeComponent component = recipe.Components[i];
                ingredientAmounts.Add(component.GetComponentAmount());
                ingredientNamesOnly.Add(component.GetComponentSimpleName());
                if (ingredientAmounts[i] > maxAmount)
                {
                    maxAmount = ingredientAmounts[i];
                }
            }
            if (maxAmount == 1)
            {
                ingredientList = "1 serving " + (recipe.Components.Count > 1 ? "each" : string.Empty) + " of ";
                for (int i = 0; i < recipe.Components.Count; i++)
                {
                    ingredientList += ingredientNamesOnly[i].PrependListElementJoinString(i, recipe.Components.Count);
                    ingredientList += "{{K|(" + CookingGamestate.GetIngredientQuantity(recipe.Components[i]) + ")}}";
                }
            }
            else
            {
                for (int i = 0; i < recipe.Components.Count; i++)
                {
                    string thisIngredient = ingredientAmounts[i].ToString() + " serving" + (ingredientAmounts[i] > 1 ? "s" : string.Empty);
                    thisIngredient += " of " + ingredientNamesOnly[i];
                    ingredientList += (i > 0 ? ", " : string.Empty) + thisIngredient;
                    ingredientList += "{{K|(" + CookingGamestate.GetIngredientQuantity(recipe.Components[i]) + ")}}";
                }
            }
            return(ingredientList);
        }