X-Git-Url: https://git.auder.net/img/rock_paper_scissors_lizard_spock.gif?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FChakart.js;h=73d7cfc9fe3ac25f98c9f3a0e02a1c39baae6c57;hb=7c8d0174f68dfcda183848d85588e58f5d347cda;hp=8f84b373f93f1f6453dd0bdec43f5f1b7406d468;hpb=42e379837d6d621f4b1464f267c2d50f525110e4;p=vchess.git diff --git a/client/src/variants/Chakart.js b/client/src/variants/Chakart.js index 8f84b373..73d7cfc9 100644 --- a/client/src/variants/Chakart.js +++ b/client/src/variants/Chakart.js @@ -320,7 +320,6 @@ export class ChakartRules extends ChessRules { const L = this.firstMove.length; const fm = this.firstMove[L-1]; switch (fm.end.effect) { - // case 0: a click is required (banana or bomb) case "kingboo": // Exchange position with any piece, // except pawns if arriving on last rank. @@ -370,11 +369,12 @@ export class ChakartRules extends ChessRules { // Helper for getBasicMove() getRandomSquare([x, y], steps) { + const color = this.turn; const validSteps = steps.filter(s => { const [i, j] = [x + s[0], y + s[1]]; return ( V.OnBoard(i, j) && - (this.board[i][j] == V.EMPTY || this.getColor(i, j) == 'a') + (this.board[i][j] == V.EMPTY || this.getColor(i, j) != color) ); }); if (validSteps.length == 0) @@ -1358,7 +1358,7 @@ export class ChakartRules extends ChessRules { // Play a deterministic one: capture king or material if possible return super.getComputerMove(deterministicMoves); // Play a random effect move, at random: - let move1 = randomMoves[randInt(moves.length)]; + let move1 = randomMoves[randInt(randomMoves.length)]; this.play(move1); let move2 = undefined; if (this.subTurn == 2) {