From: Benjamin Auder Date: Thu, 2 Apr 2020 09:37:11 +0000 (+0200) Subject: Fix Parachute, allow 3 squares in Ball variant X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/user/doc/screen_timer.png?a=commitdiff_plain;h=94b9fcef82470199f97b216fd53e6e57a13295c4;p=vchess.git Fix Parachute, allow 3 squares in Ball variant --- diff --git a/client/src/translations/rules/Ball/en.pug b/client/src/translations/rules/Ball/en.pug index 63859cf3..c70fb460 100644 --- a/client/src/translations/rules/Ball/en.pug +++ b/client/src/translations/rules/Ball/en.pug @@ -14,7 +14,7 @@ ul p. All pieces represent players on a field of some ball game, - so they can move up to two squares only for a better realism. + so they can move up to three squares only for a better realism. figure.diagram-container .diagram.diag12 diff --git a/client/src/translations/rules/Ball/es.pug b/client/src/translations/rules/Ball/es.pug index 69c18c04..916ef802 100644 --- a/client/src/translations/rules/Ball/es.pug +++ b/client/src/translations/rules/Ball/es.pug @@ -14,7 +14,7 @@ ul p. Todas las piezas representan jugadores en un área de juego de pelota, - entonces solo se mueven dos casillas como máximo para un mejor realismo. + entonces solo se mueven tres casillas como máximo para un mejor realismo. figure.diagram-container .diagram.diag12 diff --git a/client/src/translations/rules/Ball/fr.pug b/client/src/translations/rules/Ball/fr.pug index 141cd09f..f38bfbd2 100644 --- a/client/src/translations/rules/Ball/fr.pug +++ b/client/src/translations/rules/Ball/fr.pug @@ -14,7 +14,7 @@ ul p. Toutes les pièces représentent des joueurs sur un terrain d'un certain - jeu de ballon, donc elles ne se déplacent que de deux cases au maximum + jeu de ballon, donc elles ne se déplacent que de trois cases au maximum pour un meilleur réalisme. figure.diagram-container diff --git a/client/src/variants/Ball.js b/client/src/variants/Ball.js index 734a9218..3903e2b4 100644 --- a/client/src/variants/Ball.js +++ b/client/src/variants/Ball.js @@ -268,7 +268,7 @@ export class BallRules extends ChessRules { return super.getPotentialMovesFrom([x, y]); } - // "Sliders": at most 2 steps + // "Sliders": at most 3 steps getSlideNJumpMoves([x, y], steps, oneStep) { let moves = []; outerLoop: for (let step of steps) { @@ -277,7 +277,7 @@ export class BallRules extends ChessRules { let stepCount = 1; while (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY) { moves.push(this.getBasicMove([x, y], [i, j])); - if (oneStep || stepCount == 2) continue outerLoop; + if (oneStep || stepCount == 3) continue outerLoop; i += step[0]; j += step[1]; stepCount++; diff --git a/client/src/variants/Parachute.js b/client/src/variants/Parachute.js index 07186352..86b1ce84 100644 --- a/client/src/variants/Parachute.js +++ b/client/src/variants/Parachute.js @@ -14,6 +14,25 @@ export class ParachuteRules extends ChessRules { return true; } + static IsGoodPosition(position) { + if (position.length == 0) return false; + const rows = position.split("/"); + if (rows.length != V.size.x) return false; + for (let row of rows) { + let sumElts = 0; + for (let i = 0; i < row.length; i++) { + if (V.PIECES.includes(row[i].toLowerCase())) sumElts++; + else { + const num = parseInt(row[i]); + if (isNaN(num)) return false; + sumElts += num; + } + } + if (sumElts != V.size.y) return false; + } + return true; + } + static ParseFen(fen) { const fenParts = fen.split(" "); return Object.assign( @@ -166,6 +185,13 @@ export class ParachuteRules extends ChessRules { return true; } + underCheck(color) { + if (this.kingPos[color][0] < 0) + // A king outside the board isn't under check + return false; + return this.isAttacked(this.kingPos[color], V.GetOppCol(color)); + } + prePlay(move) { super.prePlay(move); if (move.vanish.length == 0) this.reserve[this.turn][move.appear[0].p]--;