X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FBoard.vue;h=8a42d34eaff8738e53078c9d68396d212e3a7e36;hb=cd49e617866590dbc68530ad961b109cdbe1ce55;hp=6c26722a4420e73885966196b25db5af90bb4aa3;hpb=e90bafa8fb5fb7641728231bf2398590d96c672a;p=vchess.git diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index 6c26722a..8a42d34e 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 ( @@ -205,7 +214,7 @@ export default { attrs: { src: "/images/pieces/" + - this.vr.getReservePpath(i, playingColor) + + this.vr.getReservePpath(i, playingColor, orientation) + ".svg" } }), @@ -232,7 +241,7 @@ export default { attrs: { src: "/images/pieces/" + - this.vr.getReservePpath(i, oppCol) + + this.vr.getReservePpath(i, oppCol, orientation) + ".svg" } }), @@ -702,6 +711,8 @@ export default {