- isAttacked(sq, color, castling) {
- const singleMoveAttack = super.isAttacked(sq, color);
- if (singleMoveAttack) return true;
- if (color == 'b' || !!castling) return singleMoveAttack;
- // Attacks by white: double-move allowed
- const curTurn = this.turn;
- this.turn = 'w';
- const w1Moves = super.getAllPotentialMoves();
- this.turn = curTurn;
- for (let move of w1Moves) {
- this.play(move);
- const res = super.isAttacked(sq, 'w');
- this.undo(move);
- if (res) return res;
- }