+ doClick(square) {
+ // A click to promote a piece on subTurn 2 would trigger this.
+ // For now it would then return [NaN, NaN] because surrounding squares
+ // have no IDs in the promotion modal. TODO: improve this?
+ if (!square[0]) return null;
+ // If subTurn == 2:
+ // if square is empty && firstMove is compatible,
+ // complete the move (banana or bomb).
+ // if square not empty, just complete with empty move
+ const Lf = this.firstMove.length;
+ if (this.subTurn == 2) {
+ if (
+ this.board[square[0]][square[1]] == V.EMPTY &&
+ !this.underCheck(this.turn) &&
+ (La == 0 || !this.oppositeMoves(this.amoves[La-1], this.firstMove[Lf-1]))
+ ) {
+ return {
+ start: { x: -1, y: -1 },
+ end: { x: -1, y: -1 },
+ appear: [],
+ vanish: []
+ };
+ }
+ }
+ return null;
+ }
+
+ postPlay(move) {
+ // TODO: king may also be "chomped"
+ super.updateCastleFlags(move, piece);
+ }
+