X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FCoregal.js;h=e0729ac3f7f3fcb615b6b7cec2cdf30f874385a7;hb=14c35dc66973e66f9d9a680abb0a35db93ee2bcb;hp=704ce4c53624f0e0693b4709643ec202853a45db;hpb=f82609cd2aea6d5ee880773795278948fbfac666;p=vchess.git diff --git a/client/src/variants/Coregal.js b/client/src/variants/Coregal.js index 704ce4c5..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?