Example #1
0
        public ActionResult <Status> PassTurn()
        {
            Status result = null;

            try
            {
                _game.PassTurn();
                result = new Status();
            }
            catch (Exception ex)
            {
                result = new Status(false, ex.Message);
            }
            return(UpdateStatus(result));
        }
Example #2
0
        private void TurnMenu()
        {
            bool quit = false;

            while (!quit)
            {
                try
                {
                    Console.Clear();

                    if (_game.HasWinner)
                    {
                        Utility.PlaySound("applause.wav");
                        _game.SaveWinner(_game.CurrentPlayerName);
                        Console.Clear();
                        Console.WriteLine("The winner is " + _game.CurrentPlayerName);
                        Console.ReadKey();
                        quit = true;
                    }
                    else
                    {
                        DisplayPlayerStatus();
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine();
                        Console.WriteLine("1) Roll");
                        Console.WriteLine("2) End Turn");
                        Console.WriteLine("3) Score Board");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("4) Suicide");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine();

                        int selection = CLIHelper.GetSingleInteger("Select an option...", 1, 4);

                        if (selection == 1)
                        {
                            Utility.PlaySound("thunder.wav");
                            RollDice();
                        }
                        else if (selection == 2)
                        {
                            Utility.PlaySound("skids.wav");
                            _game.PassTurn();
                        }
                        else if (selection == 3)
                        {
                            DisplayScoreBoard();
                        }
                        else if (selection == 4)
                        {
                            DisplaySuicideScreen();
                            quit = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadKey();
                }
            }
        }