X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FFanorona.js;h=4593e6bb00954cd4d701f46b7edac8f5b12339cb;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=04eea2c34c333a9f23cea3300c883dec2547b30e;hpb=cdab566355412821c9187078ee0864ceb30545de;p=vchess.git diff --git a/client/src/variants/Fanorona.js b/client/src/variants/Fanorona.js index 04eea2c3..4593e6bb 100644 --- a/client/src/variants/Fanorona.js +++ b/client/src/variants/Fanorona.js @@ -80,13 +80,14 @@ export class FanoronaRules extends ChessRules { return "Fanorona/" + b; } - getPPpath(m) { + getPPpath(m, orientation) { // m.vanish.length >= 2, first capture gives direction const ref = (Math.abs(m.vanish[1].x - m.start.x) == 1 ? m.start : m.end); const step = [m.vanish[1].x - ref.x, m.vanish[1].y - ref.y]; + const multStep = (orientation == 'w' ? 1 : -1); const normalizedStep = [ - step[0] / Math.abs(step[0]), - step[1] / Math.abs(step[1]) + multStep * step[0] / Math.abs(step[0]), + multStep * step[1] / Math.abs(step[1]) ]; return ( "Fanorona/arrow_" + @@ -246,18 +247,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 +267,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();