fix chess960 castle where king does not move

local-config
Niklas Fiekas 2020-06-25 21:29:26 +02:00
parent a337363146
commit d2f6378dd1
2 changed files with 6 additions and 5 deletions

View File

@ -361,9 +361,10 @@ export default class RoundController {
// This block needs to be idempotent, even for castling moves in
// Chess960.
const keys = util.uci2move(o.uci)!,
p = this.chessground.state.pieces[keys[0]],
c = this.chessground.state.pieces[keys[1]];
if (p && (!c || p.color !== c.color || p.role === 'king')) this.chessground.move(keys[0], keys[1]);
pieces = this.chessground.state.pieces;
if (!o.castle || (pieces[o.castle.king[0]]?.role === 'king' && pieces[o.castle.rook[0]]?.role === 'rook')) {
this.chessground.move(keys[0], keys[1]);
}
}
if (o.enpassant) {
const p = o.enpassant, pieces: cg.PiecesDiff = {};

View File

@ -132,11 +132,11 @@ export interface ApiMove extends Step {
key: cg.Key;
pieceClass: cg.Role;
};
enpassant: {
enpassant?: {
key: cg.Key;
color: Color;
};
castle: {
castle?: {
king: [cg.Key, cg.Key];
rook: [cg.Key, cg.Key];
color: Color;