Пример #1
0
        private static Board ChooseTheSavedGame(List <string> listOfSavedGamesNames)
        {
            while (true)
            {
                Console.WriteLine("\nPlease Choose One Of the Loaded Games...\n");

                int index = 1;
                foreach (var name in listOfSavedGamesNames)
                {
                    Console.WriteLine($"{index++}) {name}");
                }

                var cki = Console.ReadKey(true);

                if (int.TryParse(cki.KeyChar.ToString(), out int choice) == true)
                {
                    if (choice < 1 || choice > listOfSavedGamesNames.Count)
                    {
                        Console.Clear();
                        Console.WriteLine("\nYou didn't chose one of the loaded games\nPlease Try Again...");
                    }

                    else
                    {
                        //Saving The Name Of The Saved Game that the User Chose
                        SavedGameName = listOfSavedGamesNames[choice - 1];

                        return(DataBaseHandler.GetTheSavedGame(listOfSavedGamesNames[choice - 1]));
                    }
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("\nSorry, That's Not a Number\nPlease Try Again...");
                }
            }
        }