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)
56 return ""; //variant not set yet
57 // (AJAX) Request to get rules content (plain text, HTML)
58 return require("raw-loader!@/translations/rules/" +
59 this.gameInfo.vname + "/" + this.st.lang + ".pug")
60 // Next two lines fix a weird issue after last update (2019-11)
61 .replace(/\\n/g, " ").replace(/\\"/g, '"')
62 .replace('module.exports = "', '').replace(/"$/, "")
63 .replace(/(fen:)([^:]*):/g, this.replaceByDiag);
67 clickReadRules: function() {
68 if (this.display != "rules")
69 this.display = "rules";
70 else if (this.gameInProgress)
71 this.display = "computer";
74 const fenParts = fen.split(" ");
76 position: fenParts[0],
78 orientation: fenParts[2],
82 // Method to replace diagrams in loaded HTML
83 replaceByDiag: function(match, p1, p2) {
84 const args = this.parseFen(p2);
85 return getDiagram(args);
87 re_setVariant: async function(vname) {
88 const vModule = await import("@/variants/" + vname + ".js");
89 window.V = vModule.VariantRules;
90 this.gameInfo.vname = vname;
92 startGame: function(mode) {
93 if (this.gameInProgress)
95 this.gameInProgress = true;
96 this.display = "computer";
97 this.gameInfo.mode = mode;
98 this.gameInfo.score = "*";
99 this.gameInfo.fen = V.GenRandInitFen();
101 // user is willing to stop the game:
102 stopGame: function(score) {
103 this.gameInfo.score = score || "?";
105 // The game is effectively stopped:
106 gameStopped: function() {
107 this.gameInProgress = false;
109 gotoAnalyze: function() {
110 this.$router.push("/analyse/" + this.gameInfo.vname
111 + "/?fen=" + V.GenRandInitFen());
117 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
122 background-color: lightgrey
125 figure.diagram-container
126 margin: 15px 0 15px 0
138 margin-left: calc(10% - 20px)
140 @media screen and (max-width: 630px)
142 margin: 0 auto 10px auto
145 margin-right: calc(10% - 20px)
146 @media screen and (max-width: 630px)
156 background-color: #FFCC66
168 // To show (new) pieces, and/or there values...
169 figure.showPieces > img
172 figure.showPieces > figcaption
181 ol, ul:not(.browser-default)
184 ul:not(.browser-default)
187 ul:not(.browser-default) > li
188 list-style-type: disc
191 background-color: #e5e5ca
194 background-color: #6f8f57
196 // TODO: following is duplicated (Board.vue)
200 display: inline-block
205 padding-bottom: 12.5%
218 img.piece, img.mark-square
232 filter: brightness(50%)