X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FSchess.js;h=d8e1b1c5c9a08e84ca62690d6cf8f90876870a03;hb=ce5afae7847431d33b55efec89d735acfcb31752;hp=07556a50de5852e976d5a2edfdf322b2b9c1de95;hpb=0d5335de5c94d780e03ac0aa3279b731c69455cc;p=vchess.git diff --git a/client/src/variants/Schess.js b/client/src/variants/Schess.js index 07556a50..d8e1b1c5 100644 --- a/client/src/variants/Schess.js +++ b/client/src/variants/Schess.js @@ -1,6 +1,7 @@ import { ChessRules, PiPo } from "@/base_rules"; export class SchessRules extends ChessRules { + static get PawnSpecs() { return Object.assign( {}, @@ -119,12 +120,12 @@ export class SchessRules extends ChessRules { const fenParsed = V.ParseFen(fen); this.pocket = { "w": { - h: parseInt(fenParsed.pocket[0]), - e: parseInt(fenParsed.pocket[1]) + h: parseInt(fenParsed.pocket[0], 10), + e: parseInt(fenParsed.pocket[1], 10) }, "b": { - h: parseInt(fenParsed.pocket[2]), - e: parseInt(fenParsed.pocket[3]) + h: parseInt(fenParsed.pocket[2], 10), + e: parseInt(fenParsed.pocket[3], 10) } }; } @@ -172,7 +173,8 @@ export class SchessRules extends ChessRules { ( m.appear.length == shift+1 || // Special castle case: is initial king square free? - ![m.appear[shift].y, m.appear[shift+1].y].includes(m.vanish[0].y) + ![m.appear[shift].y, m.appear[shift+1].y] + .includes(m.vanish[0].y) ) ) { let pMove = JSON.parse(JSON.stringify(m)); @@ -191,7 +193,8 @@ export class SchessRules extends ChessRules { if ( m.appear.length >= 2 + shift && m.vanish.length == 2 && - ![m.appear[shift].y, m.appear[shift+1].y].includes(m.vanish[1].y) + ![m.appear[shift].y, m.appear[shift+1].y] + .includes(m.vanish[1].y) ) { // Special castle case: rook flag was necessarily on let pMove = JSON.parse(JSON.stringify(m)); @@ -289,7 +292,6 @@ export class SchessRules extends ChessRules { ([V.HAWK, V.ELEPHANT, V.NOTHING].includes(move.appear[0].p) ? 1 : 0); this.kingPos[color][0] = move.appear[shift].x; this.kingPos[color][1] = move.appear[shift].y; - return; } this.updateCastleFlags(move, piece); @@ -340,7 +342,14 @@ export class SchessRules extends ChessRules { const nothingAppear = (move.appear[0].p == V.NOTHING); if (pPieceAppear || nothingAppear) { let suffix = ""; - if (pPieceAppear) suffix = "/" + move.appear[0].p.toUpperCase(); + if (pPieceAppear) { + suffix = "/" + move.appear[0].p.toUpperCase(); + if (move.appear.length == 3) { + // Castling; indicate square + suffix += + V.CoordsToSquare({ x: move.appear[0].x, y: move.appear[0].y }); + } + } let cmove = JSON.parse(JSON.stringify(move)); cmove.appear.shift(); return super.getNotation(cmove) + suffix; @@ -348,4 +357,5 @@ export class SchessRules extends ChessRules { } return super.getNotation(move); } + };