X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=8de0176c78b73a8fb6011d369bbba3dbdc74d465;hb=2eef6db6cdce30fe785e601b88858c7fc743eee8;hp=a8f24893558a660f3b305210beb280aa2bdecc65;hpb=e82cd97976a6c7707467a384f7d6ca1daa9a0772;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index a8f24893..8de0176c 100644 --- a/public/javascripts/base_rules.js +++ b/public/javascripts/base_rules.js @@ -752,6 +752,7 @@ class ChessRules // END OF GAME // Basic check for 3 repetitions (in the last moves only) + // TODO: extend to usual 3-repetition recognition (storing FEN with move?) checkRepetition() { if (this.moves.length >= 8) @@ -988,9 +989,9 @@ class ChessRules // Setup the initial random (assymetric) position static GenRandInitFen() { - let pieces = [new Array(8), new Array(8)]; + let pieces = { "w": new Array(8), "b": new Array(8) }; // Shuffle pieces on first and last rank - for (let c = 0; c <= 1; c++) + for (let c of ["w","b"]) { let positions = _.range(8); @@ -1032,11 +1033,10 @@ class ChessRules pieces[c][knight2Pos] = 'n'; pieces[c][rook2Pos] = 'r'; } - let fen = pieces[0].join("") + + return pieces["b"].join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" + - pieces[1].join("").toUpperCase() + + pieces["w"].join("").toUpperCase() + " 1111"; //add flags - return fen; } // Return current fen according to pieces+colors state