public IHttpActionResult SaveRecipe(int id)
        {
            string message = new RecipeHandler().AddRecipeToCookBook(id, "Saved Recipes",
                                                                     new CurrentUserIdRetriever().GetUserId(User.Identity as ClaimsIdentity));

            return(Ok(message));
        }
Ejemplo n.º 2
0
    public void Initialize(Object obj)
    {
        player = obj as Player;

        dropAnchor      = GameObject.Find("r_DropAnchor").transform;    // TODO: Make safer
        inventoryVisual = Resources.Load("Prefabs/GUIPrefabs/InventoryVisual") as GameObject;

        GameAccesPoint.Instance.hudGUIState.AddPlayerInventoryHandler(this);
        worldController = GameAccesPoint.Instance.mainGameState._worldController;

        recipeHandler = new RecipeHandler();
        recipeHandler.Initialize();

        _inventory = GameAccesPoint.Instance.hudGUIState.GetInitialInventory();
        GameAccesPoint.Instance.hudGUIState.ClearInventory();

        foreach (KeyValuePair <Transform, InventoryItem> pair in _inventory)
        {
            if (pair.Key.name == "CraftOutputSlot")
            {
                craftSlot = pair.Key;
            }
        }

        if (player._currentPlayerState != null)
        {
            RecreateInventory(player._currentPlayerState.savableInventory);
        }
    }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetRecipe(string recipeId, [FromQuery] string?projectPath = null)
        {
            if (string.IsNullOrEmpty(recipeId))
            {
                return(BadRequest($"A Recipe ID was not provided."));
            }

            ProjectDefinition?projectDefinition = null;

            if (!string.IsNullOrEmpty(projectPath))
            {
                projectDefinition = await _projectDefinitionParser.Parse(projectPath);
            }
            var recipeDefinitions = await RecipeHandler.GetRecipeDefinitions(_customRecipeLocator, projectDefinition);

            var selectedRecipeDefinition = recipeDefinitions.FirstOrDefault(x => x.Id.Equals(recipeId));

            if (selectedRecipeDefinition == null)
            {
                return(BadRequest($"Recipe ID {recipeId} not found."));
            }

            var output = new RecipeSummary(
                selectedRecipeDefinition.Id,
                selectedRecipeDefinition.Version,
                selectedRecipeDefinition.Name,
                selectedRecipeDefinition.Description,
                selectedRecipeDefinition.ShortDescription,
                selectedRecipeDefinition.TargetService,
                selectedRecipeDefinition.DeploymentType.ToString(),
                selectedRecipeDefinition.DeploymentBundle.ToString()
                );

            return(Ok(output));
        }
Ejemplo n.º 4
0
    public void GetNewRecipe(int slot)
    {
        if (slot < 0 || slot >= 3)
        {
            return;
        }

        RecipeHandler add_back = null;

        //Detach recipe from slot if neccesary
        if (recipeGridContainer.allGrids[slot].transform.childCount != 0)
        {
            add_back = recipeGridContainer.allGrids[slot].transform.GetChild(0).GetComponent <RecipeHandler>();
            shownRecipes.Remove(add_back);
            recipeGridContainer.allGrids[slot].transform.GetChild(0).gameObject.SetActive(false);
            recipeGridContainer.allGrids[slot].transform.DetachChildren();
        }

        int           index  = Random.Range(0, allRecipes.Count);
        RecipeHandler recipe = allRecipes[index];

        recipe.transform.SetParent(recipeGridContainer.allGrids[slot].transform, true);
        recipe.transform.gameObject.SetActive(true);

        shownRecipes.Add(recipe);
        allRecipes.Remove(recipe);

        if (add_back != null)
        {
            allRecipes.Add(add_back);
        }
    }
Ejemplo n.º 5
0
        public IActionResult Index()
        {
            var filepath = "recipes.json";

            handler = new RecipeHandler(filepath);
            handler.loadJsonFile();

            return(View(handler));
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            RecipeHandler handler = new RecipeHandler();
            RecipeModel   model   = new RecipeModel();

            List <Recipe>         list  = handler.GetListOfActiveRecipes();
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (Recipe p in list)
            {
                items.Add(new SelectListItem()
                {
                    Text = p.Description + " " + p.DateEntered.ToString("MM/dd/yyyy"), Value = p.RecipeId.ToString()
                });
            }

            model.ActiveRecipes = items;

            return(View("Recipes", model));
        }
