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";
36 gameInProgress: false,
37 // variables passed to ComputerGame:
47 "$route": function(newRoute) {
48 this.tryChangeVariant(newRoute.params["vname"]);
51 created: async function() {
52 // NOTE: variant cannot be set before store is initialized
53 this.tryChangeVariant(this.$route.params["vname"]);
56 clickReadRules: function() {
57 if (this.display != "rules")
58 this.display = "rules";
59 else if (this.gameInProgress)
60 this.display = "computer";
63 const fenParts = fen.split(" ");
65 position: fenParts[0],
67 orientation: fenParts[2],
71 tryChangeVariant: async function(vname) {
72 if (!vname || vname == "_unknown")
74 this.gameInfo.vname = vname;
75 const vModule = await import("@/variants/" + vname + ".js");
76 window.V = vModule.VariantRules;
77 // Method to replace diagrams in loaded HTML
78 const replaceByDiag = (match, p1, p2) => {
79 const args = this.parseFen(p2);
80 return getDiagram(args);
82 // (AJAX) Request to get rules content (plain text, HTML)
84 require("raw-loader!@/translations/rules/" + vname + "/" + this.st.lang + ".pug")
85 // Next two lines fix a weird issue after last update (2019-11)
86 .replace(/\\n/g, " ").replace(/\\"/g, '"')
87 .replace('module.exports = "', '').replace(/"$/, "")
88 .replace(/(fen:)([^:]*):/g, replaceByDiag);
90 startGame: function(mode) {
91 if (this.gameInProgress)
93 this.gameInProgress = true;
94 this.display = "computer";
95 this.gameInfo.mode = mode;
96 this.gameInfo.score = "*";
97 this.gameInfo.fen = V.GenRandInitFen();
99 // user is willing to stop the game:
100 stopGame: function(score) {
101 this.gameInfo.score = score || "?";
103 // The game is effectively stopped:
104 gameStopped: function() {
105 this.gameInProgress = false;
107 gotoAnalyze: function() {
108 this.$router.push("/analyze/" + this.gameInfo.vname
109 + "/?fen=" + V.GenRandInitFen());
115 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
120 // margin-right: auto
122 // figure.diagram-container
124 // @media screen and (max-width: 767px)
131 background-color: lightgrey
134 figure.diagram-container
135 margin: 15px 0 15px 0
147 margin-left: calc(10% - 20px)
149 @media screen and (max-width: 630px)
151 margin: 0 auto 10px auto
154 margin-right: calc(10% - 20px)
155 @media screen and (max-width: 630px)
165 background-color: #FFCC66
171 // To show (new) pieces, and/or there values...
172 figure.showPieces > img
175 figure.showPieces > figcaption
184 ol, ul:not(.browser-default)
187 ul:not(.browser-default)
190 ul:not(.browser-default) > li
191 list-style-type: disc
194 background-color: #e5e5ca
197 background-color: #6f8f57
199 // TODO: following is duplicated (Board.vue)
203 display: inline-block
208 padding-bottom: 12.5%
221 img.piece, img.mark-square
235 filter: brightness(50%)