Add Checkered1 + fix last move highlights
[vchess.git] / client / src / components / Board.vue
index 56f3488..e6a0aaf 100644 (file)
@@ -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] =