X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=c7c37896e489ee35e7fd65dee61be321bd58cb1a;hb=b406466b0f0ce67451f1718053e5f5691d6507fb;hp=6c26722a4420e73885966196b25db5af90bb4aa3;hpb=e90bafa8fb5fb7641728231bf2398590d96c672a;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 6c26722a..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 ( @@ -702,6 +711,8 @@ export default {