Exemple #1
0
        public void Play()
        {
            int  EnterFromUser, AmountStepsOfGame;
            bool ControlMenu = false;

            do
            {
                Console.Clear();
                Console.WriteLine("Enter the number which you want to move.\n");
                Console.WriteLine("Enter -1 to shake values.\n");
                //Console.WriteLine("Enter -2 to see history.\n");
                //Console.WriteLine("Enter -3 to FlashBack.\n");
                Console.WriteLine("Enter 0 to leave.\n");
                OutPutMatrix();
                if (Iplayable.IsFinished())
                {
                    Console.WriteLine("You WIN!!!");
                }

                EnterFromUser = int.Parse(Console.ReadLine());
                switch (EnterFromUser)
                {
                case 0:
                    ControlMenu = true;
                    Console.Beep();
                    break;

                case -1:
                    Iplayable.Randomize();
                    break;

                /*case -2:
                 *  for (int i = 0; i < FieldOfGame.GetHistory.Count; i++)
                 *  {
                 *      Console.WriteLine("Value " + FieldOfGame.GetHistory[i].value +
                 *          " we moved on " + FieldOfGame.GetHistory[i].valueX + " " + FieldOfGame.GetHistory[i].valueY);
                 *  }
                 *  Console.WriteLine("Enter any key to continue.");
                 *  Console.ReadKey();
                 *  break;
                 *
                 * case -3:
                 *  Console.WriteLine("How many steps you want roll back?");
                 *  AmountStepsOfGame = int.Parse(Console.ReadLine());
                 *  FieldOfGame.FlashBackOnStep(AmountStepsOfGame);
                 *  break;*/

                default:
                    Iplayable.Shift(EnterFromUser);
                    Console.Beep();
                    break;
                }
            } while (!ControlMenu);
        }
Exemple #2
0
        public void Play()
        {
            PrintMenu();
            PrintBoard();
            while (!game.IsCompleted())
            {
                try
                {
                    bool   tempFlag = true;
                    string s        = Console.ReadLine();
                    switch (s)
                    {
                    case "q":
                        tempFlag = false;
                        break;

                    case "r":
                        game.Randomize();
                        RefreshScreen();
                        break;

                    default:
                        game.Shift(int.Parse(s));
                        RefreshScreen();
                        break;
                    }

                    if (tempFlag == false)
                    {
                        break;
                    }
                }

                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }