+ // Final check: is this knight immobilized?
+ let foundImmobilizer = false;
+ let neutralized = false;
+ outerLoop:
+ for (let step of steps)
+ {
+ const [i2,j2] = [i+step[0],j+step[1]];
+ if (i2>=0 && i2<sizeX && j2>=0 && j2<sizeY
+ && this.board[i2][j2] != V.EMPTY
+ && this.getColor(i2,j2) == oppCol
+ && this.getPiece(i2,j2) == V.IMMOBILIZER)
+ {
+ foundImmobilizer = true;
+ // Moving is possible only if this immobilizer is neutralized
+ for (let step2 of steps)
+ {
+ const [i3,j3] = [i2+step2[0],j2+step2[1]];
+ if (i3>=0 && i3<sizeX && j3>=0 && j3<sizeY
+ && this.board[i3][j3] != V.EMPTY && this.getColor(i3,j3) == color
+ && [V.BISHOP,V.IMMOBILIZER].includes(this.getPiece(i3,j3)))
+ {
+ neutralized = true;
+ break outerLoop;
+ }
+ }
+ }
+ }
+ if (!foundImmobilizer || neutralized)
+ return false;
+