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

noirs blancs

parent 3120ffc5
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,11 @@ const pieceImages = {
"K": "roi_noir.png"
};
const noirs = ["P","T","C","F","Q","K"];
const blancs = ["p","t","c","f","q","k"];
// Dessiner l'échiquier avec les couleurs des cases
function drawBoard() {
for (let row = 0; row < 8; row++) {
......@@ -107,12 +112,17 @@ function highlightMoves(piece, row, col) {
moves.push({row: row - 2,col});
}
}
let direction = -1; // Pion blanc monte, pion noir descend
let direction = -1; // Pion blanc monte
if (board[row + direction] && board[row + direction][col] === "") {
moves.push({ row: row + direction, col });
}
// Prises diagonales
let possibleCaptures = [col - 1, col + 1];
for (let newCol of possibleCaptures) {
if (newCol >= 0 && newCol < 8 && board[row + direction] && noirs.has(board[row + direction][newCol])) {
moves.push({ row: row + direction, col: newCol });
}
}
return moves;
......@@ -160,3 +170,4 @@ function movePiece(newRow, newCol) {
selectedPiece=null;
}
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ var fs = require('fs'),
path = require('path');
var server = http.createServer(function (request, response) {
var filePath = path.join(__dirname, 'htdocs', request.url === '/' ? 'page_acceuil.html' : request.url);
var filePath = path.join(__dirname, 'htdocs', request.url === '/' ? 'page_jeu.html' : request.url);
fs.readFile(filePath, function (err, data) {
if (err) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment