|
@ -161,4 +161,51 @@ class ChessBoardTest { |
|
|
assertTrue(chessBoard.validateMove(4, 7, 6, 5)); |
|
|
assertTrue(chessBoard.validateMove(4, 7, 6, 5)); |
|
|
assertFalse(chessBoard.validateMove(4, 7, 7, 4)); |
|
|
assertFalse(chessBoard.validateMove(4, 7, 7, 4)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 |
|
|
|
|
|
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ |
|
|
|
|
|
0 │ │ │ │ │ │ │ │ │ 0 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
1 │ │ │ │ T │ │ │ │ K │ 1 │ │ │ │ │ │ │ │ K │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
2 │ │ │ │ │ │ │ │ │ 2 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
3 │ │ │ │ │ │ Z │ │ │ 3 │ │ │ │ │ │ Z │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ --> ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
4 │ │ │ │ │ │ │ │ │ 4 │ │ │ │ │ B │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
5 │ │ │ |Q| │ │ │ │ │ │ 5 │ │ │ T │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
6 │ │ │ │ │ │ │ B │ │ 6 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ ├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤ |
|
|
|
|
|
7 │ │ │ │ │ │ │ │ │ 7 │ │ │ │ │ │ │ │ │ |
|
|
|
|
|
└─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ |
|
|
|
|
|
*/ |
|
|
|
|
|
@Test |
|
|
|
|
|
void moveFigure() { |
|
|
|
|
|
ChessFigure[][] tempBoard = new ChessFigure[8][8]; |
|
|
|
|
|
ChessFigure[][] resultBoard = new ChessFigure[8][8]; |
|
|
|
|
|
|
|
|
|
|
|
tempBoard[1][3] = new ChessFigure(ChessFigure.Type.CASTLE, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[1][7] = new ChessFigure(ChessFigure.Type.KNIGHT, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[6][6] = new ChessFigure(ChessFigure.Type.BISHOP, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[3][5] = new ChessFigure(ChessFigure.Type.KNIGHT, ChessFigure.Team.WHITE); |
|
|
|
|
|
tempBoard[5][2] = new ChessFigure(ChessFigure.Type.QUEEN, ChessFigure.Team.BLACK); |
|
|
|
|
|
|
|
|
|
|
|
resultBoard[5][2] = new ChessFigure(ChessFigure.Type.CASTLE, ChessFigure.Team.WHITE); |
|
|
|
|
|
resultBoard[1][7] = new ChessFigure(ChessFigure.Type.KNIGHT, ChessFigure.Team.WHITE); |
|
|
|
|
|
resultBoard[4][4] = new ChessFigure(ChessFigure.Type.BISHOP, ChessFigure.Team.WHITE); |
|
|
|
|
|
resultBoard[3][5] = new ChessFigure(ChessFigure.Type.KNIGHT, ChessFigure.Team.WHITE); |
|
|
|
|
|
|
|
|
|
|
|
chessBoard.setChessBoard(tempBoard); |
|
|
|
|
|
|
|
|
|
|
|
assertEquals(chessBoard.moveFigure(3, 1, 2, 1), ChessBoard.MoveFeedback.MOVE); |
|
|
|
|
|
assertEquals(chessBoard.moveFigure(2, 1, 2, 5), ChessBoard.MoveFeedback.ENEMYBEATEN); |
|
|
|
|
|
assertEquals(chessBoard.moveFigure(6, 6, 4, 4), ChessBoard.MoveFeedback.MOVE); |
|
|
|
|
|
assertEquals(chessBoard.moveFigure(7, 1, 8, 1), ChessBoard.MoveFeedback.OUTSIDEOFBOARD); |
|
|
|
|
|
assertEquals(chessBoard.moveFigure(5, 3, 4, 2), ChessBoard.MoveFeedback.INVALID); |
|
|
|
|
|
|
|
|
|
|
|
assertArrayEquals(resultBoard, chessBoard.getBoard()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |