update
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 2 Jan 2024 12:08:07 +0000 (13:08 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 2 Jan 2024 12:08:07 +0000 (13:08 +0100)
variants/Dice/class.js
variants/Dice/style.css

index 02e4f6d..1bb6f1f 100644 (file)
@@ -54,20 +54,47 @@ export default class DiceRules extends ChessRules {
     this.afterPlay = (move_s, newTurn, ops) => {
       // Movestack contains only one move:
       move_s[0].toplay = this.getRandomPiece(this.turn);
-      super.displayMessage(
-        this.message, "To play: " + move_s[0].toplay.toUpperCase());
+      this.toplay = move_s[0].toplay;
+      this.displayMessage(move_s[0].toplay,
+                          C.GetOppTurn(move_s[0].appear[0].c));
       o.afterPlay(move_s, newTurn, ops);
     };
   }
 
+  static get PieceToUnicode() {
+    return {
+      'K': "&#9812;",
+      'Q': "&#9813;",
+      'R': "&#9814;",
+      'B': "&#9815;",
+      'N': "&#9816;",
+      'P': "&#9817;",
+      'k': "&#9818;",
+      'q': "&#9819;",
+      'r': "&#9820;",
+      'b': "&#9821;",
+      'n': "&#9822;",
+      'p': "&#9823;"
+    };
+  }
+
+  displayMessage(piece, color) {
+    if (color == 'w')
+      piece = piece.toUpperCase();
+    super.displayMessage(this.message,
+      '<span>to play:</span> ' +
+      '<span class="symb">' + V.PieceToUnicode[piece] + '</span>'
+    );
+  }
+
   setOtherVariables(fenParsed) {
     super.setOtherVariables(fenParsed);
     this.toplay = fenParsed.toplay;
     this.message = document.createElement("div");
     C.AddClass_es(this.message, "piece-text");
-    this.message.innerHTML = "To play: " + this.toplay.toUpperCase();
     let container = document.getElementById(this.containerId);
     container.appendChild(this.message);
+    this.displayMessage(this.toplay, fenParsed.turn);
   }
 
   getRandomPiece(color) {
@@ -102,8 +129,7 @@ export default class DiceRules extends ChessRules {
 
   playReceivedMove(moves, callback) {
     this.toplay = moves[0].toplay; //only one move
-    super.displayMessage(
-      this.message, "To play: " + this.toplay.toUpperCase());
+    this.displayMessage(this.toplay, C.GetOppTurn(moves[0].appear[0].c));
     super.playReceivedMove(moves, callback);
   }
 
index 5881bc3..c9ed898 100644 (file)
@@ -1,5 +1,11 @@
 @import url("/base_pieces.css");
 
+/* doesn't work:
+@font-face {
+  font-family: chess-font;
+  src: url(/assets/FreeSerifBold-rdMp.otf);
+} */
+
 div.piece-text {
   position: relative;
   margin-top: 15px;
@@ -8,5 +14,10 @@ div.piece-text {
   background-color: transparent;
   color: darkred;
   font-weight: bold;
-  font-size: 2em;
+  font-size: 1.7em;
 }
+
+/*
+div.piece-text > span.symb {
+  font-family: chess-font;
+} */