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"] }}
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"]);
72 showAnalyzeBtn: function() {
73 return (this.display=='rules' && (!window.V || V.CanAnalyse));
76 if (!this.gameInfo.vname) return ""; //variant not set yet
77 // (AJAX) Request to get rules content (plain text, HTML)
79 require("raw-loader!@/translations/rules/" +
84 // Next two lines fix a weird issue after last update (2019-11)
87 .replace('module.exports = "', "")
89 .replace(/(fen:)([^:]*):/g, this.replaceByDiag)
94 clickReadRules: function() {
95 if (this.display != "rules") this.display = "rules";
96 else if (this.gameInProgress) this.display = "computer";
99 const fenParts = fen.split(" ");
101 position: fenParts[0],
103 orientation: fenParts[2],
107 // Method to replace diagrams in loaded HTML
108 replaceByDiag: function(match, p1, p2) {
109 const args = this.parseFen(p2);
110 return getDiagram(args);
112 re_setVariant: async function(vname) {
113 const vModule = await import("@/variants/" + vname + ".js");
114 window.V = vModule.VariantRules;
115 this.gameInfo.vname = vname;
117 startGame: function(mode) {
118 if (this.gameInProgress) return;
119 this.gameInProgress = true;
120 this.display = "computer";
121 this.gameInfo.mode = mode;
122 this.gameInfo.score = "*";
123 this.gameInfo.fen = V.GenRandInitFen();
125 // user is willing to stop the game:
126 stopGame: function(score) {
127 this.gameInfo.score = score || "?";
129 // The game is effectively stopped:
130 gameStopped: function() {
131 this.gameInProgress = false;
133 gotoAnalyze: function() {
135 "/analyse/" + this.gameInfo.vname + "/?fen=" + V.GenRandInitFen()
142 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
147 background-color: lightgrey
150 figure.diagram-container
151 margin: 15px 0 15px 0
163 margin-left: calc(10% - 20px)
165 @media screen and (max-width: 630px)
167 margin: 0 auto 10px auto
170 margin-right: calc(10% - 20px)
171 @media screen and (max-width: 630px)
181 background-color: #FFCC66
193 // To show (new) pieces, and/or there values...
194 figure.showPieces > img
197 figure.showPieces > figcaption
206 ol, ul:not(.browser-default)
209 ul:not(.browser-default)
212 ul:not(.browser-default) > li
213 list-style-type: disc