Пример #1
0
 public GameBoard PlaceVerticalShipOfLength(GameBoard oldGameBoard, int shipLength)
 {
     return(NewGameBoardFromOld(
                oldGameBoard,
                shipLength,
                () => (
                    _randomCoordSelector('a', 'j'),
                    _randomCoordSelector('0', (char)('9' - (shipLength - 1)))
                    ),
                (newX, newY, x) => new Square
     {
         X = newX,
         Y = (char)(newY + x)
     }));
 }
Пример #2
0
 public GameBoard PlaceHorizontalShipOfLength(GameBoard oldGameBoard, int shipLength)
 {
     return(NewGameBoardFromOld(
                oldGameBoard,
                shipLength,
                () => (
                    _randomCoordSelector('a', (char)('j' - (shipLength - 1))),
                    _randomCoordSelector('0', '9')
                    )
                ,
                (newX, newY, x) => new Square
     {
         X = (char)(newX + x),
         Y = newY
     }));
 }
Пример #3
0
        public GameBoard PlaceDiagonallyDownAndLeftShipOfLength(GameBoard oldGameBoard, int shipLength)
        {
            var minXCoord = (char)('a' + (shipLength - 1));
            var maxYCoord = (char)('9' - (shipLength - 1));

            return(NewGameBoardFromOld(
                       oldGameBoard,
                       shipLength,
                       () => (
                           _randomCoordSelector(minXCoord, 'j'),
                           _randomCoordSelector('0', maxYCoord)
                           ),
                       (newX, newY, x) => new Square
            {
                X = (char)(newX - x),
                Y = (char)(newY + x)
            }));
        }