Implemented turn indicator
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 19 Nov 2018 14:57:29 +0000 (15:57 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 19 Nov 2018 14:57:29 +0000 (15:57 +0100)
TODO
public/javascripts/components/game.js
public/stylesheets/variant.sass

diff --git a/TODO b/TODO
index 8dacb29..ebfc70e 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,2 @@
-PGN text is not selectable (understand why?!)
-Checkered stage 2: switch button at reserve position (or on top).
+PGN text is not selectable on desktop computer (understand why?!)
 Mode expert: game.js, button on top (with online indicator)
-Turn indicator on top too (black or white)
index 30ed7e0..829beaa 100644 (file)
@@ -27,10 +27,6 @@ Vue.component('my-game', {
                let incheckSq = doubleArray(sizeX, sizeY, false);
                this.incheck.forEach(sq => { incheckSq[sq[0]][sq[1]] = true; });
                let elementArray = [];
-               let square00 = document.getElementById("sq-0-0");
-               let squareWidth = !!square00
-                       ? parseFloat(window.getComputedStyle(square00).width.slice(0,-2))
-                       : 0;
                const playingHuman = (this.mode == "human");
                const playingComp = (this.mode == "computer");
                let actionArray = [
@@ -60,25 +56,51 @@ Vue.component('my-game', {
                ];
                if (!!this.vr)
                {
+                       const square00 = document.getElementById("sq-0-0");
+                       const squareWidth = !!square00
+                               ? parseFloat(window.getComputedStyle(square00).width.slice(0,-2))
+                               : 0;
+                       const indicWidth = (squareWidth>0 ? squareWidth/2 : 20);
                        if (this.mode == "human")
                        {
                                let connectedIndic = h(
                                        'div',
                                        {
                                                "class": {
+                                                       "topindicator": true,
+                                                       "indic-left": true,
                                                        "connected": this.oppConnected,
                                                        "disconnected": !this.oppConnected,
                                                },
+                                               style: {
+                                                       "width": indicWidth + "px",
+                                                       "height": indicWidth + "px",
+                                               },
                                        }
                                );
                                elementArray.push(connectedIndic);
                        }
+                       let turnIndic = h(
+                               'div',
+                               {
+                                       "class": {
+                                               "topindicator": true,
+                                               "indic-right": true,
+                                               "white-turn": this.vr.turn=="w",
+                                               "black-turn": this.vr.turn=="b",
+                                       },
+                                       style: {
+                                               "width": indicWidth + "px",
+                                               "height": indicWidth + "px",
+                                       },
+                               }
+                       );
+                       elementArray.push(turnIndic);
                        let choices = h('div',
                                {
                                        attrs: { "id": "choices" },
                                        'class': { 'row': true },
                                        style: {
-                                               //"position": "relative",
                                                "display": this.choices.length>0?"block":"none",
                                                "top": "-" + ((sizeY/2)*squareWidth+squareWidth/2) + "px",
                                                "width": (this.choices.length * squareWidth) + "px",
index b2c678a..495f4ca 100644 (file)
@@ -35,18 +35,30 @@ figure.diagram-container > .diagram
   margin-left: auto
   margin-right: auto
 
-.connected, .disconnected
-  width: 20px
-  height: 20px
-  margin: 0 auto 15px auto
+.topindicator
+  position: relative
   border: 1px solid brown
 
+.indic-left
+  float: left
+  margin: 0 0 10px 20px
+
+.indic-right
+  float: right
+  margin: 0 20px 10px 0
+
 .connected
   background-color: green
 
 .disconnected
   background-color: red
 
+.white-turn
+  background-color: white
+
+.black-turn
+  background-color: black
+
 // TODO: div.board, board9, board10, board11, board12
 div.board
   float: left
@@ -56,6 +68,9 @@ div.board
   display: inline-block
   position: relative
 
+.game
+  clear: both
+
 .game .board
   cursor: pointer