- if (!!c) {
- if (x != c.end.x || y != c.end.y) return [];
- step = [(c.end.x - c.start.x) / 2, (c.end.y - c.start.y) / 2];
- // Add move to adjacent empty square to mark "end of capture"
- moves.push(
- new Move({
- appear: [],
- vanish: [],
- start: { x: x, y: y },
- end: { x: x - step[0], y: y - step[1] }
- })
- );
- }
- // Examine captures from here
- for (let s of (!!step ? [step] : V.steps[V.ROOK])) {
- let [i, j] = [x + 2*s[0], y + 2*s[1]];
- if (
- !!c || //avoid redundant checks if continuation
- (
- V.OnBoard(i, j) &&
- this.board[i][j] == V.EMPTY &&
- this.board[i - s[0]][j - s[1]] != V.EMPTY &&
- this.getColor(i - s[0], j - s[1]) == oppCol
- )
- ) {
- let mv = new Move({
- appear: [
- new PiPo({ x: i, y: j, c: color, p: V.PAWN })
- ],
- vanish: [
- new PiPo({ x: x, y: y, c: color, p: V.PAWN }),
- new PiPo({ x: i - s[0], y: j - s[1], c: oppCol, p: V.PAWN })
- ]
- });
- // Is there another capture possible then?
- [i, j] = [i + 2*s[0], j + 2*s[1]];
+ for (let s of V.steps[V.ROOK]) {
+ let curmv = new Move({
+ appear: [ new PiPo({ x: -1, y: -1, c: color, p: V.PAWN }) ],
+ vanish: [ new PiPo({ x: x, y: y, c: color, p: V.PAWN }) ]
+ });
+ for (let mult = 2; ; mult += 2) {
+ let [i, j] = [x + mult * s[0], y + mult * s[1]];