Add Sittuyin + Doublemove2. A few fixes. TODO: fix Ambiguous bugs and playing on...
[vchess.git] / client / src / components / Board.vue
index 56f3488..c7c3789 100644 (file)
@@ -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 {
 </script>
 
 <style lang="sass" scoped>
+@import "@/styles/_board_squares_img.sass";
+
 // NOTE: no variants with reserve of size != 8
 .game.reserve-div
   margin-bottom: 18px
@@ -788,5 +806,4 @@ img.ghost
   background-color: #9f9fff
 .dark-square.chesstempo.highlight-dark
   background-color: #557fff
-
 </style>