Fix display of Hiddenqueen diags in corr games
[vchess.git] / client / src / utils / printDiagram.js
index 524e12b..4239688 100644 (file)
@@ -75,10 +75,12 @@ export function getDiagram(args) {
   const orientation = args.orientation || "w";
   const markArray = getMarkArray(args.marks);
   const shadowArray = getShadowArray(args.shadow);
-  const vr = new V(); //just for pieces images paths
+  const vr = new V(); //TODO: just for pieces images paths
   let boardDiv = "";
   const [startX, startY, inc] =
     orientation == "w" ? [0, 0, 1] : [V.size.x - 1, V.size.y - 1, -1];
+  let lightOddity = (V.size.x + V.size.y) % 2;
+  if (V.DarkBottomRight) lightOddity = 1 - lightOddity;
   for (let i = startX; i >= 0 && i < V.size.x; i += inc) {
     boardDiv += "<div class='row";
     if (i == startX && V.Monochrome) boardDiv += " border-top";
@@ -90,7 +92,7 @@ export function getDiagram(args) {
           (V.Notoodark ? "middle-square" : "dark-square");
         if (j == startY) boardDiv += " border-left";
       }
-      else if ((i + j) % 2 == 0) boardDiv += "light-square";
+      else if ((i + j) % 2 == lightOddity) boardDiv += "light-square";
       else boardDiv += "dark-square";
       boardDiv += " " + store.state.settings.bcolor;
       if (shadowArray.length > 0 && shadowArray[i][j])
@@ -100,7 +102,7 @@ export function getDiagram(args) {
         boardDiv +=
           "<img " +
           "src='/images/pieces/" +
-          vr.getPpath(board[i][j], null, null, orientation) +
+          vr.getPpath(board[i][j], args.color, args.score, orientation) +
           V.IMAGE_EXTENSION + "' " +
           "class='piece'/>";
       }