Example #1
0
 private char GetFieldStatus(BoardField boardField)
 {
     if (boardField.HasShip)
     {
         if (boardField.Status == BoardField.State.ShotDown)
         {
             return(_shipStatus[boardField.GetShip().Status]);
         }
         else
         {
             return(_fieldStatus[boardField.Status]);
         }
     }
     else
     {
         return(_fieldStatus[boardField.Status]);
     }
 }
Example #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);
        }