public Recipe( string name, RecipeType recipeType, string description, // List<ProductComposition> productsComposition, // RecipeCreator recipeCreator, string numberCreator, int price = 2, bool isHealthy = false, bool isBio = false, bool isVegan = false, bool isChimical = false, bool isTrending = false, int rating = 0 ) { this._name = name; this._recipeType = recipeType; this._description = description; // this._productsComposition = productsComposition; // this._recipeCreator = recipeCreator; this._price = price; this._isHealthy = isHealthy; this._isBio = isBio; this._isVegan = isVegan; this._isChimical = isChimical; this._isTrending = isTrending; this._rating = rating; this._numberCreator = numberCreator; }
public void MYSQLDbAccessTests() { List <int> recipesIds = MySQLDbAccess.GetRecipesIdsThatContainsIngredients(new List <Ingredient>() { new Ingredient() { Id = 283, Name = "Açucar" } }, new RecipeType() { Id = 3, Name = "Vegetariano" }); List <Unit> units = MySQLDbAccess.GetAllUnits(); List <ApplianceType> appliances = MySQLDbAccess.GetAllApplianceTypes(); Recipe recipe = MySQLDbAccess.GetRecipeById(2); //List<int> recipesIds = MySQLDbAccess.GetRecipesIdsThatContainsIngredients(new List<Ingredient>() { new Ingredient() { Id = 24, Name = "Banana" } }); List <Ingredient> ingredients = MySQLDbAccess.GetAllIngredients(); Ingredient ingredient = MySQLDbAccess.GetIngredientById(111); Ingredient ingredient2 = MySQLDbAccess.GetIngredientByName("Limão"); User user = MySQLDbAccess.GetUserById(1); RecipeType recipeType = MySQLDbAccess.GetRecipeTypeById(1); Unit unit = MySQLDbAccess.GetUnitTypeById(1); List <IngredientInfo> infos = MySQLDbAccess.GetIngredientInfosFromRecipe(1); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="key">The recipe's lookup name (if any).</param> /// <param name="type">The recipe type.</param> /// <param name="displayType">The display name for the machine or building name for which the recipe applies.</param> /// <param name="ingredients">The items needed to craft the recipe (item ID => number needed).</param> /// <param name="item">The item that's created by this recipe, given an optional input.</param> /// <param name="mustBeLearned">Whether the recipe must be learned before it can be used.</param> /// <param name="isForMachine">Get whether this recipe is for the given machine.</param> /// <param name="exceptIngredients">The ingredients which can't be used in this recipe (typically exceptions for a category ingredient).</param> /// <param name="outputItemIndex">The item ID produced by this recipe, if applicable.</param> /// <param name="minOutput">The minimum number of items output by the recipe.</param> /// <param name="maxOutput">The maximum number of items output by the recipe.</param> /// <param name="outputChance">The percentage chance of this recipe being produced (or <c>null</c> if the recipe is always used).</param> public RecipeModel(string key, RecipeType type, string displayType, IDictionary <int, int> ingredients, Func <Item, Item> item, bool mustBeLearned, Func <object, bool> isForMachine, int[] exceptIngredients = null, int?outputItemIndex = null, int?minOutput = null, int?maxOutput = null, int?outputChance = null) { // normalise values if (minOutput == null && maxOutput == null) { minOutput = 1; maxOutput = 1; } else if (minOutput == null) { minOutput = maxOutput; } else if (maxOutput == null) { maxOutput = minOutput; } // save values this.Key = key; this.Type = type; this.DisplayType = displayType; this.Ingredients = ingredients; this.IsForMachine = isForMachine; this.ExceptIngredients = exceptIngredients ?? new int[0]; this.Item = item; this.MustBeLearned = mustBeLearned; this.OutputItemIndex = outputItemIndex; this.MinOutput = minOutput.Value; this.MaxOutput = maxOutput.Value; this.OutputChance = outputChance > 0 && outputChance < 100 ? outputChance.Value : 100; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="key">The recipe's lookup name (if any).</param> /// <param name="type">The recipe type.</param> /// <param name="displayType">The display name for the machine or building name for which the recipe applies.</param> /// <param name="ingredients">The items needed to craft the recipe (item ID => number needed).</param> /// <param name="item">The item that's created by this recipe, given an optional input.</param> /// <param name="mustBeLearned">Whether the recipe must be learned before it can be used.</param> /// <param name="machineParentSheetIndex">The object parent sheet index for the machine, if applicable.</param> /// <param name="isForMachine">Get whether this recipe is for the given machine.</param> /// <param name="exceptIngredients">The ingredients which can't be used in this recipe (typically exceptions for a category ingredient).</param> /// <param name="outputItemIndex">The item ID produced by this recipe, if applicable.</param> /// <param name="outputItemType">The item type produced by this recipe, if applicable.</param> /// <param name="minOutput">The minimum number of items output by the recipe.</param> /// <param name="maxOutput">The maximum number of items output by the recipe.</param> /// <param name="outputChance">The percentage chance of this recipe being produced (or <c>null</c> if the recipe is always used).</param> public RecipeModel(string key, RecipeType type, string displayType, IEnumerable <RecipeIngredientModel> ingredients, Func <Item, Item> item, bool mustBeLearned, int?machineParentSheetIndex, Func <object, bool> isForMachine, IEnumerable <RecipeIngredientModel> exceptIngredients = null, int?outputItemIndex = null, ItemType?outputItemType = null, int?minOutput = null, int?maxOutput = null, decimal?outputChance = null) { // normalize values if (minOutput == null && maxOutput == null) { minOutput = 1; maxOutput = 1; } else if (minOutput == null) { minOutput = maxOutput; } else if (maxOutput == null) { maxOutput = minOutput; } // save values this.Key = key; this.Type = type; this.DisplayType = displayType; this.Ingredients = ingredients.ToArray(); this.MachineParentSheetIndex = machineParentSheetIndex; this.IsForMachine = isForMachine; this.ExceptIngredients = exceptIngredients?.ToArray() ?? new RecipeIngredientModel[0]; this.Item = item; this.MustBeLearned = mustBeLearned; this.OutputItemIndex = outputItemIndex; this.OutputItemType = outputItemType; this.MinOutput = minOutput.Value; this.MaxOutput = maxOutput.Value; this.OutputChance = outputChance > 0 && outputChance < 100 ? outputChance.Value : 100; }
public void Create(string title, RecipeType choice) { using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Insert(new Recipe(title, choice)); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { RecipeType type = (RecipeType)value; switch (type) { case RecipeType.Breakfast: return(findSource("ico_breakfast.png")); case RecipeType.DessertAndCake: return(findSource("ico_cake.png")); case RecipeType.Drink: return(findSource("ico_drink.png")); case RecipeType.MainCourse: return(findSource("ico_mainCourse.png")); case RecipeType.Salat: return(findSource("ico_salat.png")); case RecipeType.SideDish: return(findSource("ico_sideDish.png")); case RecipeType.Soup: return(findSource("ico_soup.png")); default: return(findSource("ico_other.png")); } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="key">The recipe's lookup name (if any).</param> /// <param name="type">The recipe type.</param> /// <param name="displayType">The display name for the machine or building name for which the recipe applies.</param> /// <param name="ingredients">The items needed to craft the recipe (item ID => number needed).</param> /// <param name="item">The item that's created by this recipe, given an optional input.</param> /// <param name="isKnown">Whether the player knows this recipe.</param> /// <param name="machineParentSheetIndex">The object parent sheet index for the machine, if applicable.</param> /// <param name="isForMachine">Get whether this recipe is for the given machine.</param> /// <param name="exceptIngredients">The ingredients which can't be used in this recipe (typically exceptions for a category ingredient).</param> /// <param name="outputItemIndex">The item ID produced by this recipe, if applicable.</param> /// <param name="outputItemType">The item type produced by this recipe, if applicable.</param> /// <param name="minOutput">The minimum number of items output by the recipe.</param> /// <param name="maxOutput">The maximum number of items output by the recipe.</param> /// <param name="outputChance">The percentage chance of this recipe being produced (or <c>null</c> if the recipe is always used).</param> public RecipeModel(string?key, RecipeType type, string displayType, IEnumerable <RecipeIngredientModel> ingredients, Func <Item?, Item?>?item, Func <bool> isKnown, int?machineParentSheetIndex, Func <object, bool> isForMachine, IEnumerable <RecipeIngredientModel>?exceptIngredients = null, int?outputItemIndex = null, ItemType?outputItemType = null, int?minOutput = null, int?maxOutput = null, decimal?outputChance = null) { // normalize values if (minOutput == null && maxOutput == null) { minOutput = 1; maxOutput = 1; } else if (minOutput == null) { minOutput = maxOutput; } else if (maxOutput == null) { maxOutput = minOutput; } // save values this.Key = key; this.Type = type; this.DisplayType = displayType; this.Ingredients = ingredients.ToArray(); this.MachineParentSheetIndex = machineParentSheetIndex; this.IsForMachine = isForMachine; this.ExceptIngredients = exceptIngredients?.ToArray() ?? Array.Empty <RecipeIngredientModel>(); this.Item = item; this.IsKnown = isKnown; this.OutputItemIndex = outputItemIndex; this.OutputItemType = outputItemType; this.MinOutput = minOutput !.Value; this.MaxOutput = maxOutput !.Value; this.OutputChance = outputChance is > 0 and < 100 ? outputChance.Value : 100; }
/// <summary> /// Initializes a new instance of <see cref="Recipe"/>. Uses the database context to resolve item IDs to instances of <see cref="Item"/>. /// </summary> /// <param name="recipeEntity">The entity containing the descriptors for the recipe.</param> /// <param name="getItem">A function that resolves an <see cref="int"/> ID to an <see cref="Item"/>.</param> internal Recipe(RecipeEntity recipeEntity, Func <int, Item> getItem) { this._type = Enum.TryParse(recipeEntity.Type, out RecipeType type) ? type : RecipeType.Unknown; this.OutputItem = getItem(recipeEntity.OutputItemID.Value); this._outputItemCount = recipeEntity.OutputItemCount ?? 0; foreach (var disciplineResult in recipeEntity.Disciplines) { this._disciplines.Add((Discipline)Enum.Parse(typeof(Discipline), disciplineResult.Name)); } foreach (var flagResult in recipeEntity.Flags) { this._flags.Add((Flag)Enum.Parse(typeof(Flag), flagResult.Name)); } foreach (var ingredient in recipeEntity.Ingredients) { this.Ingredients.Add(getItem(ingredient.ItemID), ingredient.Count); } foreach (var ingredient in recipeEntity.GuildIngredients) { this.Ingredients.Add(getItem(ingredient.UpgradeID), ingredient.Count); } // update each ingredient's recipe list to allow travel up the crafting tree foreach (var ingredient in this.Ingredients.Keys) { ingredient.DependentRecipes.Add(this); } this.OutputItem.GeneratingRecipes.Add(this); }
/// <summary> /// Calculates a player's chance to craft a specific recipe. /// </summary> /// <param name="player">The player to calculate for</param> /// <param name="recipeType">The type of recipe to calculate for</param> /// <returns>A value between 0 and 95 representing the chance to craft an item.</returns> public static float CalculateChanceToCraft(uint player, RecipeType recipeType) { var chance = 60f; var playerId = GetObjectUUID(player); var dbPlayer = DB.Get <Player>(playerId); var recipe = GetRecipe(recipeType); var playerLevel = dbPlayer.Skills[recipe.Skill].Rank; var(primary, secondary) = _craftSkillToAbility[recipe.Skill]; var levelDelta = playerLevel - recipe.Level; var attributeAdjustment = GetAbilityModifier(primary) * 2.0f + GetAbilityModifier(secondary) * 1.5f; var levelAdjustment = levelDelta * 10f; chance += levelAdjustment + attributeAdjustment; if (chance < 0) { chance = 0; } else if (chance >= 95) { chance = 95; } return(chance); }
public static string ToIconClass(RecipeType recipeType) { switch (recipeType) { case RecipeType.Entrees: { return("fas fa-utensils"); } case RecipeType.MainDish: { return("mdi mdi-food"); } case RecipeType.Sweet: { return("fas fa-cookie"); } default: { return("mdi-food-variant"); } } }
public static Dictionary <Guid, RecipeInformation> GetValue(RecipeType type) { if (CommonFunction.IsNull(Result) == false) { return(Result); } //TableRecipeData[] datas = Array.FindAll(Table, i => i.RType == type); Result = new Dictionary <Guid, RecipeInformation>(); foreach (TableRecipeData d in Table) { RecipeInformation rec = new RecipeInformation(); //生成対象アイテムを取得 BaseItem item = TableItemIncidence.GetItemObjNo(d.IType, d.ObjNo, false); item.StrengthValue = d.Strength; rec.RecipeTargetName = item.DisplayNameNormal; rec.Weight = item.Weight; rec.RecipeTargetNo = d.ObjNo; rec.RecipeTargetType = d.IType; rec.Strength = d.Strength; TableRecipeMaterial.SetValue(rec, d.RecipeObjNo); Result.Add(rec.Name, rec); } return(Result); }
public static IEnumerable <DietPhase> GetPhaseForRecipe(int recipeID) { List <DietPhase> res = new List <DietPhase>(); List <RecipeType> r_t_l = instance.db.GetItemsWParam <RecipeType>("RecipeType", "RecipeID", recipeID.ToString()); if (r_t_l.Count != 0) { RecipeType r_t = r_t_l[0]; if (r_t.Attack != 0) { res.Add(new DietPhase(DietPhaseId.DP_Attack)); } if (r_t.Cruise != 0) { res.Add(new DietPhase(DietPhaseId.DP_Cruise)); } if (r_t.Consolidation != 0) { res.Add(new DietPhase(DietPhaseId.DP_Consolidation)); } if (r_t.Stabilization != 0) { res.Add(new DietPhase(DietPhaseId.DP_Stabilization)); } } else { res.Add(new DietPhase(DietPhaseId.DP_Default)); } return(res); }
public ActionResult Edit(RecipeType types) { db.Entry(types).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <RecipeType> addRecipeType(RecipeType recipeType) { _context.RecipeTypes.Add(recipeType); await _context.SaveChangesAsync(); return(recipeType); }
public async Task <IActionResult> Edit(int id, [Bind("RecipeTypeId,Name")] RecipeType recipeType) { if (id != recipeType.RecipeTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recipeType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeTypeExists(recipeType.RecipeTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(recipeType)); }
public Recipe(int Page, RecipeType RecipeType, string Name, string[] Ingredients, string[] Method) { name = Name; page = Page; type = RecipeType; ingredients = Ingredients; method = Method; }
public IEnumerable <Recipe> GetAll() { RecipeType recipeType = RecipeType.own; return(userContext.Recipes .Where(r => r.RecipeType.Equals(recipeType)) .AsEnumerable()); }
/// <summary> /// Instantiates an instance of <see cref="ImprovementMetadata" /> /// </summary> /// <param name="tenant">The tenant</param> /// <param name="recipe">The type of the recipe that describes the build steps</param> /// <param name="improvement">The id of the improvment</param> /// <param name="improvementFor">The id of the improvable being improved</param> /// <param name="version">The version of the software that is associated with this improvement</param> public ImprovementMetadata(TenantId tenant, RecipeType recipe, ImprovementId improvement, ImprovableId improvementFor, Version version) { Tenant = tenant; Recipe = recipe; Improvement = improvement; ImprovementFor = improvementFor; Version = version; }
public Recipe(string name, int id, RecipeType recipeType, Ingredients ingredients, Loot output) { this.name = name; this.id = id; this.recipeType = recipeType; this.ingredients = ingredients; this.output = output; }
public static RecipeBase Get(string tool, RecipeType type, string[] items) { if (GameManager.ProxyManager.TryGet <IRecipe>(GetRecipeName(tool, type, items), out var proxy)) { return((RecipeBase)proxy); } return(null); }
public static RecipeTypeModel ToRecipeTypeModel(this RecipeType recipeType) { return(new RecipeTypeModel() { Id = recipeType.Id, Name = recipeType.Name, }); }
public IEnumerable <Recipe> GetOwnRecipesForUser(string id) { RecipeType recipeType = RecipeType.own; return(userContext.Recipes .Where(recipe => recipe.UserId.Equals(id) && (recipe.RecipeType.Equals(recipeType))) .AsEnumerable()); }
/// <summary> /// Registers a new <see cref="Improvable" /> /// </summary> /// <param name="name">The name of the new improvable</param> /// <param name="recipe">The recipe type to associate with the new improvable</param> /// <param name="repository">The source control repository associated with the improvable</param> /// <param name="path">The path within the Source Control repository to the building artifact</param> public void Register(ImprovableName name, RecipeType recipe, RepositoryFullName repository, Path path) { if (_registered) { throw new ImprovableAlreadyRegistered($"An improvable with the Id '{this.EventSourceId.Value}' has already been registered"); } Apply(new ImprovableRegistered(this.EventSourceId, name, recipe, repository, path)); }
public IEnumerable <Recipe> GetCookedRecipesForUser(String Id) { RecipeType recipeType = RecipeType.cooked; return(userContext.Recipes .Where(recipe => recipe.UserId.Equals(Id) && (recipe.RecipeType.Equals(recipeType))) .AsEnumerable()); }
public IRecipe GetByName(RecipeType name) { var typeName = $"{typeof(RecipeLocator).Namespace}.Recipes.{name}"; var type = _typeFinder.FindTypeByFullName(typeName); var recipe = Activator.CreateInstance(type) as IRecipe; return(recipe); }
public BenchFoodRecipe(string iDName, RecipeType type, double foodRestore, List <OreBlock> inputs, ItemStack output) { IDName = iDName ?? throw new ArgumentNullException(nameof(iDName)); Type = type; Inputs = inputs ?? throw new ArgumentNullException(nameof(inputs)); Output = output ?? throw new ArgumentNullException(nameof(output)); FoodRestore = foodRestore; }
public async Task <int> Save(RecipeType recipeType) { using (var db = _context) { db.RecipeType.Add(recipeType); return(await db.SaveChangesAsync()); } }
/// <summary>Construct an instance.</summary> /// <param name="name">The name of the recipe.</param> /// <param name="type">How the recipe is used to create an object.</param> /// <param name="ingredients">The items needed to craft the recipe (item ID => number needed).</param> /// <param name="item">The item that be created by this recipe.</param> /// <param name="mustBeLearned">Whether the recipe must be learned before it can be used.</param> /// <param name="exceptIngredients">The ingredients which can't be used in this recipe (typically exceptions for a category ingredient).</param> public RecipeModel(string name, RecipeType type, IDictionary <int, int> ingredients, Func <Item> item, bool mustBeLearned, int[] exceptIngredients = null) { this.Name = name; this.Type = type; this.Ingredients = ingredients; this.ExceptIngredients = exceptIngredients ?? new int[0]; this.Item = item; this.MustBeLearned = mustBeLearned; }
public ICollection <Recipe> FindByName(string name) { RecipeType recipeType = RecipeType.own; ICollection <Recipe> recipes = userContext.Recipes .Where(r => r.Name.Contains(name) && (r.RecipeType.Equals(recipeType))) .ToList(); return(recipes); }
public ICollection <Recipe> FindByNameAndCategory(string category, string name) { Category category1 = (Category)System.Enum.Parse(typeof(Category), category); RecipeType recipeType = RecipeType.own; ICollection <Recipe> recipes = userContext.Recipes .Where(r => r.Name.Contains(name) && ((r.Category.Equals(category1)) && (r.RecipeType.Equals(recipeType)))) .ToList(); return(recipes); }
/// <summary> /// Constructor for this resource /// </summary> /// <param name="id">The recipe id.</param> /// <param name="type">The recipe type.</param> /// <param name="output_item_id">The item id of the produced item.</param> /// <param name="output_item_count">The amount of items produced.</param> /// <param name="time_to_craft_ms">The time in milliseconds it takes to craft the item.</param> /// <param name="disciplines">The crafting disciplines that can use the recipe.</param> /// <param name="min_rating">The required rating to craft the recipe.</param> /// <param name="flags">Flags applying to the recipe.</param> /// <param name="ingredients">List of recipe ingredients.</param> /// <param name="chat_link">The chat code for the recipe.</param> public Recipe(int id, RecipeType type, int output_item_id, int output_item_count, int time_to_craft_ms, List<Discipline> disciplines, int min_rating, List<Flags> flags, List<Ingredient> ingredients, string chat_link) { Id = id; Type = type; OutputItemId = output_item_id; OutputItemCount = output_item_count; MinRating = min_rating; TimeToCraftMS = time_to_craft_ms; Disciplines = disciplines; Flags = flags; Ingredients = ingredients; ChatLink = chat_link; }