From 93e8684c9c995ac6bd53e97289dd294a3bcefc14 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Fri, 13 Mar 2020 01:05:28 +0100 Subject: [PATCH] 'update' --- client/src/variants/Eightpieces.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/client/src/variants/Eightpieces.js b/client/src/variants/Eightpieces.js index a799cff1..f040a838 100644 --- a/client/src/variants/Eightpieces.js +++ b/client/src/variants/Eightpieces.js @@ -666,7 +666,10 @@ export const VariantRules = class EightpiecesRules extends ChessRules { this.castleFlags[oppCol][flagIdx] = false; } - if (this.subTurn == 2) { + if (move.appear.length == 0 && move.vanish.length == 1) { + // The sentry is about to push a piece: + this.sentryPos = { x: move.end.x, y: move.end.y }; + } else if (this.subTurn == 2) { // A piece is pushed: forbid array of squares between start and end // of move, included (except if it's a pawn) let squares = []; @@ -707,19 +710,17 @@ export const VariantRules = class EightpiecesRules extends ChessRules { this.epSquares.push(this.getEpSquare(move)); V.PlayOnBoard(this.board, move); if (this.subTurn == 1) this.movesCount++; - if (move.appear.length == 0 && move.vanish.length == 1) { - // The sentry is about to push a piece: - this.sentryPos = { x: move.end.x, y: move.end.y }; + if (move.appear.length == 0 && move.vanish.length == 1) this.subTurn = 2; - } else { + else { // Turn changes only if not a sentry "pre-push" this.turn = V.GetOppCol(this.turn); this.subTurn = 1; - const L = this.sentryPush.length; - // Is it a sentry push? (useful for undo) - move.sentryPush = !!this.sentryPush[L-1]; } this.updateVariables(move); + const L = this.sentryPush.length; + // Is it a sentry push? (useful for undo) + move.sentryPush = !!this.sentryPush[L-1]; } undo(move) { -- 2.44.0