- // After move is undo-ed *and flags resetted*, un-update other variables
- // TODO: more symmetry, by storing flags increment in move (?!)
- unupdateVariables(move) {
- // (Potentially) Reset king position
- const c = this.getColor(move.start.x, move.start.y);
- if (this.getPiece(move.start.x, move.start.y) == V.KING)
- this.kingPos[c] = [move.start.x, move.start.y];
- }
-
- play(move) {
- // DEBUG:
-// if (!this.states) this.states = [];
-// const stateFen = this.getBaseFen() + this.getTurnFen() + this.getFlagsFen();
-// this.states.push(stateFen);
-
- if (V.HasFlags) move.flags = JSON.stringify(this.aggregateFlags()); //save flags (for undo)
- if (V.HasEnpassant) this.epSquares.push(this.getEpSquare(move));
- V.PlayOnBoard(this.board, move);
- this.turn = V.GetOppCol(this.turn);
- this.movesCount++;
- this.updateVariables(move);
- }