+ canIplay(side, [x, y]) {
+ if (this.movesCount >= 4) return super.canIplay(side, [x, y]);
+ return (
+ this.turn == side &&
+ (
+ (side == 'w' && x == 7) ||
+ (side == 'b' && x == 0)
+ )
+ );
+ }
+
+ hoverHighlight([x, y]) {
+ const c = this.turn;
+ return (
+ this.movesCount <= 3 &&
+ ((c == 'w' && x == 7) || (c == 'b' && x == 0))
+ );
+ }
+
+ onlyClick([x, y]) {
+ return (
+ this.movesCount <= 3 ||
+ // TODO: next line theoretically shouldn't be required...
+ (this.movesCount == 4 && this.getColor(x, y) != this.turn)
+ );
+ }
+
+ // Special case of move 1 = choose squares, knight first, then bishop
+ doClick(square) {
+ if (this.movesCount >= 4) return null;
+ const color = this.turn;
+ const [x, y] = [square[0], square[1]];
+ if ((color == 'w' && x != 7) || (color == 'b' && x != 0)) return null;
+ const selectedPiece = this.board[x][y][1];
+ return new Move({
+ appear: [
+ new PiPo({
+ x: x,
+ y: y,
+ c: color,
+ p: this.getAugmented(selectedPiece)
+ })
+ ],
+ vanish: [
+ new PiPo({
+ x: x,
+ y: y,
+ c: color,
+ p: selectedPiece
+ })
+ ],
+ start: { x: x, y: y },
+ end: { x: x, y: y }
+ });
+ }
+