- isAttacked(sq, color, castling) {
- const singleMoveAttack = super.isAttacked(sq, color);
- if (singleMoveAttack) return true;
- if (!!castling) {
- if (this.subTurn == 1)
- // Castling at move 1 could be done into check
- return false;
- return singleMoveAttack;
- }
- // Double-move allowed:
- const curTurn = this.turn;
- this.turn = color;
- const moves1 = super.getAllPotentialMoves();
- this.turn = curTurn;
- for (let move of moves1) {
- this.play(move);
- const res = super.isAttacked(sq, color);
- this.undo(move);
- if (res) return res;
- }