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 IActionResult RandomRecipe()
        {
            RecipeInformation recipeInformation = RecipeGenerator_BL.Recipe.getFirstRecipe();

            ViewBag.recipe = recipeInformation;
            return(View());
        }
Example #3
0
        public static RecipeInformation SimplyfyInformation(Recipe r)
        {
            RecipeInformation rv = new RecipeInformation();

            rv.DairyFree  = r.DairyFree;
            rv.GlutenFree = r.GlutenFree;
            rv.Vegan      = r.Vegan;
            rv.Vegetarian = r.Vegetarian;

            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < r.Diets.Count; i++)
            {
                builder.Append(r.Diets[i]);
                if (i != r.Diets.Count)
                {
                    builder.Append(", ");
                }
            }

            rv.Diets = builder.ToString();

            rv.ReadyInMinutes           = r.ReadyInMinutes;
            rv.WeightWatcherSmartPoints = r.WeightWatcherSmartPoints;

            return(rv);
        }
Example #4
0
    public static Dictionary <Guid, RecipeInformation> GetValue(List <BaseItem> ItemList)
    {
        //持っている装備を抽出
        BaseItem[] equips = ItemList.Where(i => i.IType == ItemType.Weapon || i.IType == ItemType.Shield).ToArray();

        //持っている強化素材を抽出
        long[] materials = ItemList.Where(i => (i.GetType() == typeof(MaterialBase) && ((MaterialBase)i).MType == MaterialType.Strength)).Select(i => i.ObjNo).Distinct().ToArray();

        //強化素材の一覧を抽出
        MaterialBase smate = TableMaterial.GetItem(MaterialType.Strength);
        //TableStrengthData[] datas = Array.FindAll(Table, i => i.RType == type);

        Dictionary <Guid, RecipeInformation> result = new Dictionary <Guid, RecipeInformation>();

        foreach (BaseItem d in equips)
        {
            int cnt = 0;
            if (materials.Length > 0)
            {
                foreach (long m in materials)
                {
                    MaterialBase mb = TableMaterial.GetItem(m, false);
                    if (d.StrengthValue < mb.StrengthValue)
                    {
                        RecipeInformation rec = new RecipeInformation();
                        rec.Weight           = d.Weight;
                        rec.RecipeTargetName = d.DisplayNameNormal;
                        rec.RecipeTargetNo   = d.ObjNo;
                        rec.RecipeTargetType = d.IType;
                        rec.SetRecipeValue(d.ObjNo, d.IType, 1, d.StrengthValue);
                        rec.SetRecipeValue(m, ItemType.Material, 1, d.StrengthValue + 1);

                        rec.IsStrength     = true;
                        rec.TargetStrength = d;

                        result.Add(rec.Name, rec);

                        cnt++;
                    }
                }
            }
            if (cnt == 0)
            {
                RecipeInformation rec = new RecipeInformation();
                rec.RecipeTargetName = d.DisplayNameNormal;
                rec.RecipeTargetNo   = d.ObjNo;
                rec.RecipeTargetType = d.IType;
                rec.SetRecipeValue(d.ObjNo, d.IType, 1, d.StrengthValue);
                rec.SetRecipeValue(smate.ObjNo, ItemType.Material, 1, d.StrengthValue + 1);

                rec.IsStrength     = true;
                rec.TargetStrength = d;

                result.Add(rec.Name, rec);
            }
        }

        return(result);
    }
Example #5
0
    //public static TableRecipeMaterialData[] GetAllValue()
    //{
    //    return Table;
    //}

    public static void SetValue(RecipeInformation rec, ushort recNo)
    {
        TableRecipeMaterialData[] data = Array.FindAll(Table, i => i.RecipeTargetObjNo == recNo);

        foreach (TableRecipeMaterialData d in data)
        {
            rec.SetRecipeValue(d.ObjNo, d.IType, d.Count, d.MinPlus);
        }
    }
        public void ConvertCsvToJson()
        {
            var recipes = new SerializedRecipesInformation()
            {
                Recipes = RecipeInformation.ParseFromCSV("./recipeinformation.csv").ToList().Select(SerializedRecipeInformation.ConvertFrom).ToList()
            };
            var jsonFilepath = Path.Combine("..", "..", "..", "SubnauticaRandomizer", "recipeinformation.json");

            File.WriteAllText(jsonFilepath, JsonConvert.SerializeObject(recipes, Formatting.Indented));
        }
        public void SerializationDoesntMutate()
        {
            var recipes = RecipeInformation.ParseFromCSV("./recipeinformation.csv").ToList();

            Assert.IsNotNull(recipes);
            Assert.IsTrue(recipes.Count > 100);
            var standardTank = recipes.FirstOrDefault(rp => rp.Type == TechType.Tank);

            Assert.IsNotNull(standardTank);
            Assert.AreEqual(standardTank.Category, "Equipment");
            Assert.AreEqual(standardTank.RandomizeDifficulty.Count, 2);
        }
        public DetailPageViewModel()
        {
            localPath = Path.Combine(FileSystem.CacheDirectory, Constants.LocalFileName);
            recipe    = JsonConvert.DeserializeObject <RecipeDetails>(File.ReadAllText(LocalPath));

            image             = recipe.ImageURL;
            title             = recipe.Title;
            description       = recipe.Description;
            recipeInformation = recipe.RecipeInformation;
            recipe.Ingredients.ForEach(i => ingredients.Add(i));
            recipe.InstructionSteps.ForEach(i => instructions.Add(i));
        }
