- if (this.movesCount <= 1) {
- const color = this.turn;
- const p = V.RESERVE_PIECES[y];
- if (this.reserve[color][p] == 0) return [];
- const iBound =
- p != V.ROOK
- ? (color == 'w' ? [4, 7] : [0, 3])
- : (color == 'w' ? [7, 7] : [0, 0]);
- const jBound = (i) => {
- if (color == 'w' && i == 4) return [4, 7];
- if (color == 'b' && i == 3) return [0, 3];
- return [0, 7];
- };
- let moves = [];
- for (let i = iBound[0]; i <= iBound[1]; i++) {
- const jb = jBound(i);
- for (let j = jb[0]; j <= jb[1]; j++) {
- if (this.board[i][j] == V.EMPTY) {
- let mv = new Move({
- appear: [
- new PiPo({
- x: i,
- y: j,
- c: color,
- p: p
- })
- ],
- vanish: [],
- start: { x: x, y: y },
- end: { x: i, y: j }
- });
- moves.push(mv);
- }
+ if (this.movesCount >= 2) return super.getPotentialMovesFrom([x, y]);
+ // Only reserve moves are allowed for now:
+ if (V.OnBoard(x, y)) return [];
+ const color = this.turn;
+ const p = V.RESERVE_PIECES[y];
+ if (this.reserve[color][p] == 0) return [];
+ const iBound =
+ p != V.ROOK
+ ? (color == 'w' ? [4, 7] : [0, 3])
+ : (color == 'w' ? [7, 7] : [0, 0]);
+ const jBound = (i) => {
+ if (color == 'w' && i == 4) return [4, 7];
+ if (color == 'b' && i == 3) return [0, 3];
+ return [0, 7];
+ };
+ let moves = [];
+ for (let i = iBound[0]; i <= iBound[1]; i++) {
+ const jb = jBound(i);
+ for (let j = jb[0]; j <= jb[1]; j++) {
+ if (this.board[i][j] == V.EMPTY) {
+ let mv = new Move({
+ appear: [
+ new PiPo({
+ x: i,
+ y: j,
+ c: color,
+ p: p
+ })
+ ],
+ vanish: [],
+ start: { x: x, y: y },
+ end: { x: i, y: j }
+ });
+ moves.push(mv);