Fixes + implement Cylinder Chess
[vchess.git] / client / src / components / Board.vue
index 45c7293..bf43051 100644 (file)
@@ -11,6 +11,7 @@ export default {
     "vr",
     "lastMove",
     "analyze",
+    "score",
     "incheck",
     "orientation",
     "userColor",
@@ -46,9 +47,9 @@ export default {
       incheckSq[sq[0]][sq[1]] = true;
     });
 
-    // Create board element (+ reserves if needed by variant or mode)
+    // Create board element (+ reserves if needed by variant)
     const lm = this.lastMove;
-    const showLight = this.settings.highlight && this.vname != "Dark";
+    const showLight = this.settings.highlight && V.ShowMoves == "all";
     const gameDiv = h(
       "div",
       {
@@ -58,7 +59,7 @@ export default {
         }
       },
       [...Array(sizeX).keys()].map(i => {
-        let ci = this.orientation == "w" ? i : sizeX - i - 1;
+        let ci = !V.CanFlip || this.orientation == "w" ? i : sizeX - i - 1;
         return h(
           "div",
           {
@@ -68,12 +69,11 @@ export default {
             style: { opacity: this.choices.length > 0 ? "0.5" : "1" }
           },
           [...Array(sizeY).keys()].map(j => {
-            let cj = this.orientation == "w" ? j : sizeY - j - 1;
+            let cj = !V.CanFlip || this.orientation == "w" ? j : sizeY - j - 1;
             let elems = [];
             if (
               this.vr.board[ci][cj] != V.EMPTY &&
-              (this.vname != "Dark" ||
-                this.analyze ||
+              (!this.vr.enlightened || this.analyze || this.score != "*" ||
                 (!!this.userColor &&
                   this.vr.enlightened[this.userColor][ci][cj]))
             ) {
@@ -88,7 +88,7 @@ export default {
                   attrs: {
                     src:
                       "/images/pieces/" +
-                      V.getPpath(this.vr.board[ci][cj]) +
+                      this.vr.getPpath(this.vr.board[ci][cj], this.userColor, this.score) +
                       ".svg"
                   }
                 })
@@ -116,8 +116,9 @@ export default {
                   "dark-square": (i + j) % 2 == 1,
                   [this.settings.bcolor]: true,
                   "in-shadow":
-                    this.vname == "Dark" &&
                     !this.analyze &&
+                    this.score == "*" &&
+                    this.vr.enlightened &&
                     (!this.userColor ||
                       !this.vr.enlightened[this.userColor][ci][cj]),
                   highlight:
@@ -153,7 +154,7 @@ export default {
                 attrs: {
                   src:
                     "/images/pieces/" +
-                    this.vr.getReservePpath(playingColor, i) +
+                    this.vr.getReservePpath(i, playingColor) +
                     ".svg"
                 }
               }),
@@ -180,7 +181,7 @@ export default {
                 attrs: {
                   src:
                     "/images/pieces/" +
-                    this.vr.getReservePpath(oppCol, i) +
+                    this.vr.getReservePpath(i, oppCol) +
                     ".svg"
                 }
               }),
@@ -254,7 +255,7 @@ export default {
                 attrs: {
                   src:
                     "/images/pieces/" +
-                    V.getPpath(m.appear[0].c + m.appear[0].p) +
+                    this.vr.getPpath(m.appear[0].c + m.appear[0].p) +
                     ".svg"
                 },
                 class: { "choice-piece": true },
@@ -342,7 +343,7 @@ export default {
       // Next condition: classList.contains(piece) fails because of marks
       while (landing.tagName == "IMG") landing = landing.parentNode;
       if (this.start.id == landing.id)
-        //one or multi clicks on same piece
+        // One or multi clicks on same piece
         return;
       // OK: process move attempt, landing is a square node
       let endSquare = getSquareFromId(landing.id);