X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FChakart.js;h=e8b95cb1d4e67d4f6ca4bbcbb6adf35f07d5e94f;hp=7b2e77e29389703f6aa5cddbd4e16c6e7e9e1b08;hb=1c15969ecec2a86ee7dffe570e53dfd61fd06b22;hpb=6c7cbfedc6ecf2b49f6b1e27a174039e92a36365 diff --git a/client/src/variants/Chakart.js b/client/src/variants/Chakart.js index 7b2e77e2..e8b95cb1 100644 --- a/client/src/variants/Chakart.js +++ b/client/src/variants/Chakart.js @@ -90,12 +90,61 @@ export class ChakartRules extends ChessRules { //atLeastOneMove() should be OK + doClick(square) { + // A click to promote a piece on subTurn 2 would trigger this. + // For now it would then return [NaN, NaN] because surrounding squares + // have no IDs in the promotion modal. TODO: improve this? + if (!square[0]) return null; + // If subTurn == 2: + // if square is empty && firstMove is compatible, + // complete the move (banana or bomb). + // if square not empty, just complete with empty move + const Lf = this.firstMove.length; + if (this.subTurn == 2) { + if ( + this.board[square[0]][square[1]] == V.EMPTY && + !this.underCheck(this.turn) && + (La == 0 || !this.oppositeMoves(this.amoves[La-1], this.firstMove[Lf-1])) + ) { + return { + start: { x: -1, y: -1 }, + end: { x: -1, y: -1 }, + appear: [], + vanish: [] + }; + } + } + return null; + } + + postPlay(move) { + // TODO: king may also be "chomped" + super.updateCastleFlags(move, piece); + } + getCurrentScore() { + if (this.kingPos[this.turn][0] < 0) + // King captured (or "chomped") + return this.turn == "w" ? "0-1" : "1-0"; + const color = V.GetOppCol(this.turn); + const lastRank = (color == 'w' ? 0 : 7); + if (this.kingPos[color][0] == lastRank) + // The opposing edge is reached! + return color == "w" ? "1-0" : "0-1"; + if (this.atLeastOneMove()) return "*"; + // Game over + const oppCol = this.turn; + if (!this.underCheck(oppCol)) return "1/2"; + return (oppCol == "w" ? "0-1" : "1-0"); //TODO: But = capturer la princesse adverse. Variante : but = la princesse arrive de l'autre côté de l'échiquier. //==> On peut mixer ces deux conditions : arriver au bout du plateau ou capturer la princesse adverse. return '*'; } + getComputerMove() { + // TODO: random mover + } + //Détails : //Si une pièce pose quelque chose sur une case ça remplace ce qui y était déjà. //Pas de condition de pat, puisque l'objectif est la capture de la reine :)