Example #9
0
        public static RecipeInformation getFirstRecipe()
        {
            RecipeInformation recipeInformation = null;// new RecipeInformation();
            DataSet           ds;

            //2rd Assignment
            //Get the demographics from database but get the connection string details from web.Config file
            ds = RecipeGenerator_DA.Recipe_DA.getFirstRecipe();

            if (ds.Tables.Count > 0)
            {
                var row = ds.Tables[0].Rows[0];
                recipeInformation = new RecipeInformation {
                    Id          = Convert.ToInt32(row["id"]),
                    Title       = Convert.ToString(row["title"]),
                    Ingredients = Convert.ToString(row["ingredients"]),
                    Method      = Convert.ToString(row["Method"]),
                    ImageUrl    = Convert.ToString(row["ImageUrl"]),
                    CreatedOn   = Convert.ToString(row["title"])
                };
            }
            return(recipeInformation);
        }
 public IActionResult AddRecipe(RecipeInformation recipeInformation)
 {
     RecipeGenerator_BL.Recipe.save(recipeInformation);
     return(View());
 }
    // Use this for initialization
    void Start()
    {
        // BombModule.OnActivate += FunctionToCallWhenTheLightsTurnOn;
        int index = UnityEngine.Random.Range(0, RecipeInformation.AllRecipes.Length);

        SelectedRecipe = RecipeInformation.AllRecipes[index];

        ModuleLog("Selected dish: {0}", SelectedRecipe.Name);
        ModuleLog("Course: {0}", SelectedRecipe.Course);
        ModuleLog("Technique: {0} (button: {1})", SelectedRecipe.Technique.ToExtendedString(), SelectedRecipe.Technique);
        ModuleLog("Expected digit: {0}", DigitLookupTable[SelectedRecipe.Technique][SelectedRecipe.Course]);
        ModuleLog("Ingredients: {0}", SelectedRecipe.Ingredients.Select(ingr => ingr.ToFriendlyString()).Join(", "));

        // Build up our ingredients pool

        // The ingredients still needed to complete each dish
        var neededIngredients = new Dictionary <Recipe, HashSet <Ingredient> >();

        foreach (var recipe in RecipeInformation.AllRecipes)
        {
            neededIngredients[recipe] = new HashSet <Ingredient>(recipe.Ingredients.Except(SelectedRecipe.Ingredients));
        }

        // Ingredients we haven't added yet
        var ingredientsEnumerable = Enum.GetValues(typeof(Ingredient)).Cast <Ingredient>().Except(SelectedRecipe.Ingredients);
        var ingredientsPool       = new HashSet <Ingredient>(ingredientsEnumerable);

        var recipesContainingEachIngredient = RecipeInformation.RecipesContainingEachIngredient();

        int minFakeIngredients   = Math.Max(2, 7 - SelectedRecipe.Ingredients.Count);
        int maxFakeIngredients   = Math.Min(5, 10 - SelectedRecipe.Ingredients.Count);
        int fakeIngredientsCount = UnityEngine.Random.Range(minFakeIngredients, maxFakeIngredients + 1);

        var fakeIngredients = new List <Ingredient>();

        for (int i = 0; i < fakeIngredientsCount; i++)
        {
            // Eliminate any ingredients that will complete another dish
            var singletons = neededIngredients.Keys.Where(recipe => neededIngredients[recipe].Count == 1);
            foreach (var ingredient in singletons.Select(recipe => neededIngredients[recipe].First()))
            {
                ingredientsPool.Remove(ingredient);
            }

            // No need to keep track of those singletons anymore
            foreach (var recipe in singletons.ToArray())
            {
                neededIngredients.Remove(recipe);
            }

            // Pick an ingredient...
            if (ingredientsPool.Count == 0)
            {
                // This should never happen, but we include it just in case.
                // We start the loop with at least 51 ingredients and remove
                // at most 6 ingredients per iteration.
                // Nevertheless, the module should still be solvable.
                break;
            }
            var nextIngredient = ingredientsPool.PickRandom();
            fakeIngredients.Add(nextIngredient);

            // ...and mark it as used everywhere else
            ingredientsPool.Remove(nextIngredient);
            foreach (var recipe in recipesContainingEachIngredient[nextIngredient])
            {
                if (neededIngredients.ContainsKey(recipe))
                {
                    neededIngredients[recipe].Remove(nextIngredient);
                }
            }
        }

        ModuleLog("Red herrings: {0}", fakeIngredients.Select(ingr => ingr.ToFriendlyString()).Join(", "));

        CurrentIngredientsList = SelectedRecipe.Ingredients.Concat(fakeIngredients).ToList().Shuffle();
        InitialIngredientsList = CurrentIngredientsList.ToArray();

        CurrentIndex = 0;

        UpdateDisplay();

        AddedIngredients = new HashSet <Ingredient>();
    }
 public void Post(RecipeInformation information)
 {
 }
Example #13
0
 public static int save(RecipeInformation recipeInformation)
 {
     return(RecipeGenerator_DA.Recipe_DA.save(recipeInformation.Title, recipeInformation.Ingredients, recipeInformation.Method, recipeInformation.ImageUrl));
 }