- const kIdx = move.vanish.findIndex(v => v.p == "l");
- if (kIdx >= 0)
- // A stunned 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];
+ }