+ let moves = super.getPotentialQueenMoves(sq);
+ this.addRookCaptures(moves);
+ return moves;
+ }
+
+ // Long-leaper
+ getKnightCaptures(startSquare, byChameleon)
+ {
+ // Look in every direction for captures
+ const steps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
+ const color = this.turn;
+ const oppCol = this.getOppCol(color);
+ let moves = [];
+ const [x,y] = [startSquare[0],startSquare[1]];
+ const piece = this.getPiece(x,y); //might be a chameleon!
+ outerLoop:
+ for (let step of steps)
+ {
+ let [i,j] = [x+step[0], y+step[1]];
+ while (V.OnBoard(i,j) && this.board[i][j]==V.EMPTY)
+ {
+ i += step[0];
+ j += step[1];
+ }
+ if (!V.OnBoard(i,j) || this.getColor(i,j)==color
+ || (!!byChameleon && this.getPiece(i,j)!=V.KNIGHT))
+ {
+ continue;
+ }
+ // last(thing), cur(thing) : stop if "cur" is our color, or beyond board limits,
+ // or if "last" isn't empty and cur neither. Otherwise, if cur is empty then
+ // add move until cur square; if cur is occupied then stop if !!byChameleon and
+ // the square not occupied by a leaper.
+ let last = [i,j];
+ let cur = [i+step[0],j+step[1]];
+ let vanished = [ new PiPo({x:x,y:y,c:color,p:piece}) ];
+ while (V.OnBoard(cur[0],cur[1]))
+ {
+ if (this.board[last[0]][last[1]] != V.EMPTY)
+ {
+ const oppPiece = this.getPiece(last[0],last[1]);
+ if (!!byChameleon && oppPiece != V.KNIGHT)
+ continue outerLoop;
+ // Something to eat:
+ vanished.push( new PiPo({x:last[0],y:last[1],c:oppCol,p:oppPiece}) );
+ }
+ if (this.board[cur[0]][cur[1]] != V.EMPTY)
+ {
+ if (this.getColor(cur[0],cur[1]) == color
+ || this.board[last[0]][last[1]] != V.EMPTY) //TODO: redundant test
+ {
+ continue outerLoop;
+ }
+ }
+ else
+ {
+ moves.push(new Move({
+ appear: [ new PiPo({x:cur[0],y:cur[1],c:color,p:piece}) ],
+ vanish: JSON.parse(JSON.stringify(vanished)), //TODO: required?
+ start: {x:x,y:y},
+ end: {x:cur[0],y:cur[1]}
+ }));
+ }
+ last = [last[0]+step[0],last[1]+step[1]];
+ cur = [cur[0]+step[0],cur[1]+step[1]];
+ }
+ }
+ return moves;