X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FGrand.js;h=844d62c740c7c203729fb7dadd251792fa5506b8;hb=a6abf094c35a26019e47fea21302c4be32ff030b;hp=faf7f63fb5163c965011aa80d043684884019f63;hpb=c605216162dfc09cbbe61b0969f8890f28625372;p=vchess.git diff --git a/public/javascripts/variants/Grand.js b/public/javascripts/variants/Grand.js index faf7f63f..844d62c7 100644 --- a/public/javascripts/variants/Grand.js +++ b/public/javascripts/variants/Grand.js @@ -63,8 +63,8 @@ class GrandRules extends ChessRules const V = VariantRules; const [sizeX,sizeY] = VariantRules.size; const shift = (color == "w" ? -1 : 1); - const startRanks = (color == "w" ? [sizeY-2,sizeY-3] : [1,2]); - const lastRanks = (color == "w" ? [0,1,2] : [sizeY-1,sizeY-2,sizeY-3]); + const startRanks = (color == "w" ? [sizeX-2,sizeX-3] : [1,2]); + const lastRanks = (color == "w" ? [0,1,2] : [sizeX-1,sizeX-2,sizeX-3]); if (x+shift >= 0 && x+shift < sizeX && x+shift != lastRanks[0]) { @@ -76,7 +76,7 @@ class GrandRules extends ChessRules { // Two squares jump moves.push(this.getBasicMove([x,y], [x+2*shift,y])); - if (x == startRanks[0] && this.board[x+2*shift][y] == V.EMPTY) + if (x == startRanks[0] && this.board[x+3*shift][y] == V.EMPTY) { // 3-squares jump moves.push(this.getBasicMove([x,y], [x+3*shift,y])); @@ -93,7 +93,7 @@ class GrandRules extends ChessRules if (lastRanks.includes(x+shift)) { // Promotion - let promotionPieces = [V.ROOK,V.KNIGHT,V.BISHOP,V.QUEEN]; + let promotionPieces = [V.ROOK,V.KNIGHT,V.BISHOP,V.QUEEN,V.MARSHALL,V.CARDINAL]; promotionPieces.forEach(p => { if (!this.captures[color][p] || this.captures[color][p]==0) return; @@ -134,6 +134,8 @@ class GrandRules extends ChessRules return moves; } + // TODO: different castle? + getPotentialMarshallMoves(sq) { const V = VariantRules; @@ -169,9 +171,9 @@ class GrandRules extends ChessRules || this.isAttackedBySlideNJump(sq, colors, V.CARDINAL, V.steps[V.KNIGHT], "oneStep"); } - play(move, ingame) + updateVariables(move) { - super.play(move, ingame); + super.updateVariables(move); if (move.vanish.length==2 && move.appear.length==1 && move.vanish[1].p != VariantRules.PAWN) { @@ -183,13 +185,12 @@ class GrandRules extends ChessRules } } - undo(move) + unupdateVariables(move) { - super.undo(move); + super.unupdateVariables(move); if (move.vanish.length==2 && move.appear.length==1 && move.vanish[1].p != VariantRules.PAWN) { - // Capture: update this.captures this.captures[move.vanish[1].c][move.vanish[1].p] = Math.max(0, this.captures[move.vanish[1].c][move.vanish[1].p]-1); } @@ -202,6 +203,8 @@ class GrandRules extends ChessRules ); } + static get SEARCH_DEPTH() { return 2; } + // TODO: this function could be generalized and shared better static GenRandInitFen() {