X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=e6a0aafdf08b1e8a8a1eea91bf6c298ad6d0935a;hb=af34341d92d47d14f396e7f4adb81f2a7e9d9a61;hp=56f34880e93dcfd75744a1d68bcb9680382518ae;hpb=1ef65040168ab7d55ce921abc9d63644a937d689;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 56f34880..e6a0aafd 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -54,7 +54,16 @@ export default { incheckSq[sq[0]][sq[1]] = true; }); - const lm = this.lastMove; + let lm = this.lastMove; + // Precompute lastMove highlighting squares + const lmHighlights = {}; + if (!!lm) { + if (!Array.isArray(lm)) lm = [lm]; + lm.forEach(m => { + lmHighlights[m.start.x + sizeX * m.start.y] = true; + lmHighlights[m.end.x + sizeX * m.end.y] = true; + }); + } const showLight = ( this.settings.highlight && ["all","highlight"].includes(V.ShowMoves) @@ -74,9 +83,7 @@ export default { ); }; const inHighlight = (x, y) => { - return showLight && !!lm && ( - (lm.end.x == x && lm.end.y == y) || - (lm.start.x == x && lm.start.y == y)); + return showLight && !!lmHighlights[x + sizeX * y]; }; const inShadow = (x, y) => { return ( @@ -625,6 +632,13 @@ export default { this.processArrowAttempt(e); } }, + // Called by BaseGame after partially undoing multi-moves: + resetCurrentAttempt: function() { + this.possibleMoves = []; + this.start = null; + this.click = ""; + this.selectedPiece = null; + }, processMoveAttempt: function(e) { // Obtain the move from start and end squares const [offsetX, offsetY] =