X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FEightpieces.js;h=76f72b0f8544d74704eb16514d646d110cbf85e8;hb=f14572c4a22425033735253eabbaa2d8dbb53d05;hp=beaddbe9bdd8eba3b950c5a5e64601471ef08599;hpb=d9a7a1e40254bda6e545514596a7363048c084f9;p=vchess.git diff --git a/client/src/variants/Eightpieces.js b/client/src/variants/Eightpieces.js index beaddbe9..76f72b0f 100644 --- a/client/src/variants/Eightpieces.js +++ b/client/src/variants/Eightpieces.js @@ -924,7 +924,7 @@ export const VariantRules = class EightpiecesRules extends ChessRules { absDeltaX = Math.abs(deltaX); const deltaY = y2 - y1, absDeltaY = Math.abs(deltaY); - const step = [ deltaX / absDeltaX, deltaY / absDeltaY ]; + const step = [ deltaX / absDeltaX || 0, deltaY / absDeltaY || 0 ]; if ( // Check that the step is a priori valid: (absDeltaX != absDeltaY && deltaX != 0 && deltaY != 0) || @@ -933,7 +933,7 @@ export const VariantRules = class EightpiecesRules extends ChessRules { return false; } let sq = [ x1 + step[0], y1 + step[1] ]; - while (sq[0] != x2 && sq[1] != y2) { + while (sq[0] != x2 || sq[1] != y2) { if ( // NOTE: no need to check OnBoard in this special case (!lancer && this.board[sq[0]][sq[1]] != V.EMPTY) || @@ -1080,9 +1080,24 @@ export const VariantRules = class EightpiecesRules extends ChessRules { return (!choice.second ? choice : [choice, choice.second]); } + // For moves notation: + static get LANCER_DIRNAMES() { + return { + 'c': "N", + 'd': "NE", + 'e': "E", + 'f': "SE", + 'g': "S", + 'h': "SW", + 'm': "W", + 'o': "NW" + }; + } + getNotation(move) { // Special case "king takes jailer" is a pass move if (move.appear.length == 0 && move.vanish.length == 0) return "pass"; + let notation = undefined; if (this.subTurn == 2) { // Do not consider appear[1] (sentry) for sentry pushes const simpleMove = { @@ -1091,8 +1106,11 @@ export const VariantRules = class EightpiecesRules extends ChessRules { start: move.start, end: move.end }; - return super.getNotation(simpleMove); - } - return super.getNotation(move); + notation = super.getNotation(simpleMove); + } else notation = super.getNotation(move); + if (Object.keys(V.LANCER_DIRNAMES).includes(move.vanish[0].p)) + // Lancer: add direction info + notation += "=" + V.LANCER_DIRNAMES[move.appear[0].p]; + return notation; } };