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"] }}
8 v-show="!gameInProgress"
9 @click="startGame('auto')"
11 | {{ st.tr["Example game"] }}
13 v-show="!gameInProgress"
14 @click="startGame('versus')"
16 | {{ st.tr["Practice"] }}
18 v-show="gameInProgress"
21 | {{ st.tr["Stop game"] }}
23 v-if="display=='rules' && gameInfo.vname!='Dark'"
24 @click="gotoAnalyze()"
26 | {{ st.tr["Analyse"] }}
28 v-show="display=='rules'"
32 v-show="display=='computer'"
35 @game-stopped="gameStopped"
40 import ComputerGame from "@/components/ComputerGame.vue";
41 import { store } from "@/store";
42 import { getDiagram } from "@/utils/printDiagram";
52 gameInProgress: false,
53 // variables passed to ComputerGame:
63 $route: function(newRoute) {
64 this.re_setVariant(newRoute.params["vname"]);
68 // NOTE: variant cannot be set before store is initialized
69 this.re_setVariant(this.$route.params["vname"]);
73 if (!this.gameInfo.vname) return ""; //variant not set yet
74 // (AJAX) Request to get rules content (plain text, HTML)
76 require("raw-loader!@/translations/rules/" +
81 // Next two lines fix a weird issue after last update (2019-11)
84 .replace('module.exports = "', "")
86 .replace(/(fen:)([^:]*):/g, this.replaceByDiag)
91 clickReadRules: function() {
92 if (this.display != "rules") this.display = "rules";
93 else if (this.gameInProgress) this.display = "computer";
96 const fenParts = fen.split(" ");
98 position: fenParts[0],
100 orientation: fenParts[2],
104 // Method to replace diagrams in loaded HTML
105 replaceByDiag: function(match, p1, p2) {
106 const args = this.parseFen(p2);
107 return getDiagram(args);
109 re_setVariant: async function(vname) {
110 const vModule = await import("@/variants/" + vname + ".js");
111 window.V = vModule.VariantRules;
112 this.gameInfo.vname = vname;
114 startGame: function(mode) {
115 if (this.gameInProgress) return;
116 this.gameInProgress = true;
117 this.display = "computer";
118 this.gameInfo.mode = mode;
119 this.gameInfo.score = "*";
120 this.gameInfo.fen = V.GenRandInitFen();
122 // user is willing to stop the game:
123 stopGame: function(score) {
124 this.gameInfo.score = score || "?";
126 // The game is effectively stopped:
127 gameStopped: function() {
128 this.gameInProgress = false;
130 gotoAnalyze: function() {
132 "/analyse/" + this.gameInfo.vname + "/?fen=" + V.GenRandInitFen()
139 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
144 background-color: lightgrey
147 figure.diagram-container
148 margin: 15px 0 15px 0
160 margin-left: calc(10% - 20px)
162 @media screen and (max-width: 630px)
164 margin: 0 auto 10px auto
167 margin-right: calc(10% - 20px)
168 @media screen and (max-width: 630px)
178 background-color: #FFCC66
190 // To show (new) pieces, and/or there values...
191 figure.showPieces > img
194 figure.showPieces > figcaption
203 ol, ul:not(.browser-default)
206 ul:not(.browser-default)
209 ul:not(.browser-default) > li
210 list-style-type: disc