play(move) {
move.flags = JSON.stringify(this.aggregateFlags());
- move.turn = this.turn + this.subTurn;
+ move.turn = [this.turn, this.subTurn];
V.PlayOnBoard(this.board, move);
const epSq = this.getEpSquare(move);
if (this.movesCount == 0) {
this.epSquares.push([epSq]);
move.checkOnSubturn1 = true;
this.movesCount++;
- } else {
+ }
+ else {
if (this.subTurn == 2) {
this.turn = V.GetOppCol(this.turn);
let lastEpsq = this.epSquares[this.epSquares.length - 1];
lastEpsq.push(epSq);
- } else {
+ }
+ else {
this.epSquares.push([epSq]);
this.movesCount++;
}
}
postPlay(move) {
- const c = move.turn.charAt(0);
+ const c = move.turn[0];
const piece = move.vanish[0].p;
const firstRank = c == "w" ? V.size.x - 1 : 0;
) {
const flagIdx = (move.start.y == this.castleFlags[c][0] ? 0 : 1);
this.castleFlags[c][flagIdx] = V.size.y;
- } else if (
+ }
+ else if (
move.end.x == oppFirstRank && //we took opponent rook?
this.castleFlags[oppCol].includes(move.end.y)
) {
this.epSquares.pop();
// Moves counter was just incremented:
this.movesCount--;
- } else {
+ }
+ else {
// Undo the second half of a move
let lastEpsq = this.epSquares[this.epSquares.length - 1];
lastEpsq.pop();
}
this.turn = move.turn[0];
- this.subTurn = parseInt(move.turn[1]);
+ this.subTurn = move.turn[1];
super.postUndo(move);
}