X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=c7c37896e489ee35e7fd65dee61be321bd58cb1a;hb=b406466b0f0ce67451f1718053e5f5691d6507fb;hp=56f34880e93dcfd75744a1d68bcb9680382518ae;hpb=1ef65040168ab7d55ce921abc9d63644a937d689;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 56f34880..c7c37896 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -54,7 +54,18 @@ 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 => { + if (V.OnBoard(m.start.x, m.start.y)) + lmHighlights[m.start.x + sizeX * m.start.y] = true; + if (V.OnBoard(m.end.x, m.end.y)) + lmHighlights[m.end.x + sizeX * m.end.y] = true; + }); + } const showLight = ( this.settings.highlight && ["all","highlight"].includes(V.ShowMoves) @@ -74,9 +85,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 +634,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] = @@ -695,6 +711,8 @@ export default {