Make canEnPassent mutual and make it null if it wasn't a double step move
This commit is contained in:
parent
2aa2ef0233
commit
25c3f66480
|
@ -32,7 +32,7 @@ export const hasMoved = {
|
|||
rightRook: false,
|
||||
},
|
||||
}
|
||||
export const canEnPassent = false;
|
||||
export let canEnPassent = false;
|
||||
export const currentKingPosition = {
|
||||
white: [7, 4],
|
||||
black: [0, 4],
|
||||
|
@ -506,5 +506,6 @@ export const movePiece = (move, player) => {
|
|||
if (move.main[0] == (player ? [7, 0] : [0, 0])) pieces.leftRook = true;
|
||||
if (move.main[0] == (player ? [7, 7] : [0, 7])) pieces.rightRook = true;
|
||||
if ([WP, BP].includes(board[fromA][fromB]) && Math.abs(fromA - toA) == 2) canEnPassent = toB;
|
||||
else canEnPassent = null;
|
||||
board = moved(move, board);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue