Example #1
0
 public void AskForPlayersMove(Player pl, Board gameBoard)
 {
     int gameBoardSize = gameBoard.GetBoardSize();
     ConsoleKeyInfo input ;
     do
     {
         Console.WriteLine(pl.GetPlayerName() + " it is your turn.  ");
         Console.Write("Move the cursor with the arrow keys \nand confirm the selection with spacebar");
         input = Console.ReadKey();
         if (input.Key == ConsoleKey.UpArrow)
         {
             selectedRow = selectedRow - 1;
         }
         if (input.Key == ConsoleKey.DownArrow)
         {
             selectedRow = selectedRow + 1;
         }
         if (input.Key == ConsoleKey.LeftArrow)
         {
             selectedColumn = selectedColumn - 1;
         }
         if (input.Key == ConsoleKey.RightArrow)
         {
             selectedColumn = selectedColumn + 1;
         }
         selectedRow = CorrectOutOfBounds(selectedRow, gameBoardSize);
         selectedColumn = CorrectOutOfBounds(selectedColumn, gameBoardSize);
         ClearScreen();
         Draw(gameBoard);
     } while (input.Key != ConsoleKey.Spacebar);
 }
Example #2
0
 public void AskForPlayersMove(Player pl, Board gameBoard)
 {
     int gameBoardSize = gameBoard.GetBoardSize();
     selectedColumn = moves[moveCount, 0];
     selectedRow = moves[moveCount, 1];
     moveCount++;
 }
Example #3
0
        public void TestingParameterConstructor()
        {
            //Arrange
            Board br = new Board(4);
            var expected = 4;

            //Act
            var actual = br.GetBoardSize();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void TestingDefaultConstructor()
        {
            //Arrange
            Board br = new Board();
            var expected = 3;

            //Act
            var actual = br.GetBoardSize();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Example #5
0
        /// <summary>
        ///  Draws the status of the gameBoard to a console window
        /// </summary>
        /// <param name="gameVoard">an instance of the gameBoard</param>
        public void Draw(Board gameBoard)
        {
            ClearScreen();
            DrawHeader();
            int gameBoardSize = gameBoard.GetBoardSize();
            int[,] gameBoardArray = new int[gameBoardSize, gameBoardSize];

            gameBoardArray = gameBoard.GetArray();
            for (int y = 1; y <= gameBoardSize; y++)

            {
                for (int x = 1; x <= gameBoardSize; x++)
                {
                    if (x == 1)
                        Console.Write(" " + ValueToSymbol(gameBoardArray[x-1, y-1]) + " |");
                    else if (x == gameBoardSize)
                        Console.Write("| " + ValueToSymbol(gameBoardArray[x-1, y-1]) + " ");
                    else
                        Console.Write(" " + ValueToSymbol(gameBoardArray[x-1, y-1]) + " ");
                }
                if (y == selectedRow)
                {
                    Console.Write("<");
                }
                Console.WriteLine();
                if (y != gameBoardSize)
                    Console.WriteLine("-----------");
            }
            Console.WriteLine();
            for (int x=1; x <= gameBoardSize; x++)
            {
                if (x == selectedColumn)
                    Console.WriteLine(" ^ ");
                else
                    Console.Write("    ");
            }
            Console.WriteLine();
        }