+ getPotentialQueenMoves(sq) {
+ const normalMoves = super.getPotentialQueenMoves(sq);
+ // If flag allows it, add 'invisible movements'
+ let invisibleMoves = [];
+ if (this.powerFlags[this.turn][V.QUEEN]) {
+ normalMoves.forEach(m => {
+ if (m.vanish.length == 1) {
+ let im = JSON.parse(JSON.stringify(m));
+ m.appear[0].p = V.INVISIBLE_QUEEN;
+ invisibleMoves.push(im);
+ }
+ });
+ }
+ return normalMoves.concat(invisibleMoves);
+ }
+
+ getPotentialKingMoves([x, y]) {
+ let moves = super.getPotentialKingMoves([x, y]);
+ const color = this.turn;
+ // If flag allows it, add 'remote shell captures'
+ if (this.powerFlags[this.turn][V.KING]) {
+ V.steps[V.ROOK].concat(V.steps[V.BISHOP]).forEach(step => {
+ let [i, j] = [x + 2 * step[0], y + 2 * step[1]];
+ while (
+ V.OnBoard(i, j) &&
+ (
+ this.board[i][j] == V.EMPTY ||
+ (
+ this.getColor(i, j) == 'a' &&
+ [V.EGG, V.MUSHROOM].includes(this.getPiece(i, j))
+ )
+ )
+ ) {
+ i += step[0];
+ j += step[1];
+ }
+ if (V.OnBoard(i, j) && this.getColor(i, j) != color)
+ // May just destroy a bomb or banana:
+ moves.push(this.getBasicMove([x, y], [i, j]));
+ });
+ }
+ return moves;
+ }
+
+ getSlideNJumpMoves([x, y], steps, oneStep) {
+ let moves = [];
+ outerLoop: for (let step of steps) {
+ let i = x + step[0];
+ let j = y + step[1];
+ while (
+ V.OnBoard(i, j) &&
+ (
+ this.board[i][j] == V.EMPTY ||
+ (
+ this.getColor(i, j) == 'a' &&
+ [V.EGG, V.MUSHROOM].includes(this.getPiece(i, j))
+ )
+ )
+ ) {
+ moves.push(this.getBasicMove([x, y], [i, j]));
+ if (oneStep) continue outerLoop;
+ i += step[0];
+ j += step[1];
+ }
+ if (V.OnBoard(i, j) && this.canTake([x, y], [i, j]))
+ moves.push(this.getBasicMove([x, y], [i, j]));
+ }
+ return moves;