// The goal is to test various representative valid and invalid // moves for correctness. Throws Exception if a validly specified // path is determined to be invalid, or if an invalidly specified // path is determined to be valid. private static void TestBoardMapPathing() { // Create a new empty game board. TzaarBoardMap boardMap = new TzaarBoardMap(); TzaarBoard board = new TzaarBoard(true); // Create some game pieces of various types. TzaarPiece p1 = new TzaarPiece.Tzaar(TzaarColor.BLACK); TzaarPiece p2 = new TzaarPiece.Tzarra(TzaarColor.BLACK); TzaarPiece p3 = new TzaarPiece.Tott(TzaarColor.BLACK); // Operate on this specific position. int col = 8; int row = 0; // Add the pieces we created to the board at the target // position. board.Add(p1, col, row); board.Add(p2, col, row); board.Add(p3, col, row); // Check that a valid move is reported as valid. if (!boardMap.IsValidPath(board, 0, 0, 0, 1)) throw new Exception(); // Check that an invalid move is reported as invalid. if (boardMap.IsValidPath(board, 4, 3, 4, 4)) throw new Exception(); board.Add(p1, 2, 2); board.Add(p2, 2, 3); // Check that an invalid move is reported as invalid. if (!boardMap.IsValidPath(board, 2, 2, 2, 3)) throw new Exception(); // Check that passing through another piece is reported as // invalid. board.Add(p1, 1, 1); if (boardMap.IsValidPath(board, 0, 0, 2, 2)) throw new Exception(); // Remove the obstructing piece and verify that (0, 0) and // (2, 2) are now connected. board.Take(1, 1); if (!boardMap.IsValidPath(board, 0, 0, 2, 2)) throw new Exception(); }
public TzaarLogic(GameState aState) { this.boardMap = new TzaarBoardMap(); this.state = (TzaarGameState)aState; }
public TzaarLogic(GameBoard aBoard) { this.boardMap = new TzaarBoardMap(); this.state = new TzaarGameState(aBoard); }
// A game can be constructed without a parameter (empty board), with a // premade board, with a premade state, or with the bool value 'true' // for a randomly generated board. public TzaarLogic() { this.boardMap = new TzaarBoardMap(); TzaarBoard board = new TzaarBoard(); this.state = new TzaarGameState(board); }