+ };
+ move.flags = JSON.stringify(this.aggregateFlags());
+ V.PlayOnBoard(this.board, move);
+ if (this.subTurn == 2) gotoNext(move);
+ else {
+ this.subTurn = 2;
+ this.firstMove.push(move);
+ this.toNewKingPos(move);
+ if (
+ // Condition is true on empty arrays:
+ this.getAllPotentialMoves().every(m => {
+ V.PlayOnBoard(this.board, m);
+ this.toNewKingPos(m);
+ const res = this.underCheck(color);
+ V.UndoOnBoard(this.board, m);
+ this.toOldKingPos(m);
+ return res;
+ })
+ ) {
+ // No valid move at subTurn 2
+ gotoNext(this.getEmptyMove());
+ }
+ this.toOldKingPos(move);