X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=e6a0aafdf08b1e8a8a1eea91bf6c298ad6d0935a;hp=6c26722a4420e73885966196b25db5af90bb4aa3;hb=af34341d92d47d14f396e7f4adb81f2a7e9d9a61;hpb=fef153df51fe60a5af4c5b2a05e0b1177187bf62 diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 6c26722a..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 (