Graphical fix
[vchess.git] / client / src / components / BaseGame.vue
index 1240bcb..55ed249 100644 (file)
@@ -17,7 +17,7 @@ div#baseGame(tabindex=-1 @click="() => focusBg()"
     #boardContainer
       Board(:vr="vr" :last-move="lastMove" :analyze="analyze"
         :user-color="game.mycolor" :orientation="orientation"
-        :vname="game.vname" @play-move="play")
+        :vname="game.vname" :incheck="incheck" @play-move="play")
       #turnIndicator(v-if="game.vname=='Dark' && game.score=='*'")
         | {{ turn }}
       #controls
@@ -51,6 +51,7 @@ import { store } from "@/store";
 import { getSquareId } from "@/utils/squareId";
 import { getDate } from "@/utils/datetime";
 import { processModalClick } from "@/utils/modalClick";
+import { getScoreMessage } from "@/utils/scoring";
 
 export default {
   name: 'my-base-game',
@@ -71,6 +72,7 @@ export default {
       cursor: -1, //index of the move just played
       lastMove: null,
       firstMoveNumber: 0, //for printing
+      incheck: [], //for Board
     };
   },
   watch: {
@@ -79,6 +81,7 @@ export default {
       this.re_setVariables();
     },
     // Received a new move to play:
+    // TODO: error "flush nextTick callbacks" when observer reloads page
     "game.moveToPlay": function(newMove) {
       if (!!newMove) //if stop + launch new game, get undefined move
         this.play(newMove, "receive");
@@ -220,6 +223,7 @@ export default {
       const L = this.moves.length;
       this.cursor = L-1;
       this.lastMove = (L > 0 ? this.moves[L-1]  : null);
+      this.incheck = [];
     },
     analyzePosition: function() {
       const newUrl = "/analyze/" + this.game.vname +
@@ -262,25 +266,6 @@ export default {
       }
       return pgn + "\n";
     },
-    getScoreMessage: function(score) {
-      let eogMessage = "Undefined"; //not translated: unused
-      switch (score)
-      {
-        case "1-0":
-          eogMessage = this.st.tr["White win"];
-          break;
-        case "0-1":
-          eogMessage = this.st.tr["Black win"];
-          break;
-        case "1/2":
-          eogMessage = this.st.tr["Draw"];
-          break;
-        case "?":
-          eogMessage = this.st.tr["Unknown"];
-          break;
-      }
-      return eogMessage;
-    },
     showEndgameMsg: function(message) {
       this.endgameMessage = message;
       let modalBox = document.getElementById("modalEog");
@@ -358,7 +343,7 @@ export default {
         const score = this.vr.getCurrentScore();
         if (score != "*")
         {
-          const message = this.getScoreMessage(score);
+          const message = getScoreMessage(score);
           if (this.game.mode != "analyze")
             this.$emit("gameover", score, message);
           else //just show score on screen (allow undo)