Ejemplo n.º 7
0
        public async Task RecipeController_GetRecipe_WithProjectPath()
        {
            var directoryManager        = new DirectoryManager();
            var fileManager             = new FileManager();
            var projectDefinitionParser = new ProjectDefinitionParser(fileManager, directoryManager);

            var mockCustomRecipeLocator = new Mock <ICustomRecipeLocator>();

            var sourceProjectDirectory = SystemIOUtilities.ResolvePath("WebAppWithDockerFile");

            var customLocatorCalls = 0;

            mockCustomRecipeLocator
            .Setup(x => x.LocateCustomRecipePaths(It.IsAny <string>(), It.IsAny <string>()))
            .Callback <string, string>((csProjectPath, solutionPath) =>
            {
                customLocatorCalls++;
                Assert.Equal(new DirectoryInfo(sourceProjectDirectory).FullName, Directory.GetParent(csProjectPath).FullName);
            })
            .Returns(Task.FromResult(new HashSet <string>()));

            var projectDefinition = await projectDefinitionParser.Parse(sourceProjectDirectory);

            var recipeDefinitions = await RecipeHandler.GetRecipeDefinitions(mockCustomRecipeLocator.Object, projectDefinition);

            var recipe = recipeDefinitions.First();

            Assert.NotEqual(0, customLocatorCalls);

            customLocatorCalls = 0;
            var recipeController = new RecipeController(mockCustomRecipeLocator.Object, projectDefinitionParser);
            var response         = await recipeController.GetRecipe(recipe.Id, sourceProjectDirectory);

            Assert.NotEqual(0, customLocatorCalls);

            var result       = Assert.IsType <OkObjectResult>(response);
            var resultRecipe = Assert.IsType <RecipeSummary>(result.Value);

            Assert.Equal(recipe.Id, resultRecipe.Id);
        }
Ejemplo n.º 8
0
        public async Task RecipeController_GetRecipe_HappyPath()
        {
            var directoryManager              = new DirectoryManager();
            var fileManager                   = new FileManager();
            var deploymentManifestEngine      = new DeploymentManifestEngine(directoryManager, fileManager);
            var consoleInteractiveServiceImpl = new ConsoleInteractiveServiceImpl();
            var consoleOrchestratorLogger     = new ConsoleOrchestratorLogger(consoleInteractiveServiceImpl);
            var commandLineWrapper            = new CommandLineWrapper(consoleOrchestratorLogger);
            var customRecipeLocator           = new CustomRecipeLocator(deploymentManifestEngine, consoleOrchestratorLogger, commandLineWrapper, directoryManager);
            var projectDefinitionParser       = new ProjectDefinitionParser(fileManager, directoryManager);

            var recipeController  = new RecipeController(customRecipeLocator, projectDefinitionParser);
            var recipeDefinitions = await RecipeHandler.GetRecipeDefinitions(customRecipeLocator, null);

            var recipe = recipeDefinitions.First();

            var response = await recipeController.GetRecipe(recipe.Id);

            var result       = Assert.IsType <OkObjectResult>(response);
            var resultRecipe = Assert.IsType <RecipeSummary>(result.Value);

            Assert.Equal(recipe.Id, resultRecipe.Id);
        }
        public IHttpActionResult RemoveRecipeFromCookBook(int rid, int cid)
        {
            string result = new RecipeHandler().RemoveRecipeFromCookBook(rid, cid);

            return(Ok(result));
        }
Ejemplo n.º 10
0
 public RecipeController(IRecipeRepository repository, RecipeHandler handler)
 {
     _repository = repository;
     _handler    = handler;
 }
Ejemplo n.º 11
0
 public override void AddRecipeGroups() => RecipeHandler.AddRecipeGroups();
