4 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
6 button(@click="clickReadRules()") {{ st.tr["Rules"] }}
7 button(v-show="!gameInProgress" @click="startGame('auto')")
8 | {{ st.tr["Example game"] }}
9 button(v-show="!gameInProgress" @click="startGame('versus')")
10 | {{ st.tr["Practice"] }}
11 button(v-show="gameInProgress" @click="stopGame()")
12 | {{ st.tr["Stop game"] }}
13 button(v-if="display=='rules' && gameInfo.vname!='Dark'"
14 @click="gotoAnalyze()")
15 | {{ st.tr["Analyse"] }}
16 div(v-show="display=='rules'" v-html="content")
17 ComputerGame(v-show="display=='computer'" :game-info="gameInfo"
18 @game-over="stopGame" @game-stopped="gameStopped")
22 import ComputerGame from "@/components/ComputerGame.vue";
23 import { store } from "@/store";
24 import { getDiagram } from "@/utils/printDiagram";
34 gameInProgress: false,
35 // variables passed to ComputerGame:
45 $route: function(newRoute) {
46 this.re_setVariant(newRoute.params["vname"]);
50 // NOTE: variant cannot be set before store is initialized
51 this.re_setVariant(this.$route.params["vname"]);
55 if (!this.gameInfo.vname) return ""; //variant not set yet
56 // (AJAX) Request to get rules content (plain text, HTML)
58 require("raw-loader!@/translations/rules/" +
63 // Next two lines fix a weird issue after last update (2019-11)
66 .replace('module.exports = "', "")
68 .replace(/(fen:)([^:]*):/g, this.replaceByDiag)
73 clickReadRules: function() {
74 if (this.display != "rules") this.display = "rules";
75 else if (this.gameInProgress) this.display = "computer";
78 const fenParts = fen.split(" ");
80 position: fenParts[0],
82 orientation: fenParts[2],
86 // Method to replace diagrams in loaded HTML
87 replaceByDiag: function(match, p1, p2) {
88 const args = this.parseFen(p2);
89 return getDiagram(args);
91 re_setVariant: async function(vname) {
92 const vModule = await import("@/variants/" + vname + ".js");
93 window.V = vModule.VariantRules;
94 this.gameInfo.vname = vname;
96 startGame: function(mode) {
97 if (this.gameInProgress) return;
98 this.gameInProgress = true;
99 this.display = "computer";
100 this.gameInfo.mode = mode;
101 this.gameInfo.score = "*";
102 this.gameInfo.fen = V.GenRandInitFen();
104 // user is willing to stop the game:
105 stopGame: function(score) {
106 this.gameInfo.score = score || "?";
108 // The game is effectively stopped:
109 gameStopped: function() {
110 this.gameInProgress = false;
112 gotoAnalyze: function() {
114 "/analyse/" + this.gameInfo.vname + "/?fen=" + V.GenRandInitFen()
121 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
126 background-color: lightgrey
129 figure.diagram-container
130 margin: 15px 0 15px 0
142 margin-left: calc(10% - 20px)
144 @media screen and (max-width: 630px)
146 margin: 0 auto 10px auto
149 margin-right: calc(10% - 20px)
150 @media screen and (max-width: 630px)
160 background-color: #FFCC66
172 // To show (new) pieces, and/or there values...
173 figure.showPieces > img
176 figure.showPieces > figcaption
185 ol, ul:not(.browser-default)
188 ul:not(.browser-default)
191 ul:not(.browser-default) > li
192 list-style-type: disc