genRandInitFen(seed) {
const gr = new GiveawayRules(
- {mode: "suicide", options: {}, genFenOnly: true});
+ {mode: "suicide", options: this.options, genFenOnly: true});
// Add Peach + mario flags
return gr.genRandInitFen(seed).slice(0, -17) + '{"flags":"1111"}';
}
moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY]));
}
}
- this.pawnPostProcess(moves, color, oppCol);
+ super.pawnPostProcess(moves, color, oppCol);
// Add mushroom on before-last square
moves.forEach(m => {
let revStep = [m.start.x - m.end.x, m.start.y - m.end.y];
}
play(move) {
+ const color = this.turn;
+ const oppCol = C.GetOppCol(color);
+ if (
+ move.appear.length > 0 &&
+ move.appear[0].p == 'p' &&
+ (
+ (color == 'w' && move.end.x == 0) ||
+ (color == 'b' && move.end.x == this.size.x - 1)
+ )
+ ) {
+ // "Forgotten" promotion, which occurred after some effect
+ let moves = [move];
+ super.pawnPostProcess(moves, color, oppCol);
+ super.showChoices(moves);
+ return false;
+ }
if (!move.nextComputed) {
// Set potential random effects, so that play() is deterministic
// from opponent viewpoint:
move.nextComputed = true;
}
this.egg = move.egg;
- const color = this.turn;
- const oppCol = C.GetOppCol(color);
if (move.egg == "toadette") {
this.reserve = { w: {}, b: {} };
// Randomly select a piece in pawnPromotions
this.displayBonus(move);
this.playOnBoard(move);
this.nextMove = move.next;
+ return true;
}
// Helper to set and apply banana/bomb effect
}
getMushroomEffect(move) {
- if (move.koopa)
+ if (move.koopa || typeof move.start.x == "string")
return null;
let step = [move.end.x - move.start.x, move.end.y - move.start.y];
if ([0, 1].some(i => Math.abs(step[i]) >= 2 && Math.abs(step[1-i]) != 1)) {
const afterSquare =
[nextSquare[0] + step[0], nextSquare[1] + step[1]];
let nextMove = null;
- this.playOnBoard(move); //HACK for getBasicMove() below
- if (
- this.onBoard(nextSquare[0], nextSquare[1]) &&
- ['k', 'p', 'n'].includes(move.vanish[0].p) &&
- !['w', 'b'].includes(this.getColor(nextSquare[0], nextSquare[1]))
- ) {
- // Speed up non-sliders
+ if (this.onBoard(nextSquare[0], nextSquare[1])) {
+ this.playOnBoard(move); //HACK for getBasicMove()
nextMove = this.getBasicMove([move.end.x, move.end.y], nextSquare);
+ this.undoOnBoard(move);
}
- else if (
- this.onBoard(afterSquare[0], afterSquare[1]) &&
- this.board[nextSquare[0]][nextSquare[1]] != "" &&
- this.getColor(nextSquare[0], nextSquare[1]) != 'a' &&
- this.getColor(afterSquare[0], afterSquare[1]) != this.turn
- ) {
- nextMove = this.getBasicMove([move.end.x, move.end.y], afterSquare);
- }
- this.undoOnBoard(move);
return nextMove;
}
}
playPlusVisual(move, r) {
- this.moveStack.push(move);
const nextLines = () => {
- this.play(move);
+ if (!this.play(move))
+ return;
+ this.moveStack.push(move);
this.playVisual(move, r);
if (this.nextMove)
this.playPlusVisual(this.nextMove, r);
this.moveStack = [];
}
};
- if (this.moveStack.length == 1)
+ if (this.moveStack.length == 0)
nextLines();
else
this.animate(move, nextLines);