Commit 00da295a authored by Saad MAHBOUBI's avatar Saad MAHBOUBI
Browse files

Toutes les fonctions sont finis et marche, plus que les test a faire.

parent d426e31e
......@@ -202,5 +202,39 @@ export function bishopMove(board: Chessboard, move: Move): boolean {
*/
export function knightMove(board: Chessboard, move: Move): boolean {
// #TODO: Implement this function
return true;
let depart: Square = squareAtPosition(board, move.from!);
let destination: Square = squareAtPosition(board, move.to!);
if (equals( move.to!, top(top(right(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, top(top(left(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, bottom(bottom(right(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, bottom(bottom(left(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, left(left(top(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, left(left(bottom(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, right(right(top(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
if (equals( move.to!, right(right(bottom(move.from!)))) ) {
return isEmpty(board, move.to!) || (depart.piece!.isWhite === !destination.piece!.isWhite);
}
return false;
}
\ 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