- const kIdx = move.vanish.findIndex(
- (v,i) => v.p == 'l' || (i >= 1 && v.p == 'k'));
- if (kIdx >= 0)
- // A (stunned or not) king vanish: game over
- this.kingPos[move.vanish[kIdx].c] = [-1, -1];
+ const color = this.turn;
+ const kp = this.kingPos[color];
+ if (
+ this.board[kp[0], kp[1]] == V.EMPTY ||
+ !['k', 'l'].includes(this.getPiece(kp[0], kp[1])) ||
+ this.getColor(kp[0], kp[1]) != color
+ ) {
+ // King didn't move by itself, and vanished => game over
+ this.kingPos[color] = [-1, -1];
+ }