Skip to content

Commit

Permalink
Ataxx premoves
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Dec 24, 2023
1 parent 2b88e57 commit 74fad0c
Show file tree
Hide file tree
Showing 2 changed files with 17 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.1",
"version": "10.5.2",
"description": "Extended lichess.org Chess UI",
"type": "module",
"module": "chessground.js",
Expand Down
16 changes: 16 additions & 0 deletions src/premove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ function pawnBerolina(color: cg.Color): Mobility {
};
}

const pawnAtaxx: Mobility = (x1, y1, x2, y2) => {
return diff(x1, x2) <= 2 && diff(y1, y2) <= 2;
}

const sideways: Mobility = (x1, y1, x2, y2) => {
return y1 === y2 && diff(x1, x2) <= 1;
}
Expand Down Expand Up @@ -609,6 +613,18 @@ function builtinMobility(
bd: cg.BoardDimensions
): (boardState: cg.BoardState, key: cg.Key, canCastle: boolean) => Mobility {
switch (variant) {
case 'ataxx':
return (boardState, key) => {
const piece = boardState.pieces.get(key)!;
const role = piece.role;
switch (role) {
case 'p-piece': // pawn
return pawnAtaxx;
default:
return noMove;
}
};

case 'xiangqi':
case 'manchu':
return (boardState, key) => {
Expand Down

0 comments on commit 74fad0c

Please sign in to comment.