public char[,] GetBoard() { Console.WriteLine("Entry GetBoard"); return(_gameBoard.GetBoard()); Console.WriteLine("Exit GetBoard"); }
public BaseGameEngine(List <IGamePlayer> players, IGameBoard board, Guid playerOneId, NoughtCrossToken playerOneToken) { _players = players; _board = board; if (_players.Count != 2) { throw new ArgumentException("Invalid number of players"); } if (board.GetBoard().Length != 3 || board.GetBoard()[0].Length != 3 || board.GetBoard()[1].Length != 3 || board.GetBoard()[2].Length != 3) { throw new ArgumentException("Invalid board size"); } if (_players.Find(e => e.Id == playerOneId) == null) { throw new ArgumentException("Player One not present"); } foreach (var player in _players) { if (player.Id == playerOneId) { player.SetPlayerToken(playerOneToken); } else { if (playerOneToken == NoughtCrossToken.X) { player.SetPlayerToken(NoughtCrossToken.O); } else { player.SetPlayerToken(NoughtCrossToken.X); } } } _gameTurn = 0; _winner = null; _playerTurn = playerOneId; }
public void BoardInitialized3By3() { _board = new GameBoard(_squares); Assert.IsNotNull(_board); var boardSquares = _board.GetBoard(); Assert.AreEqual(3, boardSquares.Length); Assert.AreEqual(3, boardSquares[0].Length); }
public void DisplayBoardScreen(IGameBoard gameBoard) { Console.WriteLine("/*/*/*/*/*/*"); _gameBoard = gameBoard; var squares = _gameBoard.GetBoard(); Console.WriteLine(); Console.Write("y "); for (var i = 0; i < squares[0].Length; i++) { Console.Write("= "); } Console.WriteLine(" "); for (var i = 0; i < squares.Length; i++) { var k = (2 - i); Console.Write(k.ToString() + "|"); for (var j = 0; j < squares[i].Length; j++) { var l = (2 - j); var token = _gameBoard.GetSquare(j, k); if (token == null) { Console.Write(" "); } else if (token == NoughtCrossToken.X) { Console.Write("X"); } else if (token == NoughtCrossToken.O) { Console.Write("O"); } if (j != (squares[i].Length - 1)) { Console.Write("|"); } } Console.WriteLine("|"); if (i != (squares.Length - 1)) { Console.WriteLine(" = = = "); } } Console.Write(" "); for (var i = 0; i < squares[0].Length; i++) { Console.Write("= "); } Console.Write(" "); Console.WriteLine(); Console.Write("x "); for (var i = 0; i < squares[0].Length; i++) { Console.Write(i.ToString() + " "); } Console.WriteLine(); Console.WriteLine("/*/*/*/*/*/*"); Console.WriteLine(); }
public char[,] GetBoard() { return(_gameBoard.GetBoard()); }