+ // Pre-check: is thing on this square immobilized?
+ // In this case add potential suicide as a move "taking the immobilizer"
+ const piece = this.getPiece(x,y);
+ const color = this.getColor(x,y);
+ const oppCol = this.getOppCol(color);
+ const V = VariantRules;
+ const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
+ const [sizeX,sizeY] = V.size;
+ for (let step of adjacentSteps)
+ {
+ const [i,j] = [x+step[0],y+step[1]];
+ if (i>=0 && i<sizeX && j>=0 && j<sizeY && this.board[i][j] != V.EMPTY
+ && this.getColor(i,j) == oppCol)
+ {
+ const oppPiece = this.getPiece(i,j);
+ if (oppPiece == V.IMMOBILIZER
+ || (oppPiece == V.BISHOP && piece == V.IMMOBILIZER))
+ {
+ return [ new Move({
+ appear: [],
+ vanish: [{x:x,y:y,p:piece,c:color}],
+ start: {x:x,y:y},
+ end: {x:i,y:j}
+ }) ];
+ }
+ }
+ }