From: Benjamin Auder Date: Tue, 5 Jan 2021 16:58:39 +0000 (+0100) Subject: Paco-Sako: allow castling with a rook in union + fix a bug in isAttacked() X-Git-Url: https://git.auder.net/doc/html/packages.html?a=commitdiff_plain;h=0b4bca844aa20cb88531cd25bc0140a569f03947;p=vchess.git Paco-Sako: allow castling with a rook in union + fix a bug in isAttacked() --- diff --git a/TODO b/TODO index feb1425a..68e8b7ad 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,10 @@ PROBABLY WON'T FIX: Embedded rules language not updated when language is set (in Analyse, Game and Problems) -If new live game starts in background, "new game" notify OK but not first move (not too serious however) +If new live game starts in background, "new game" notify OK but not first move. NEW VARIANTS: +https://www.chessvariants.com/incinf.dir/bario.html +https://www.chessvariants.com/mvopponent.dir/avalanche.html https://www.pychess.org/variant/manchu https://www.pychess.org/variant/dobutsu https://musketeerchess.net/games/musketeer/index.php Attention règle de promotion + SVG / PNG @@ -11,7 +13,6 @@ https://www.pychess.org/variant/shogun https://www.reddit.com/r/TotemChess/comments/imi3v7/totem_rules/ https://www.chessvariants.com/other.dir/fugue.html https://www.chessvariants.com/rules/spartan-chess -https://www.chessvariants.com/mvopponent.dir/avalanche.html https://www.chessvariants.com/mvopponent.dir/hypnotic-chess.html https://www.chessvariants.com/mvopponent.dir/mesmer-chess.html https://brainking.com/en/GameRules?tp=47&fwa=ArchivedGame!g=8204276$i=1 @@ -31,7 +32,6 @@ https://www.jatektan.hu/_2018_vissza/2011_ig/uj2001/isakk1.html https://boardgamegeek.com/boardgame/18661/alapo Alapo is a strategy game. Each player owns twelve abstract pieces, two each of six different kinds. Round pieces move in any of the eight directions on the 6 by 6 board; square pieces move only orthogonally and triangular pieces only diagonally. Large pieces move any distance, small pieces only one field per turn. Opponent pieces can be eliminated by moving onto their position. The goal is to reach the opponent's base line with one of your pieces without the opponent being able to eliminate your piece in his/her next move. -https://www.chessvariants.com/incinf.dir/bario.html https://discord.com/channels/686736099959504907/687076968046395410/735678637432635473 + Amazon Chess Maybe: https://www.chessvariants.com/diffmove.dir/asymmetric.html diff --git a/client/src/translations/rules/Pacosako/fr.pug b/client/src/translations/rules/Pacosako/fr.pug index 332ca898..de85735f 100644 --- a/client/src/translations/rules/Pacosako/fr.pug +++ b/client/src/translations/rules/Pacosako/fr.pug @@ -49,7 +49,7 @@ ul p | Ceci peut paraître indigeste à première lecture, mais c'est plus simple - | que ça en a l'air. Voyez par exemple cette + | que ça en a l'air. Voir par exemple cette a(href="https://www.youtube.com/watch?v=tQ2JLsFvfxI") vidéo de gameplay | , ou une autre de la même chaîne YouTube. diff --git a/client/src/variants/Pacosako.js b/client/src/variants/Pacosako.js index 5eb96b66..8cec688f 100644 --- a/client/src/variants/Pacosako.js +++ b/client/src/variants/Pacosako.js @@ -508,6 +508,8 @@ export class PacosakoRules extends ChessRules { castlingCheck: for (let castleSide = 0; castleSide < 2; castleSide++) { if (this.castleFlags[c][castleSide] >= 8) continue; const rookPos = this.castleFlags[c][castleSide]; + const castlingColor = this.board[x][rookPos].charAt(0); + const castlingPiece = this.board[x][rookPos].charAt(1); // Nothing on the path of the king ? const finDist = finalSquares[castleSide][0] - y; @@ -561,14 +563,14 @@ export class PacosakoRules extends ChessRules { new PiPo({ x: x, y: finalSquares[castleSide][1], - p: V.ROOK, - c: c + p: castlingPiece, + c: castlingColor }) ], vanish: [ // King might be initially disguised (Titan...) new PiPo({ x: x, y: y, p: V.KING, c: c }), - new PiPo({ x: x, y: rookPos, p: V.ROOK, c: c }) + new PiPo({ x: x, y: rookPos, p: castlingPiece, c: castlingColor }) ], end: Math.abs(y - rookPos) <= 2 @@ -581,6 +583,14 @@ export class PacosakoRules extends ChessRules { return moves; } + getEnpassantCaptures(sq, shiftX) { + // HACK: when artificially change turn, do not consider en-passant + const mcMod2 = this.movesCount % 2; + const c = this.turn; + if ((c == 'w' && mcMod2 == 1) || (c == 'b' && mcMod2 == 0)) return []; + return super.getEnpassantCaptures(sq, shiftX); + } + isAttacked_aux(files, color, positions, fromSquare, released) { // "positions" = array of FENs to detect infinite loops. Example: // r1q1k2r/p1Pb1ppp/5n2/1f1p4/AV5P/P1eDP3/3B1PP1/R3K1NR, @@ -677,6 +687,23 @@ export class PacosakoRules extends ChessRules { this.postPlay(move); } + updateCastleFlags(move, piece) { + const c = V.GetOppCol(this.turn); + const firstRank = (c == "w" ? 7 : 0); + const oppCol = this.turn; + const oppFirstRank = 7 - firstRank; + if (piece == V.KING && move.appear.length > 0) + this.castleFlags[c] = [V.size.y, V.size.y]; + else if ( + move.start.x == firstRank && + this.castleFlags[c].includes(move.start.y) + ) { + const flagIdx = (move.start.y == this.castleFlags[c][0] ? 0 : 1); + this.castleFlags[c][flagIdx] = V.size.y; + } + // No more checking: a rook in union can take part in castling. + } + postPlay(move) { if (move.vanish.length == 0) // A released piece just moved. Cannot be the king.