예제 #1
0
파일: Game.cs 프로젝트: JacDev/Battleship
        private bool Play()
        {
            Player winer;

            while (true)
            {
                Player  currentPlayer       = _whoseTurn == BoardSide.Left ? _leftPlayer : _rightPlayer;
                Actions currentPlayerAction = currentPlayer.Shoot();
                if (currentPlayerAction == Actions.EndGame)
                {
                    winer = currentPlayer;
                    break;
                }
                else if (currentPlayerAction == Actions.BackToMenu)
                {
                    return(false);
                }
                else
                {
                    _whoseTurn = _whoseTurn == BoardSide.Left ? BoardSide.Right : BoardSide.Left;
                }
            }
            if (winer.WhichBoard == BoardSide.Left)
            {
                _outputDevice.SetBottomMessage(8);
            }
            else
            {
                _outputDevice.SetBottomMessage(9);
            }
            _outputDevice.PrintBoard(_leftPlayer.Board, _rightPlayer.Board, false);
            Console.WriteLine();
            Console.Write(("").PadRight(40, ' '));
            ReadEnter();
            return(true);
        }