Commit aa5e3c8b authored by Saad MAHBOUBI's avatar Saad MAHBOUBI 💬
Browse files

changement de la fonction isEmptyDiagonal et on constate un bug boucle (infinie)

parent 549eaca8
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'decv' ]
2 info using npm@3.5.2
3 info using node@v8.10.0
4 verbose stack Error: missing script: decv
4 verbose stack at run (/usr/share/npm/lib/run-script.js:147:19)
4 verbose stack at /usr/share/npm/lib/run-script.js:57:5
4 verbose stack at /usr/share/npm/node_modules/read-package-json/read-json.js:345:5
4 verbose stack at checkBinReferences_ (/usr/share/npm/node_modules/read-package-json/read-json.js:309:45)
4 verbose stack at final (/usr/share/npm/node_modules/read-package-json/read-json.js:343:3)
4 verbose stack at then (/usr/share/npm/node_modules/read-package-json/read-json.js:113:5)
4 verbose stack at /usr/share/npm/node_modules/read-package-json/read-json.js:300:12
4 verbose stack at /usr/share/npm/node_modules/graceful-fs/graceful-fs.js:76:16
4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
5 verbose cwd /home/saad/Documents/l1_s2/introdev/onlineChess
6 error Linux 4.18.0-16-generic
7 error argv "/usr/bin/node" "/usr/bin/npm" "run" "decv"
8 error node v8.10.0
9 error npm v3.5.2
10 error missing script: decv
11 error If you need help, you may report this error at:
11 error <https://github.com/npm/npm/issues>
12 verbose exit [ 1, true ]
......@@ -47,7 +47,7 @@ export function isEmptyFile(chessboard : Chessboard, move: Move): boolean{
}
for(let i : number = start + 1; i < end ; i++) {
let movePosition : Position = { rank : i , file : move.from!.file};
let movePosition : Position = {rank : i , file : move.from!.file};
let squareMove : Square = squareAtPosition(chessboard, movePosition);
if(!squareMove.isEmpty){
return false;
......@@ -80,34 +80,30 @@ export function isEmptyRank(chessboard : Chessboard, move: Move): boolean{
}
export function isEmptyDiagonal(chessboard : Chessboard, move: Move): boolean{
let startFile: number ;
let endFile : number ;
let startRank: number ;
let endRank : number ;
if (move.from!.file > move.to!.file) {
startFile = move.to!.file;
endFile = move.from!.file;
} else {
endFile = move.to!.file;
startFile = move.from!.file;
}
if (move.from!.rank > move.to!.rank) {
startRank = move.to!.rank;
endRank = move.from!.rank;
} else {
endRank = move.to!.rank;
startRank = move.from!.rank;
let moveFile : number ;
let moveRank : number ;
if(move.from!.file > move.to!.file && move.from!.rank > move.to!.rank){
moveFile = -1;
moveRank = -1;
}else if(move.from!.file > move.to!.file && move.from!.rank < move.to!.rank){
moveFile = -1;
moveRank = 1;
}else if(move.from!.file < move.to!.file && move.from!.rank > move.to!.rank){
moveFile = 1;
moveRank = -1;
}else{
moveFile = 1;
moveRank = 1;
}
if(!((endFile - startFile) === (endRank - startRank))){
if(!(Math.abs(move.from!.file - move.to!.file) === Math.abs(move.from!.rank - move.to!.rank))){
return false;
}
for(let i : number = startRank + 1; i < endRank ; i++) {
for(let j : number = startFile + 1; j < endFile ; j++) {
let movePosition : Position = { rank : i , file : j};
for(let i : number = move.from!.rank + moveRank ; i < move.to!.rank ; i=+ moveRank) {
for(let j : number = move.from!.file + moveFile ; j < move.to!.file ; j=+ moveFile) {
let movePosition : Position = {rank : i , file : j};
let squareMove : Square = squareAtPosition(chessboard, movePosition);
if(!squareMove.isEmpty){
return false;
......
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