+ const specialAttack = !!this.getStepSpec(color, x, y).attack;
+ let squares = [];
+ if (specialAttack) {
+ squares = this.findDestSquares(
+ [x, y],
+ {
+ attackOnly: true,
+ segments: this.options["cylinder"]
+ },
+ ([i, j]) => {
+ return (
+ (!this.options["zen"] || this.getPieceType(i, j) == 'k') &&
+ this.canTake([x, y], [i, j])
+ );
+ }
+ );
+ }
+ const noSpecials = this.findDestSquares(
+ [x, y],
+ {
+ moveOnly: specialAttack || this.options["zen"],
+ segments: this.options["cylinder"]
+ },
+ ([i, j]) => this.board[i][j] == "" || this.canTake([x, y], [i, j])
+ );
+ Array.prototype.push.apply(squares, noSpecials);
+ if (this.options["zen"]) {
+ let zenCaptures = this.findCapturesOn(
+ [x, y],
+ {},
+ ([i, j]) => this.getPieceType(i, j) != 'k'
+ );
+ // Technical step: segments (if any) are reversed
+ if (this.options["cylinder"]) {
+ zenCaptures.forEach(z => {
+ if (z.segments)
+ z.segments = z.segments.reverse().map(s => s.reverse())
+ });
+ }
+ Array.prototype.push.apply(squares, zenCaptures);
+ }
+ if (
+ this.options["recycle"] ||
+ (this.options["teleport"] && this.subTurnTeleport == 1)
+ ) {
+ const selfCaptures = this.findDestSquares(
+ [x, y],
+ {
+ attackOnly: true,
+ segments: this.options["cylinder"]
+ },
+ ([i, j]) =>
+ this.getColor(i, j) == color && this.getPieceType(i, j) != 'k'
+ );
+ Array.prototype.push.apply(squares, selfCaptures);
+ }
+ return squares.map(s => {
+ let mv = this.getBasicMove([x, y], s.sq);
+ if (this.options["cylinder"] && s.segments.length >= 2)
+ mv.segments = s.segments;
+ return mv;
+ });
+ }