+ // TODO: add captures of coordinators,pinchers,withdrawers... by re-using code
+ }
+
+ getPotentialQueenMoves([x,y])
+ {
+ let moves = super.getPotentialQueenMoves(sq);
+ const V = VariantRules;
+ const adjacentSteps = V.steps[V.ROOK].concat(V.steps[V.BISHOP]);
+ let capturingDirections = [];
+ const color = this.getColor(x,y);
+ const oppCol = this.getOppCol(color);
+ adjacentSteps.forEach(step => {
+ const [i,j] = [x+step[0],y+step[1]];
+ if (this.board[i][j] != V.EMPTY && this.getColor(i,j) == oppCol)
+ capturingDirections.push(step);
+ });
+ moves.forEach(m => {
+ const step = [
+ m.end.x!=x ? (m.end.x-x)/Math.abs(m.end.x-x) : 0,
+ m.end.y!=y ? (m.end.y-y)/Math.abs(m.end.y-y) : 0
+ ];
+ // NOTE: includes() function does not work on complex array elements
+ // TODO: this test should be done only once per direction
+ if (capturingDirection.some(dir => _.isEqual(dir, step)))
+ {
+ const [i,j] = [x-step[0],y-step[1]];
+ m.vanish.push(new PiPo({
+ x:i,
+ y:j,
+ p:this.getPiece(i,j),
+ c:oppCol
+ }));
+ }
+ });