Commit 853ee6bc authored by Romain DUPONT's avatar Romain DUPONT
Browse files

importation de la fonction DiagonalMove

parent 6380b3bf
......@@ -103,6 +103,7 @@ export function queenMove(board: Chessboard, move: Move): boolean {
export function rookMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function
return rankFileMove(board, move);
}
......@@ -116,8 +117,8 @@ export function rookMove(board: Chessboard, move: Move): boolean {
* @param move
*/
export function bishopMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function
return true;
// #TODO: Implement this
return DiagonalMove(board, move);
}
/**
......@@ -134,8 +135,7 @@ export function bishopMove(board: Chessboard, move: Move): boolean {
*/
export function knightMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function
return ((Math.abs(move.to!.rank-move.from!.rank)==1 && Math.abs(move.to!.file-move.from!.file)==2) ||
(Math.abs(move.to!.rank-move.from!.rank)==2 && Math.abs(move.to!.file-move.from!.file)==1) );
}
......@@ -185,4 +185,12 @@ function rankFileMove(board: Chessboard, move: Move): boolean {
return false;
}
}
\ No newline at end of file
}
function DiagonalMove(board : Chessboard, move : Move) : boolean {
return (Math.abs(move.to!.rank - move.from!.rank) == Math.abs(move.to!.file - move.from!.file));
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment