+ isAttackedByN_bishop(sq, color) {
+ const backward = (color == 'w' ? -1 : 1);
+ const kingSteps = [
+ [0, -1], [0, 1], [backward, -1], [backward, 0], [backward, 1]
+ ];
+ const forward = -backward;
+ const knightSteps = [
+ [2*forward, -1], [2*forward, 1], [forward, -2], [forward, 2]
+ ];
+ return (
+ this.isAttackedBySlideNJump(sq, color, V.N_BISHOP, knightSteps, 1) ||
+ this.isAttackedBySlideNJump(sq, color, V.N_BISHOP, kingSteps, 1)
+ );
+ }
+
+ isAttackedByN_queen(sq, color) {
+ const backward = (color == 'w' ? -1 : 1);
+ const forward = -backward;
+ const kingSteps = [
+ [forward, -1], [forward, 1],
+ [backward, -1], [backward, 0], [backward, 1]
+ ];
+ const knightSteps = [
+ [2*forward, -1], [2*forward, 1], [forward, -2], [forward, 2]
+ ];
+ const rookSteps = [ [0, -1], [0, 1], [forward, 0] ];
+ return (
+ this.isAttackedBySlideNJump(sq, color, V.N_QUEEN, knightSteps, 1) ||
+ this.isAttackedBySlideNJump(sq, color, V.N_QUEEN, kingSteps, 1) ||
+ this.isAttackedBySlideNJump(sq, color, V.N_QUEEN, rookSteps)
+ );
+ }
+
+ isAttackedByR_rook(sq, color) {
+ return this.isAttackedBySlideNJump(sq, color, V.R_ROOK, V.steps.r, 4);
+ }
+
+ isAttackedByR_knight(sq, color) {
+ return (
+ this.isAttackedBySlideNJump(sq, color, V.R_KNIGHT, V.steps.d, 1) ||
+ this.isAttackedBySlideNJump(sq, color, V.R_KNIGHT, V.steps.w, 1)
+ );
+ }
+
+ isAttackedByR_bishop(sq, color) {
+ return (
+ this.isAttackedBySlideNJump(sq, color, V.R_BISHOP, V.steps.d, 1) ||
+ this.isAttackedBySlideNJump(sq, color, V.R_BISHOP, V.steps.f, 1) ||
+ this.isAttackedBySlideNJump(sq, color, V.R_BISHOP, V.steps.$3, 1)
+ );
+ }
+
+ isAttackedByR_queen(sq, color) {
+ return (
+ this.isAttackedBySlideNJump(sq, color, V.R_QUEEN, V.steps.r) ||
+ this.isAttackedBySlideNJump(sq, color, V.R_QUEEN, V.steps.n, 1)
+ );
+ }
+
+ // [HACK] So that the function above works also on Fide army:
+ isAttackedByF_rook(sq, color) {
+ return super.isAttackedByRook(sq, color);
+ }
+ isAttackedByF_knight(sq, color) {
+ return super.isAttackedByKnight(sq, color);
+ }
+ isAttackedByF_bishop(sq, color) {
+ return super.isAttackedByBishop(sq, color);
+ }
+ isAttackedByF_queen(sq, color) {
+ return super.isAttackedByQueen(sq, color);
+ }
+