X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fbase_rules.js;h=e70b9de88eef4caf811de25ad45aa69fbf5b1654;hb=964eda04ad6415b4ec95387ea08b63a3d0f0f9cc;hp=1795b5fa97f9a8cd46adb202b857c1a879cf76ff;hpb=90df90bca1a993930a0e1a07a1b4990dd538c6e2;p=vchess.git diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 1795b5fa..e70b9de8 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -80,6 +80,19 @@ export const ChessRules = class ChessRules { return V.ShowMoves; } + // Sometimes moves must remain hidden until game ends + static get SomeHiddenMoves() { + return false; + } + get someHiddenMoves() { + return V.SomeHiddenMoves; + } + + // Generally true, unless the variant includes random effects + static get CorrConfirm() { + return true; + } + // Used for Monochrome variant (TODO: harmonize: !canFlip ==> showFirstTurn) get showFirstTurn() { return false; @@ -738,8 +751,7 @@ export const ChessRules = class ChessRules { if (x2 == lastRank) { // promotions arg: special override for Hiddenqueen variant if (!!promotions) finalPieces = promotions; - else if (!!V.PawnSpecs.promotions) - finalPieces = V.PawnSpecs.promotions; + else if (!!V.PawnSpecs.promotions) finalPieces = V.PawnSpecs.promotions; } let tr = null; for (let piece of finalPieces) { @@ -788,10 +800,7 @@ export const ChessRules = class ChessRules { // Captures if (V.PawnSpecs.canCapture) { for (let shiftY of [-1, 1]) { - if ( - y + shiftY >= 0 && - y + shiftY < sizeY - ) { + if (y + shiftY >= 0 && y + shiftY < sizeY) { if ( this.board[x + shiftX][y + shiftY] != V.EMPTY && this.canTake([x, y], [x + shiftX, y + shiftY]) @@ -908,6 +917,7 @@ export const ChessRules = class ChessRules { if ( // NOTE: "castling" arg is used by some variants (Monster), // where "isAttacked" is overloaded in an infinite-recursive way. + // TODO: not used anymore (Monster + Doublemove2 are simplified). (!castleInCheck && this.isAttacked([x, i], oppCol, "castling")) || (this.board[x][i] != V.EMPTY && // NOTE: next check is enough, because of chessboard constraints @@ -1192,10 +1202,8 @@ export const ChessRules = class ChessRules { piece = move.appear[0].p; // Update king position + flags - if (piece == V.KING && move.appear.length > 0) { - this.kingPos[c][0] = move.appear[0].x; - this.kingPos[c][1] = move.appear[0].y; - } + if (piece == V.KING && move.appear.length > 0) + this.kingPos[c] = [move.appear[0].x, move.appear[0].y]; if (V.HasCastle) this.updateCastleFlags(move, piece); }