Skip to content

Commit

Permalink
Khans premoves
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Mar 26, 2024
1 parent c942dab commit 063f442
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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.5.4",
"version": "10.5.5",
"description": "Extended lichess.org Chess UI",
"type": "module",
"module": "chessground.js",
Expand Down
12 changes: 12 additions & 0 deletions src/premove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ const flyingDiagonalCannon: Mobility = (x1, y1, x2, y2) => {
return bishop(x1, y1, x2, y2) || wazirDabbaba(x1, y1, x2, y2);
};

function scout(color: cg.Color): Mobility {
return (x1, y1, x2, y2) =>
(x2 === x1 && (color === 'white' ? y2 === y1 + 1 : y2 === y1 - 1)) ||
((x2 === x1 - 1 || x2 === x1 + 1) && (color === 'white' ? y2 === y1 + 2 : y2 === y1 - 2)) ||
((x2 === x1 - 2 || x2 === x1 + 2) && (color === 'white' ? y2 === y1 + 1 : y2 === y1 - 1))
};

Check failure on line 299 in src/premove.ts

View workflow job for this annotation

GitHub Actions / build

Unnecessary semicolon

// Define xiangqi palace based on geometry
// The palace is the 3x3 squares in the middle files at each side's end of the board
type Palace = cg.Pos[];
Expand Down Expand Up @@ -954,6 +961,7 @@ function builtinMobility(
};

case 'orda':
case 'khans':
case 'ordamirror':
return (boardState, key, canCastle) => {
const piece = boardState.pieces.get(key)!;
Expand All @@ -973,13 +981,16 @@ function builtinMobility(
case 'l-piece': // lancer
return chancellor;
case 'h-piece': // kheshig
case 't-piece': // khatun
return centaur;
case 'a-piece': // archer
return archbishop;
case 'y-piece': // yurt
return shogiSilver(color);
case 'f-piece': // falcon
return amazon;
case 's-piece': // scout
return scout(color);
case 'k-piece': // king
return king(color, rookFilesOf(boardState.pieces, color), canCastle);
default:
Expand Down Expand Up @@ -1341,6 +1352,7 @@ function builtinMobility(
return chancellor;
case 'h-piece': // S-chess hawk
case 'a-piece': // archbishop
case 'd-piece': // Dragon chess dragon
return archbishop;
case 'k-piece': // king
return chess960
Expand Down

0 comments on commit 063f442

Please sign in to comment.