X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCoregal.js;h=e0729ac3f7f3fcb615b6b7cec2cdf30f874385a7;hb=14c35dc66973e66f9d9a680abb0a35db93ee2bcb;hp=1a4a4038a031274e6769c528e84136c8a0a25d83;hpb=3f22c2c3939dfd6bd66da26e6d6d9848c6da86d2;p=vchess.git diff --git a/client/src/variants/Coregal.js b/client/src/variants/Coregal.js index 1a4a4038..e0729ac3 100644 --- a/client/src/variants/Coregal.js +++ b/client/src/variants/Coregal.js @@ -268,18 +268,21 @@ export class CoregalRules extends ChessRules { return false; } - updateCastleFlags(move, piece) { + // "twoKings" arg for the similar Twokings variant. + updateCastleFlags(move, piece, twoKings) { const c = V.GetOppCol(this.turn); const firstRank = (c == "w" ? V.size.x - 1 : 0); // Update castling flags if castling pieces moved or were captured const oppCol = V.GetOppCol(c); const oppFirstRank = V.size.x - 1 - firstRank; - if (move.start.x == firstRank && [V.KING, V.QUEEN].includes(piece)) { - if (this.castleFlags[c][1] == move.start.y) - this.castleFlags[c][1] = 8; - else if (this.castleFlags[c][2] == move.start.y) - this.castleFlags[c][2] = 8; - // Else: the flag is already turned off + if (move.start.x == firstRank) { + if (piece == V.KING || (!twoKings && piece == V.QUEEN)) { + if (this.castleFlags[c][1] == move.start.y) + this.castleFlags[c][1] = 8; + else if (this.castleFlags[c][2] == move.start.y) + this.castleFlags[c][2] = 8; + // Else: the flag is already turned off + } } else if ( move.start.x == firstRank && //our rook moves? @@ -298,6 +301,10 @@ export class CoregalRules extends ChessRules { // NOTE: do not set queen value to 1000 or so, because there may be several. + static get SEARCH_DEPTH() { + return 2; + } + getNotation(move) { if (move.appear.length == 2) { // Castle: determine the right notation