X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FGrand.js;h=e92896b8bf5aecae04bc058a680f124426cc2b63;hb=2c5d7b20742b802d9c47916915c1114bcfc9a9c3;hp=5523244ba1674763b29c0bb129e707cd0e981f1b;hpb=32f6285ee325a14286562a53baefc647201df2af;p=vchess.git diff --git a/client/src/variants/Grand.js b/client/src/variants/Grand.js index 5523244b..e92896b8 100644 --- a/client/src/variants/Grand.js +++ b/client/src/variants/Grand.js @@ -28,7 +28,10 @@ export class GrandRules extends ChessRules { static ParseFen(fen) { const fenParts = fen.split(" "); - return Object.assign(ChessRules.ParseFen(fen), { captured: fenParts[5] }); + return Object.assign( + ChessRules.ParseFen(fen), + { captured: fenParts[5] } + ); } getPpath(b) { @@ -87,12 +90,15 @@ export class GrandRules extends ChessRules { return { x: 10, y: 10 }; } + // Rook + knight: static get MARSHALL() { return "m"; - } //rook+knight + } + + // Bishop + knight static get CARDINAL() { return "c"; - } //bishop+knight + } static get PIECES() { return ChessRules.PIECES.concat([V.MARSHALL, V.CARDINAL]); @@ -322,16 +328,20 @@ export class GrandRules extends ChessRules { static GenRandInitFen(randomness) { if (randomness == 0) { - // No castling in the official initial setup - return "r8r/1nbqkmcbn1/pppppppppp/10/10/10/10/PPPPPPPPPP/1NBQKMCBN1/R8R " + - "w 0 zzzz - 00000000000000"; + return ( + "r8r/1nbqkmcbn1/pppppppppp/91/91/91/91/PPPPPPPPPP/1NBQKMCBN1/R8R " + + // No castling in the official initial setup + "w 0 zzzz - 00000000000000" + ); } let pieces = { w: new Array(10), b: new Array(10) }; + let flags = ""; // Shuffle pieces on first and last rank for (let c of ["w", "b"]) { if (c == 'b' && randomness == 1) { pieces['b'] = pieces['w']; + flags += flags; break; } @@ -370,7 +380,8 @@ export class GrandRules extends ChessRules { let cardinalPos = positions[randIndex]; positions.splice(randIndex, 1); - // Rooks and king positions are now fixed, because of the ordering rook-king-rook + // Rooks and king positions are now fixed, + // because of the ordering rook-king-rook let rook1Pos = positions[0]; let kingPos = positions[1]; let rook2Pos = positions[2]; @@ -386,12 +397,13 @@ export class GrandRules extends ChessRules { pieces[c][bishop2Pos] = "b"; pieces[c][knight2Pos] = "n"; pieces[c][rook2Pos] = "r"; + flags += V.CoordToColumn(rook1Pos) + V.CoordToColumn(rook2Pos); } return ( pieces["b"].join("") + - "/pppppppppp/10/10/10/10/10/10/PPPPPPPPPP/" + + "/pppppppppp/91/91/91/91/91/91/PPPPPPPPPP/" + pieces["w"].join("").toUpperCase() + - " w 0 1111 - 00000000000000" + " w 0 " + flags + " - 00000000000000" ); } };