Skip to content

Commit

Permalink
Shatranj premoves
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Oct 31, 2024
1 parent 2a3182b commit d28d44a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chessgroundx",
"version": "10.6.2",
"version": "10.6.3",
"description": "Extended lichess.org Chess UI",
"type": "module",
"module": "chessground.js",
Expand Down
25 changes: 24 additions & 1 deletion src/premove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function ferzOuk(color: cg.Color): Mobility {
(color === 'white' ? x1 === 4 && y1 === 0 && x2 === 4 && y2 === 2 : x1 === 3 && y1 === 7 && x2 === 3 && y2 === 5);
}

// shatranj elephant
// alfil (shatranj elephant)
const elephant: Mobility = (x1, y1, x2, y2) => {
const xd = diff(x1, x2);
const yd = diff(y1, y2);
Expand Down Expand Up @@ -873,6 +873,29 @@ function builtinMobility(
}
};

case 'shatranj':
return (boardState, key, canCastle) => {

Check failure on line 877 in src/premove.ts

View workflow job for this annotation

GitHub Actions / build

'canCastle' is declared but its value is never read.
const piece = boardState.pieces.get(key)!;
const role = piece.role;
const color = piece.color;
switch (role) {
case 'p-piece': // pawn
return pawnNoDoubleStep(color);
case 'r-piece': // rook
return rook;
case 'n-piece': // knight
return knight;
case 'b-piece': // bishop
return elephant;
case 'q-piece': // queen
return ferz;
case 'k-piece': // king
return kingNoCastling;
default:
return noMove;
}
};

case 'grand':
case 'grandhouse':
return (boardState, key) => {
Expand Down

0 comments on commit d28d44a

Please sign in to comment.