Commit 554a7eed authored by Saad MAHBOUBI's avatar Saad MAHBOUBI 💬
Browse files

ajout de commentaire dans les fonction dans chessboard

parent d9788100
......@@ -648,23 +648,4 @@ describe("Test rookMove()", () => {
let cannotCapture: Move = {from: positionE4, to: positionH4, isValid: true}
expect(isPossible.rookMove(chessboard, cannotCapture)).toBeFalsy();
});
});
describe("Test bishopMove()", () => {
beforeEach( () => {
// TODO:
// Initialize an empty chessboard
chessboard = createEmptyChessboard();
// Place a black Bishop on E4
putPiece(chessboard, positionE4, pieces.blackBishop);
});
it("A Bishop can move diagonally", () => {
// TODO:
// Check the following moves are possible:
//FIXE ME: erreur de test expect false to be truthy , alors que si un prend la case G6 (la case diagonal d'avant) l'erreur disparait
let diagonalForwardRightMove = {from: positionE4, to: positionH7, isValid: true};
expect(isEmptyDiagonal(chessboard,diagonalForwardRightMove )).toBeTruthy();
});
});
\ No newline at end of file
......@@ -34,6 +34,14 @@ export function emptyfile(chessboard : Chessboard, move: Move): boolean {
return i === end;
}
/**
* Checks whether a piece can perform vertically,
* if File is empty between the start Rank and arrive Rank.
* A piece can move any number of squares along File.
*
* @param chessboard The chessboard of the current game
* @param move
*/
export function isEmptyFile(chessboard : Chessboard, move: Move): boolean{
let start: number ;
let end : number ;
......@@ -56,6 +64,15 @@ export function isEmptyFile(chessboard : Chessboard, move: Move): boolean{
return true;
}
/**
* Checks whether a piece can perform hotizontally,
* if Rank is empty between the start File and arrive File.
* A piece can move any number of squares along Rank.
*
* @param chessboard The chessboard of the current game
* @param move
*/
export function isEmptyRank(chessboard : Chessboard, move: Move): boolean{
let start: number ;
let end : number ;
......@@ -79,6 +96,8 @@ export function isEmptyRank(chessboard : Chessboard, move: Move): boolean{
return true;
}
export function isEmptyDiagonal(chessboard : Chessboard, move: Move): boolean{
if(move.from!.file > move.to!.file && move.from!.rank > move.to!.rank){
......
......@@ -55,6 +55,7 @@ class HttpServer {
}else{
message = "Invalid movement!";
}
res.render('index', {error: message});
});
}
......
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