- if (
- [1, 6].includes(move.start.x) &&
- move.vanish.length >= 1 &&
- move.appear.length == 1
- ) {
- // Does this move turn off a 2-squares pawn flag?
- if (
- move.vanish[0].p == V.PAWN ||
- (
- !(ChessRules.PIECES.includes(move.vanish[0].p)) &&
- this.getUnionPieces(move.vanish[0].c, move.vanish[0].p)[c] == V.PAWN
- )
- ) {
- this.pawnFlags[move.start.x == 6 ? "w" : "b"][move.start.y] = false;
- }
+ const pawnFirstRank = (c == 'w' ? 6 : 1);
+ if (move.start.x == pawnFirstRank)
+ // This move (potentially) turns off a 2-squares pawn flag
+ this.pawnFlags[c][move.start.y] = false;
+ }
+
+ play(move) {
+ move.flags = JSON.stringify(this.aggregateFlags());
+ this.prePlay(move);
+ this.epSquares.push(this.getEpSquare(move));
+ // Check if the move is the last of the turn: all cases except releases
+ if (!move.end.released) {
+ // No more union releases available
+ this.turn = V.GetOppCol(this.turn);
+ this.movesCount++;
+ this.lastMoveEnd.push(null);