// Turn "wb" into "B" (for FEN)
static board2fen(b)
{
- return b[0]=='w' ? b[1].toUpperCase() : b[1];
+ return (b[0]=='w' ? b[1].toUpperCase() : b[1]);
}
// Turn "p" into "bp" (for board)
static fen2board(f)
{
- return f.charCodeAt()<=90 ? "w"+f.toLowerCase() : "b"+f;
+ return (f.charCodeAt()<=90 ? "w"+f.toLowerCase() : "b"+f);
}
// Check if FEN describe a position
//////////////////
// INITIALIZATION
- // Fen string fully describes the game state
constructor(fen)
+ {
+ this.re_init(fen);
+ }
+
+ // Fen string fully describes the game state
+ re_init(fen)
{
const fenParsed = V.ParseFen(fen);
this.board = V.GetBoard(fenParsed.position);
move.flags = JSON.stringify(this.aggregateFlags()); //save flags (for undo)
if (V.HasEnpassant)
this.epSquares.push( this.getEpSquare(move) );
- if (!move.color)
- move.color = this.turn; //for interface
V.PlayOnBoard(this.board, move);
this.turn = V.GetOppCol(this.turn);
this.movesCount++;