示例#1
0
        public void Play()
        {
            do
            {
                ShotConfig  shotConfig = ConfigureShot();
                Shot.Result shotResult = Shoot(shotConfig);

                _userInterface.PrintShotResult(shotResult);
                _userInterface.PrintNumberOfShipsOnBoard(_board.ShipsOnBoard);
                _userInterface.PrintBoardStatus(_board);
            } while (!_board.IsClear);
        }
示例#2
0
        private Shot.Result Shoot(ShotConfig shotConfig)
        {
            BoardField targetField = _board.GetField(shotConfig.RowNumber, shotConfig.ColumnNumber);

            Shot.Result shotResult = targetField.Shoot();

            if (shotResult == Shot.Result.Destroyed)
            {
                _board.DecreaseShipsNumber();
            }

            _statistics.IncreaseShots();
            if (shotResult != Shot.Result.Missed)
            {
                _statistics.IncreaseShotsOnTarget();
            }

            return(shotResult);
        }
示例#3
0
 public void PrintShotResult(Shot.Result ShotResult)
 {
     Console.Clear();
     Console.WriteLine(_shotResult[ShotResult]);
 }