]
}
},
- specials, bowsered, super.pieces(color, x, y));
+ specials, bowsered, super.pieces(color, x, y)
+ );
}
genRandInitFen(seed) {
this.reserve = {}; //to be filled later
}
+ canStepOver(i, j) {
+ return (
+ this.board[i][j] == "" ||
+ ['i', V.EGG, V.MUSHROOM].includes(this.getPiece(i, j))
+ );
+ }
+
// For Toadette bonus
- getDropMovesFrom([c, p]) {
- if (typeof c != "string" || this.reserve[c][p] == 0)
- return [];
- let moves = [];
- const start = (c == 'w' && p == 'p' ? 1 : 0);
- const end = (c == 'b' && p == 'p' ? 7 : 8);
- for (let i = start; i < end; i++) {
- for (let j = 0; j < this.size.y; j++) {
- const pieceIJ = this.getPiece(i, j);
- const colIJ = this.getColor(i, j);
- if (this.board[i][j] == "" || colIJ == 'a' || pieceIJ == 'i') {
- let m = new Move({
- start: {x: c, y: p},
- appear: [new PiPo({x: i, y: j, c: c, p: p})],
- vanish: []
- });
- // A drop move may remove a bonus (or hidden queen!)
- if (this.board[i][j] != "")
- m.vanish.push(new PiPo({x: i, y: j, c: colIJ, p: pieceIJ}));
- moves.push(m);
- }
- }
- }
- return moves;
+ canDrop([c, p], [i, j]) {
+ return (
+ (
+ this.board[i][j] == "" ||
+ this.getColor(i, j) == 'a' ||
+ this.getPiece(i, j) == 'i'
+ )
+ &&
+ (p != "p" || (c == 'w' && i < this.size.x - 1) || (c == 'b' && i > 0))
+ );
}
getPotentialMovesFrom([x, y]) {
case 'b':
case 'r':
// Explicitely listing types to avoid moving immobilized piece
- moves = this.getPotentialMovesOf(piece, [x, y]);
+ moves = super.getPotentialMovesOf(piece, [x, y]);
break;
}
}
return moves;
}
- canStepOver(i, j) {
- return (
- this.board[i][j] == "" ||
- ['i', V.EGG, V.MUSHROOM].includes(this.getPiece(i, j))
- );
- }
-
getPawnMovesFrom([x, y]) {
const color = this.turn;
const oppCol = C.GetOppCol(color);
getKnightMovesFrom([x, y]) {
// Add egg on initial square:
- return this.getPotentialMovesOf('n', [x, y]).map(m => {
+ return super.getPotentialMovesOf('n', [x, y]).map(m => {
m.appear.push(new PiPo({p: "e", c: "a", x: x, y: y}));
return m;
});
}
getQueenMovesFrom(sq) {
- const normalMoves = this.getPotentialMovesOf('q', sq);
+ const normalMoves = super.getPotentialMovesOf('q', sq);
// If flag allows it, add 'invisible movements'
let invisibleMoves = [];
if (this.powerFlags[this.turn]['q']) {
}
getKingMovesFrom([x, y]) {
- let moves = this.getPotentialMovesOf('k', [x, y]);
+ let moves = super.getPotentialMovesOf('k', [x, y]);
// If flag allows it, add 'remote shell captures'
if (this.powerFlags[this.turn]['k']) {
- let shellCaptures = this.getPotentialMovesOf('y', [x, y]);
+ let shellCaptures = super.getPotentialMovesOf('y', [x, y]);
shellCaptures.forEach(sc => {
sc.shell = true; //easier play()
sc.choice = 'z'; //to display in showChoices()
this.getColor(i, j) == oppCol
) {
const pieceIJ = this.getPiece(i, j);
- if (pieceIJ == 'i') {
+ if (
+ pieceIJ == 'i' &&
+ // Ensure that current move doesn't erase invisible queen
+ move.appear.every(a => a.x != i || a.y != j)
+ ) {
move.vanish.push(new PiPo({x: i, y: j, c: oppCol, p: 'i'}));
move.appear.push(new PiPo({x: i, y: j, c: oppCol, p: 'q'}));
}