Skip to content
Snippets Groups Projects
Commit e706f75a authored by Elarouti Adam's avatar Elarouti Adam
Browse files

fou

parent 2a052cd0
No related merge requests found
......@@ -173,6 +173,55 @@ function highlightMoves(piece, row, col) {
}
}
}
if (piece.toLowerCase() === "f") {
// Déplacements en haut à gauche
for (let r = row - 1, c = col - 1; r >= 0 && c >= 0; r--, c--) {
if (board[r][c] === "") {
moves.push({ row: r, col: c });
} else {
if (noirs.includes(board[r][c])) {
moves.push({ row: r, col: c });
}
break; // Bloqué par une pièce
}
}
// Déplacements en haut à droite
for (let r = row - 1, c = col + 1; r >= 0 && c < 8; r--, c++) {
if (board[r][c] === "") {
moves.push({ row: r, col: c });
} else {
if (noirs.includes(board[r][c])) {
moves.push({ row: r, col: c });
}
break;
}
}
// Déplacements en bas à gauche
for (let r = row + 1, c = col - 1; r < 8 && c >= 0; r++, c--) {
if (board[r][c] === "") {
moves.push({ row: r, col: c });
} else {
if (noirs.includes(board[r][c])) {
moves.push({ row: r, col: c });
}
break;
}
}
// Déplacements en bas à droite
for (let r = row + 1, c = col + 1; r < 8 && c < 8; r++, c++) {
if (board[r][c] === "") {
moves.push({ row: r, col: c });
} else {
if (noirs.includes(board[r][c])) {
moves.push({ row: r, col: c });
}
break;
}
}
}
return moves;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment