using Mastermind;
using System;

namespace Controller
{
    /// <summary>
    /// Mangages the game flow, handling user interactions and processing inputs
    /// </summary>
    class MastermindController
    {
        private MastermindGame spiel;
        private string difficulty;

        /// <summary>
        /// Starts the game and controls the sequence 
        /// </summary>
        public void Play()
        {
            Console.WriteLine("Welcome to Mastermind!");
            Console.WriteLine("======================");

            // User selects a difficulty
            Console.WriteLine("Please select the difficulty you would like to play on:\n");

            Console.WriteLine("Difficulty: \t[E]asy \nDescription: \tRecommended for beginners.\n");
            Console.WriteLine("Difficulty: \t[M]edium \nDescription: \tRecommended for advanced users.\n");
            Console.WriteLine("Difficulty: \t[H]ard \nDescription: \tRecommended for those who are looking for a challenge.\n");

            bool checkMenu = false;
            do
            {
                switch (Console.ReadLine().ToLower())
                {
                    case "e":
                        difficulty = "easy";
                        checkMenu = true;
                        break;
                    case "m":
                        difficulty = "medium";
                        checkMenu = true;
                        break;
                    case "h":
                        difficulty = "hard";
                        checkMenu = true;
                        break;
                    default:
                        Console.WriteLine("Something went wrong! Try again. Only the letters \"E\", \"M\", \"H\" are allowed. ");
                        break;
                }

            } while (!checkMenu);

            // Starts Game
            Console.WriteLine($"Game starts with the difficulty: {difficulty}");
            spiel = new MastermindGame(difficulty);
        }
    }
}