// DARK METHODS
updateEnlightened() {
+ console.log("new light");
this.oldEnlightened = this.enlightened;
this.enlightened = ArrayFun.init(this.size.x, this.size.y, false);
// Add pieces positions + all squares reachable by moves (includes Zen):
{
this.enlightened[x][y] = true;
this.getPotentialMovesFrom([x, y]).forEach(m => {
+
+console.log(m.end);
+
this.enlightened[m.end.x][m.end.y] = true;
});
}
});
}
- prePlay(move) {
- if (this.hasCastle)
- this.updateCastleFlags(move);
+ tryPrePlayCrazyhouse(move) {
if (this.options["crazyhouse"]) {
if (move.appear.length > 0 && move.vanish.length > 0) {
// Assumption: something is moving
delete this.ispawn[square];
});
}
+ }
+
+ tryPrePlayAtomicReserve(move) {
const minSize = Math.min(move.appear.length, move.vanish.length);
if (
this.hasReserve &&
}
}
+ prePlay(move) {
+ if (this.hasCastle)
+ this.updateCastleFlags(move);
+ this.tryPrePlayCrazyhouse(move);
+ this.tryPrePlayAtomicReserve(move);
+ }
+
play(move) {
this.prePlay(move);
if (this.hasEnpassant)
this.postPlay(move);
}
- postPlay(move) {
- if (this.options["dark"])
- this.updateEnlightened();
+ tryPostPlayTeleport(move) {
if (this.options["teleport"]) {
if (
this.subTurnTeleport == 1 &&
this.subTurnTeleport = 1;
this.captured = null;
}
+ }
+
+ postPlay(move) {
+ this.tryPostPlayTeleport(move);
this.tryChangeTurn(move);
}
this.turn = C.GetOppTurn(this.turn);
this.movesCount++;
this.subTurn = 1;
+ if (this.options["dark"])
+ this.updateEnlightened();
}
else if (!move.next)
this.subTurn++;
input: C.Options.input,
styles: [
"atomic", "cannibal", "capture", "cylinder",
- "dark", "madrasi", "rifle", "teleport"
+ "dark", "madrasi", "rifle", "teleport", "zen"
]
};
}
);
if (typeof move.start.x == "number" && !captureUndef)
// Normal move (including Teleport)
- super.postPlay(move);
+ super.tryPostPlayTeleport(move);
else if (typeof move.start.x == "string") {
super.updateReserve(
color, move.start.y, this.reserve[color][move.start.y] - 1);
this.tryChangeTurn(null, captureUndef);
}
}
-
+//TODO
// NOTE: not "trying", the turn always change here (TODO?)
tryChangeTurn(move, captureUndef) {
this.definition = null;
this.subTurn = captureUndef ? 0 : 1;
this.turn = C.GetOppTurn(this.turn);
this.movesCount++;
+ if (this.options["dark"] && this.movesCount >= 2)
+ this.updateEnlightened();
}
computeNextMove(move) {