Fix 'undefined C' issue
authorBenjamin Auder <benjamin.auder@somewhere>
Fri, 3 Dec 2021 07:12:32 +0000 (08:12 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Fri, 3 Dec 2021 07:12:32 +0000 (08:12 +0100)
app.js
base_rules.js
common.css

diff --git a/app.js b/app.js
index d871940..a6ee234 100644 (file)
--- a/app.js
+++ b/app.js
@@ -103,6 +103,7 @@ function showNewGameForm() {
     toggleVisible("newGameForm");
     import(`/variants/${vname}/class.js`).then(module => {
       window.V = module.default;
     toggleVisible("newGameForm");
     import(`/variants/${vname}/class.js`).then(module => {
       window.V = module.default;
+      V.Aliases.forEach(e => window[e.key] = e.val);
       prepareOptions();
     });
   }
       prepareOptions();
     });
   }
@@ -447,6 +448,7 @@ function initializeGame(obj) {
   const options = obj.options || {};
   import(`/variants/${obj.vname}/class.js`).then(module => {
     window.V = module.default;
   const options = obj.options || {};
   import(`/variants/${obj.vname}/class.js`).then(module => {
     window.V = module.default;
+    V.Aliases.forEach(e => window[e.key] = e.val);
     // Load CSS. Avoid loading twice the same stylesheet:
     const allIds = [].slice.call($.styleSheets).map(s => s.id);
     const newId = obj.vname + "_css";
     // Load CSS. Avoid loading twice the same stylesheet:
     const allIds = [].slice.call($.styleSheets).map(s => s.id);
     const newId = obj.vname + "_css";
index 9100173..9444e7b 100644 (file)
@@ -7,6 +7,10 @@ import Move from "/utils/Move.js";
 // NOTE: ChessRules is aliased as window.C, and variants as window.V
 export default class ChessRules {
 
 // NOTE: ChessRules is aliased as window.C, and variants as window.V
 export default class ChessRules {
 
+  static get Aliases() {
+    return [{'C': ChessRules}];
+  }
+
   /////////////////////////
   // VARIANT SPECIFICATIONS
 
   /////////////////////////
   // VARIANT SPECIFICATIONS
 
@@ -380,8 +384,6 @@ export default class ChessRules {
 
   // Fen string fully describes the game state
   constructor(o) {
 
   // Fen string fully describes the game state
   constructor(o) {
-    window.C = ChessRules; //easier alias
-
     this.options = o.options;
     this.playerColor = o.color;
     this.afterPlay = o.afterPlay;
     this.options = o.options;
     this.playerColor = o.color;
     this.afterPlay = o.afterPlay;
index d1a1311..c65559d 100644 (file)
@@ -151,7 +151,7 @@ button:hover, button.block-btn:hover {
 button.block-btn {
   display: block;
   background-color: #01786F;
 button.block-btn {
   display: block;
   background-color: #01786F;
-  margin: 0 auto 20px auto;
+  margin: 0 auto 20px auto; /*TODO: margin-bottom 30px ? */
   font-size: 2rem;
   padding: 15px 32px;
 }
   font-size: 2rem;
   padding: 15px 32px;
 }