@Before public void setup() { player1 = new Player(1, false, null); player2 = new Player(-1, false, null); player1.setOtherPlayer(player2); player2.setOtherPlayer(player1); ; }
/** Tests to see if a bishop at 4,4 causes check to a king at 2,2 */ @Test public void testBasicCheck() { setup(); chessBoard = new RectangularBoard(new StandardGame()); Bishop b = new Bishop(4, 4, chessBoard, player1); King k = new King(2, 2, chessBoard, player2); assertTrue(chessBoard.locationPressured(player2.getKing().getLocation(), player2)); assertEquals(6, chessBoard.getAllMoves(player2).size()); }
/** Tests a complicated checkmate situation where player2 is checkmated by player1's knight. */ @Test public void testComplicatedMate() { setup(); chessBoard = new RectangularBoard(new StandardGame()); Bishop b = new Bishop(4, 4, chessBoard, player1); Knight h = new Knight(5, 4, chessBoard, player1); King k = new King(3, 3, chessBoard, player1); Rook R = new Rook(5, 7, chessBoard, player2); King K = new King(6, 7, chessBoard, player2); Pawn P1 = new Pawn(5, 6, chessBoard, player2); Pawn P2 = new Pawn(7, 6, chessBoard, player2); Pawn P3 = new Pawn(6, 5, chessBoard, player2); /* 7 . . R K . (player 2) Capital's direction is down 6 . . P . P NOTE: ORGINAL VIEW 5 . . . P . 4 . b h . . 3 k . . . . 3 4 5 6 7 */ assertFalse(chessBoard.locationPressured(player2.getKing().getLocation(), player2)); // now move the horse h.movePieceToTile(new Point(7, 5), true); assertTrue(chessBoard.locationPressured(player2.getKing().getLocation(), player2)); assertTrue(chessBoard.noPossibleMoves(player2)); /* 7 . . R K . Capital's direction is down 6 . . P . P NOTE: FINAL OUTCOME, horse was at 5, 4 5 . . . P h 4 . b . . . 3 . . . . . 3 4 5 6 7 */ }