Ejemplo n.º 12
0
 public override void PostAddRecipes() => RecipeHandler.ModifyRecipes();
Ejemplo n.º 13
0
    public void CheckValidRecipe(GameObject food_collection, bool pot, bool special, bool is_burned)
    {
        bool recipe_found = false;

        if (!is_burned)
        {
            for (int i = 0; i < recipeGridContainer.allGrids.Count && !recipe_found; ++i)
            {
                List <IngredientPrepration> ingredient_list = SetUpIngredientList(food_collection, special);
                bool          recipe_check_failed           = false;
                RecipeHandler recipe_handler = recipeGridContainer.allGrids[i].transform.GetChild(0).GetComponent <RecipeHandler>();
                if ((recipe_handler.recipeData.canUsePot == pot || recipe_handler.recipeData.canUsePan == !pot) && !recipe_handler.Completed)
                {
                    for (int j = 0; j < recipe_handler.recipeData.recipeList.Count && !recipe_check_failed; ++j)
                    {
                        bool correct_ingredient_found = false;
                        for (int k = 0; k < ingredient_list.Count && !correct_ingredient_found; ++k)
                        {
                            //print("comparing " + recipe_handler.recipeData.recipeList[j].ingredientToAddToRecipe.name + " to " + ingredient_list[k].Ingredient.name);
                            //print(recipe_handler.recipeData.recipeList[j].mustBeChopped + "  vs " + ingredient_list[k].fullyCut);
                            //Try to find ingredient match from recipe to ingredeint list
                            if (recipe_handler.recipeData.recipeList[j].ingredientToAddToRecipe.name == ingredient_list[k].Ingredient.name &&
                                recipe_handler.recipeData.recipeList[j].mustBeChopped == ingredient_list[k].fullyCut)
                            {
                                //print("found correct " + recipe_handler.recipeData.recipeList[j].ingredientToAddToRecipe.name);
                                correct_ingredient_found          = true;
                                ingredient_list[k].hasBeenChecked = true;
                                break;
                            }
                        }

                        if (!correct_ingredient_found)
                        {
                            recipe_check_failed = true;
                            //print("incorrect match with recipe " + recipe_handler.name);
                        }
                    }

                    //print(recipe_handler.totalIngredientsNeeded + " == " + ingredient_list.Count);
                    if (!recipe_check_failed && recipe_handler.totalIngredientsNeeded == ingredient_list.Count)
                    {
                        //print("Recipe Match found with " + recipe_handler.name);
                        GameManager.Instance.currentScore += recipe_handler.recipeData.Points;
                        UIManager.Instance.SetScore(GameManager.Instance.currentScore);
                        recipe_handler.Completed = true;
                        recipe_found             = true;
                    }
                }
                else
                {
                    //print("incorrect cooking ware with " + recipe_handler.name);
                }
            }
        }


        //Score discard bonus if neccesary
        if (!recipe_found)
        {
            int cut_ingre   = 0;
            int uncut_ingre = 0;
            List <IngredientPrepration> ingre_prep = SetUpIngredientList(food_collection, special);
            for (int i = 0; i < ingre_prep.Count; ++i)
            {
                if (ingre_prep[i].fullyCut)
                {
                    cut_ingre++;
                }
                else
                {
                    uncut_ingre++;
                }
            }

            int discard_bonus = (uncut_ingre * GameManager.Instance.discardBonus) + (cut_ingre * GameManager.Instance.discardBonus * 2);
            GameManager.Instance.currentScore += discard_bonus;
            UIManager.Instance.SetScore(GameManager.Instance.currentScore);
        }
        else
        {
            AudioMana.Instance.PlayAudio(successAudio);
        }

        //Discard contents
        if (special)
        {
            food_collection.GetComponent <Food>().TerminateObject();
        }
        else
        {
            //print(food_collection.name);
            for (int i = food_collection.transform.childCount - 1; i >= 0; --i)
            {
                //print("trashing " + food_collection.transform.GetChild(i).gameObject.name);
                food_collection.transform.GetChild(i).gameObject.GetComponent <Food>().TerminateObject();
            }
        }
    }