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'"
15 | {{ st.tr["Analyze"] }}
16 .section-content(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";
35 gameInProgress: false,
36 // variables passed to ComputerGame:
46 "$route": function(newRoute) {
47 this.re_setVariant(newRoute.params["vname"]);
50 created: async function() {
51 // NOTE: variant cannot be set before store is initialized
52 this.re_setVariant(this.$route.params["vname"]);
56 if (!this.gameInfo.vname)
57 return ""; //variant not set yet
58 // (AJAX) Request to get rules content (plain text, HTML)
59 return require("raw-loader!@/translations/rules/" +
60 this.gameInfo.vname + "/" + this.st.lang + ".pug")
61 // Next two lines fix a weird issue after last update (2019-11)
62 .replace(/\\n/g, " ").replace(/\\"/g, '"')
63 .replace('module.exports = "', '').replace(/"$/, "")
64 .replace(/(fen:)([^:]*):/g, this.replaceByDiag);
68 clickReadRules: function() {
69 if (this.display != "rules")
70 this.display = "rules";
71 else if (this.gameInProgress)
72 this.display = "computer";
75 const fenParts = fen.split(" ");
77 position: fenParts[0],
79 orientation: fenParts[2],
83 // Method to replace diagrams in loaded HTML
84 replaceByDiag: function(match, p1, p2) {
85 const args = this.parseFen(p2);
86 return getDiagram(args);
88 re_setVariant: async function(vname) {
89 const vModule = await import("@/variants/" + vname + ".js");
90 window.V = vModule.VariantRules;
91 this.gameInfo.vname = vname;
93 startGame: function(mode) {
94 if (this.gameInProgress)
96 this.gameInProgress = true;
97 this.display = "computer";
98 this.gameInfo.mode = mode;
99 this.gameInfo.score = "*";
100 this.gameInfo.fen = V.GenRandInitFen();
102 // user is willing to stop the game:
103 stopGame: function(score) {
104 this.gameInfo.score = score || "?";
106 // The game is effectively stopped:
107 gameStopped: function() {
108 this.gameInProgress = false;
110 gotoAnalyze: function() {
111 this.$router.push("/analyze/" + this.gameInfo.vname
112 + "/?fen=" + V.GenRandInitFen());
118 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
123 // margin-right: auto
125 // figure.diagram-container
127 // @media screen and (max-width: 767px)
134 background-color: lightgrey
137 figure.diagram-container
138 margin: 15px 0 15px 0
150 margin-left: calc(10% - 20px)
152 @media screen and (max-width: 630px)
154 margin: 0 auto 10px auto
157 margin-right: calc(10% - 20px)
158 @media screen and (max-width: 630px)
168 background-color: #FFCC66
174 // To show (new) pieces, and/or there values...
175 figure.showPieces > img
178 figure.showPieces > figcaption
187 ol, ul:not(.browser-default)
190 ul:not(.browser-default)
193 ul:not(.browser-default) > li
194 list-style-type: disc
197 background-color: #e5e5ca
200 background-color: #6f8f57
202 // TODO: following is duplicated (Board.vue)
206 display: inline-block
211 padding-bottom: 12.5%
224 img.piece, img.mark-square
238 filter: brightness(50%)