Exemple #1
0
        static void Main(string[] args)
        {
            FileReader   filereader   = new FileReader();
            Board        board        = new Board();
            BoardPrinter boardprinter = new BoardPrinter();

            bool[,] x = filereader.MakeBoard(@"C:\Users\FIT\Ejercicio-Kiosko\Ejercicio4\src\Library\Prueba.txt");
            bool[,] y = board.GameLogic(x);
            boardprinter.PrintBoard(y);
        }
        public void PrintBoard_InitiateBoardWith5RowsAnd5Columns_ResultStringContains143CharactersIncludingBoardDelimiters()
        {
            Board board = new(rowCount : 5, columnCount : 5);

            board.PlaceCharTile(X: 1, Y: 2, c: new CharTile('H'));
            board.PlaceCharTile(X: 2, Y: 2, c: new CharTile('E'));
            board.PlaceCharTile(X: 3, Y: 2, c: new CharTile('L'));
            board.PlaceCharTile(X: 4, Y: 2, c: new CharTile('L'));
            board.PlaceCharTile(X: 5, Y: 2, c: new CharTile('O'));

            string boardString = BoardPrinter.PrintBoard(board);

            Assert.IsTrue(boardString.Length == 143);
        }
Exemple #3
0
        /// <summary>
        /// Starts the game
        /// </summary>
        /// <param name="allowedShips"></param>
        /// <param name="boardSize"></param>
        public void Start(IReadOnlyList <Type> allowedShips = null, int boardSize = 10)
        {
            AllowedShips = allowedShips ?? new List <Type>
            {
                typeof(AircraftCarrier),
                typeof(Ships.Battleship),
                typeof(Submarine),
                typeof(Cruiser),
                typeof(Destroyer)
            };
            BoardSize = boardSize;

            // add player
            var players = GetPlayers();

            _players.AddRange(players);
            _players.ForEach(p => PlaceShips(p));

            Status = GameStatus.Started;

            BoardPrinter.PrintBoard(this);
        }