Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ui/round/src/premove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,13 @@ const king: cg.Mobility = (ctx: cg.MobilityContext) =>
(ctx.canCastle &&
ctx.orig.pos[1] === ctx.dest.pos[1] &&
ctx.orig.pos[1] === (ctx.color === 'white' ? 0 : 7) &&
((ctx.orig.pos[0] === 4 &&
((ctx.dest.pos[0] === 2 && ctx.rookFilesFriendlies.includes(0)) ||
(ctx.dest.pos[0] === 6 && ctx.rookFilesFriendlies.includes(7)))) ||
ctx.rookFilesFriendlies.includes(ctx.dest.pos[0])) &&
(ctx.rookCastle
? // Rook castling: king moves onto rook
ctx.rookFilesFriendlies.includes(ctx.dest.pos[0])
: // Standard castling: king moves two squares
ctx.orig.pos[0] === 4 &&
((ctx.dest.pos[0] === 2 && ctx.rookFilesFriendlies.includes(0)) ||
(ctx.dest.pos[0] === 6 && ctx.rookFilesFriendlies.includes(7)))) &&
(ctx.unrestrictedPremoves ||
/* The following checks if no non-rook friendly piece is in the way between the king and its castling destination.
Note that for the Chess960 edge case of Kb1 "long castling", the check passes even if there is a piece in the way
Expand Down
Loading