// Flags part of the FEN string
getFlagsFen() {
- return ["w", "b"].map(c => {
+ return ['w', 'b'].map(c => {
return this.castleFlags[c].map(x => x.toString(36)).join("");
}).join("");
}
if (o.init)
return "000000000000";
return (
- ["w","b"].map(c => Object.values(this.reserve[c]).join("")).join("")
+ ['w', 'b'].map(c => Object.values(this.reserve[c]).join("")).join("")
);
}
getPotentialMovesOf(piece, [x, y]) {
const color = this.getColor(x, y);
const stepSpec = this.getStepSpec(color, x, y, piece);
+
+ // TODO: pawns, coregal
+console.log(stepSpec);
+
let squares = [];
if (stepSpec.attack) {
squares = this.findDestSquares(
continue outerLoop;
const oldIJ = [i, j];
[i, j] = this.increment([i, j], step);
- if (Math.abs(j - oldIJ[1]) > 1 || Math.abs(i - oldIJ[0]) > 1) {
+ if (
+ Math.abs(i - oldIJ[0]) != Math.abs(step[0]) ||
+ Math.abs(j - oldIJ[1]) != Math.abs(step[1])
+ ) {
// Boundary between segments (cylinder or circular mode)
segments.push([[segStart[0], segStart[1]], oldIJ]);
segStart = [i, j];
}
// NOTE: arg "castleFlags" for Coregal or Twokings
- updateCastleFlags(move, castleFlags) {
+ updateCastleFlags(move, castleFlags, king) {
castleFlags = castleFlags || this.castleFlags;
// If flags already off, no need to re-check:
if (
}
// Update castling flags if start or arrive from/at rook/king locations
move.appear.concat(move.vanish).forEach(psq => {
- if (this.isKing(0, 0, psq.p))
+ if ((!!king && psq.p == king) || this.isKing(0, 0, psq.p))
castleFlags[psq.c] = [this.size.y, this.size.y];
// NOTE: not "else if" because king can capture enemy rook...
let c = "";