public void SolutionModify() { var item1 = new Item("a"); var item2 = new Item("b"); Recipe r = new Recipe(""); r.AddIngredient(new ItemAmount(item1, 1)); r.AddResult(new ItemAmount(item2, 1)); r.CraftingCategory = "test"; Building b = new Building(""); b.AddCraftingCategory("test"); b.IngredientCount = 4; b.ProductionSpeed = 1; Library l = new Library(); l.AddItem(item1); l.AddItem(item2); l.AddRecipe(r); l.AddBuilding(b); l.Initialize(); var coarseGraph = RecipeGraph.FromLibrary(l, new Item[] { item1 }, new ItemAmount[] { new ItemAmount(item2, 0.01) }, (a) => 1); var denseGraph = TrivialSolutionFactory.CreateFactory(coarseGraph); var parameters = SolutionParameters.FromFactory(12, 12, denseGraph); Assert.AreEqual(parameters, parameters.Modify(0)); }
private static IEnumerable <Recipe> ParseRecipes(LuaTable recipes) { foreach (string name in recipes.Keys) { var recipe = recipes[name] as LuaTable; var result = new Recipe(name); var ingredients = recipe["ingredients"] as LuaTable; foreach (var ingredient in ParseItemAmounts(ingredients)) { result.AddIngredient(ingredient); } if (recipe.ContainsKey("result")) { double amount = 1; if (recipe.ContainsKey("result_count")) { amount = (double)recipe["result_count"]; } result.AddResult(new ItemAmount(recipe["result"] as string, amount)); } else { var results = recipe["results"] as LuaTable; foreach (var output in ParseItemAmounts(results)) { result.AddResult(output); } } var category = recipe["category"] as string; if (category != null) { result.CraftingCategory = category; } if (recipe.ContainsKey("energy_required")) { result.Time = (double)recipe["energy_required"]; } yield return(result); } }