Commit 48c8de28 authored by Romain DUPONT's avatar Romain DUPONT
Browse files

add echec and a lot of specs... TODO : corect bug spect

parent dd94b26f
This diff is collapsed.
......@@ -38,9 +38,14 @@ export function processMove(chessboard:Chessboard, moveString: string): boolean
let move : Move = parseMoveString(moveString);
if (move.isValid && isMovePossible(chessboard, move)) {
performMove(chessboard, move);
if(isPossible.isDangerousCase(chessboard,pieces.findPiece(chessboard,pieces.whiteKing).rank,pieces.findPiece(chessboard,pieces.whiteKing).file,true)){
performMove(chessboard, move);
if((isPossible.isDangerousCase(chessboard,pieces.findPiece(chessboard,pieces.whiteKing).rank,pieces.findPiece(chessboard,pieces.whiteKing).file,true) && whitePlay) || (isPossible.isDangerousCase(chessboard,pieces.findPiece(chessboard,pieces.blackKing).rank,pieces.findPiece(chessboard,pieces.blackKing).file,false) && !whitePlay)){
console.log("Echec !");
let invMove: Move = {from: move.to, to: move.from,isValid:true};
performMove(chessboard, invMove);
return false;
}
whitePlay = !whitePlay;
} else {
......
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