X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FFanorona.js;fp=client%2Fsrc%2Fvariants%2FFanorona.js;h=399116353e9a940dde808678dd1d61701c9f62be;hb=d982fffc441a0443be90ba6f57a94d1d60b702c8;hp=04eea2c34c333a9f23cea3300c883dec2547b30e;hpb=259035ec507062fdfc7158ac62b68c722404bfdf;p=vchess.git diff --git a/client/src/variants/Fanorona.js b/client/src/variants/Fanorona.js index 04eea2c3..39911635 100644 --- a/client/src/variants/Fanorona.js +++ b/client/src/variants/Fanorona.js @@ -246,18 +246,16 @@ export class FanoronaRules extends ChessRules { const color = this.turn; move.turn = color; //for undo V.PlayOnBoard(this.board, move); - const L0 = this.captures.length; - let captures = this.captures[L0 - 1]; if (move.vanish.length >= 2) { + const L0 = this.captures.length; + let captures = this.captures[L0 - 1]; captures.push({ square: move.start, step: [move.end.x - move.start.x, move.end.y - move.start.y] }); if (this.atLeastOneCapture()) // There could be other captures (optional) - // This field is mostly useful for computer play. move.notTheEnd = true; - else captures.pop(); //useless now } if (!move.notTheEnd) { this.turn = V.GetOppCol(color); @@ -268,12 +266,12 @@ export class FanoronaRules extends ChessRules { undo(move) { V.UndoOnBoard(this.board, move); - if (move.turn != this.turn) { + if (!move.notTheEnd) { this.turn = move.turn; this.movesCount--; this.captures.pop(); } - else { + if (move.vanish.length >= 2) { const L0 = this.captures.length; let captures = this.captures[L0 - 1]; captures.pop();