Skip to content
Snippets Groups Projects
Commit d5afde54 authored by De Brettes Thomas's avatar De Brettes Thomas
Browse files

tour

parent 9e9e3962
Branches
No related tags found
No related merge requests found
......@@ -122,6 +122,57 @@ function highlightMoves(piece, row, col) {
if (noirs.includes(board[row + direction][col - direction])){
moves.push({row: row +direction, col: col - direction })
}
if (piece.toLowerCase() === "t") {
// Déplacements vers le haut
for (let r = row - 1; r >= 0; r--) {
if (board[r][col] === "") {
moves.push({ row: r, col });
}
else {
if (noirs.includes(board[r][col])) {
moves.push({ row: r, col }); // Capture possible
}
break // Bloqué par une pièce
}
}
// Déplacements vers le bas
for (let r = row + 1; r < 8; r++) {
if (board[r][col] === "") {
moves.push({ row: r, col });
} else {
if (noirs.includes(board[r][col])) {
moves.push({ row: r, col });
}
break;
}
}
// Déplacements vers la gauche
for (let c = col - 1; c >= 0; c--) {
if (board[row][c] === "") {
moves.push({ row, col: c });
} else {
if (noirs.includes(board[r][col])) {
moves.push({ row, col: c });
}
break;
}
}
// Déplacements vers la droite
for (let c = col + 1; c < 8; c++) {
if (board[row][c] === "") {
moves.push({ row, col: c });
} else {
if (noirs.includes(board[r][col])) {
moves.push({ row, 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