const storageVariant = localStorage.getItem("comp-variant");
if (!!storageVariant)
{
- if (storageVariant !== variant)
+ const score = localStorage.getItem("comp-score");
+ if (storageVariant !== variant && score == "*")
{
if (!confirm("Unfinished " + storageVariant +
" computer game will be erased"))
return;
}
}
- else
- {
- const score = localStorage.getItem("comp-score");
- if (score == "*")
- return this.continueGame("computer");
- }
+ else if (score == "*")
+ return this.continueGame("computer");
}
}
this.vr = new VariantRules(fen, []);
return pieces["b"].join("") + "/" + ranks23_black +
"/8/8/" +
ranks23_white + "/" + pieces["w"].join("").toUpperCase() +
- " w 1111";
+ " w 1111 -";
}
}
return true;
}
+ static ParseFen(fen)
+ {
+ const fenParts = fen.split(" ");
+ return Object.assign(
+ ChessRules.ParseFen(fen),
+ {
+ reserve: fenParts[4],
+ promoted: fenParts[5],
+ }
+ );
+ }
+
static GenRandInitFen()
{
- const fen = ChessRules.GenRandInitFen();
- return fen.replace(" w 1111", " w 1111 0000000000 -");
+ return ChessRules.GenRandInitFen() + " 0000000000 -";
}
getFen()
}
if (res.length > 0)
res = res.slice(0,-1); //remove last comma
+ else
+ res = "-";
return res;
}
}
};
this.promoted = doubleArray(V.size.x, V.size.y, false);
- for (let square of fenParsd.promoted.split(","))
+ if (fenParsed.promoted != "-")
{
- const [x,y] = V.SquareToCoords(square);
- promoted[x][y] = true;
+ for (let square of fenParsed.promoted.split(","))
+ {
+ const [x,y] = V.SquareToCoords(square);
+ promoted[x][y] = true;
+ }
}
}
return true;
}
+ static ParseFen(fen)
+ {
+ const fenParts = fen.split(" ");
+ return Object.assign(
+ ChessRules.ParseFen(fen),
+ { captured: fenParts[4] }
+ );
+ }
+
static GenRandInitFen()
{
- const fen = ChessRules.GenRandInitFen();
- return fen.replace(" w 1111", " w 1111 0000000000");
+ return ChessRules.GenRandInitFen() + " 0000000000";
}
getFen()
class MagneticRules extends ChessRules
{
- static get HasEnpassant { return false; }
+ static get HasEnpassant() { return false; }
setOtherVariables(fen)
{
class ZenRules extends ChessRules
{
// NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare
- static get HasEnpassant { return false; }
+ static get HasEnpassant() { return false; }
// TODO(?): some duplicated code in 2 next functions
getSlideNJumpMoves([x,y], steps, oneStep)