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["Analysis mode"] }}
28 .col-sm-12.col-md-8.col-md-offset-2.col-lg-6.col-lg-offset-3
30 v-show="display=='rules'"
35 v-show="display=='computer'"
37 @game-stopped="gameStopped"
42 import ComputerGame from "@/components/ComputerGame.vue";
43 import { store } from "@/store";
44 import { getDiagram } from "@/utils/printDiagram";
45 import { CompgameStorage } from "@/utils/compgameStorage";
55 gameInProgress: false,
56 // variables passed to ComputerGame:
65 $route: function(newRoute) {
66 this.re_setVariant(newRoute.params["vname"]);
70 // NOTE: variant cannot be set before store is initialized
71 this.re_setVariant(this.$route.params["vname"]);
74 showAnalyzeBtn: function() {
75 return this.V && this.V.CanAnalyze;
78 if (!this.gameInfo.vname) return ""; //variant not set yet
79 // (AJAX) Request to get rules content (plain text, HTML)
81 require("raw-loader!@/translations/rules/" +
86 // Next two lines fix a weird issue after last update (2019-11)
89 .replace('module.exports = "', "")
91 .replace(/(fen:)([^:]*):/g, this.replaceByDiag)
96 clickReadRules: function() {
97 if (this.display != "rules") this.display = "rules";
98 else if (this.gameInProgress) this.display = "computer";
101 const fenParts = fen.split(" ");
103 position: fenParts[0],
105 orientation: fenParts[2],
109 // Method to replace diagrams in loaded HTML
110 replaceByDiag: function(match, p1, p2) {
111 const args = this.parseFen(p2);
112 return getDiagram(args);
114 re_setVariant: async function(vname) {
115 const vModule = await import("@/variants/" + vname + ".js");
116 this.V = window.V = vModule.VariantRules;
117 this.gameInfo.vname = vname;
119 startGame: function(mode) {
120 if (this.gameInProgress) return;
121 this.gameInProgress = true;
122 this.display = "computer";
123 this.gameInfo.mode = mode;
124 if (this.gameInfo.mode == "versus") {
125 CompgameStorage.get(this.gameInfo.vname, (game) => {
126 // NOTE: game might be null
127 this.$refs["compgame"].launchGame(game);
130 this.$refs["compgame"].launchGame();
133 // user wants to stop the game:
134 stopGame: function() {
135 this.$refs["compgame"].gameOver("?", "Undetermined result");
137 // The game is effectively stopped:
138 gameStopped: function() {
139 this.gameInProgress = false;
140 if (this.gameInfo.mode == "versus")
141 CompgameStorage.remove(this.gameInfo.vname);
143 gotoAnalyze: function() {
145 "/analyse/" + this.gameInfo.vname + "/?fen=" + V.GenRandInitFen()
152 <!-- NOTE: not scoped here, because HTML is injected (TODO) -->
157 background-color: lightgrey
160 figure.diagram-container
161 margin: 15px 0 15px 0
173 margin-left: calc(10% - 20px)
175 @media screen and (max-width: 630px)
177 margin: 0 auto 10px auto
180 margin-right: calc(10% - 20px)
181 @media screen and (max-width: 630px)
191 background-color: #FFCC66
203 // To show (new) pieces, and/or there values...
204 figure.showPieces > img
207 figure.showPieces > figcaption
216 ol, ul:not(.browser-default)
219 ul:not(.browser-default)
222 ul:not(.browser-default) > li
223 list-style-type: disc