3 .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2
5 button(@click="display='rules'") Read the rules
6 button(v-show="!gameInProgress" @click="() => startGame('auto')")
7 | Observe a sample game
8 button(v-show="!gameInProgress" @click="() => startGame('versus')")
10 button(v-show="gameInProgress" @click="stopGame")
12 .section-content(v-show="display=='rules'" v-html="content")
13 ComputerGame(v-show="display=='computer'" :game-info="gameInfo"
14 @computer-think="gameInProgress=false" @game-over="stopGame")
18 import ComputerGame from "@/components/ComputerGame.vue";
19 import { store } from "@/store";
20 import { getDiagram } from "@/utils/printDiagram";
32 gameInProgress: false,
33 // variables passed to ComputerGame:
43 "$route": function(newRoute) {
44 this.tryChangeVariant(newRoute.params["vname"]);
47 created: async function() {
48 // NOTE: variant cannot be set before store is initialized
49 this.tryChangeVariant(this.$route.params["vname"]);
53 const fenParts = fen.split(" ");
55 position: fenParts[0],
57 orientation: fenParts[2],
61 tryChangeVariant: async function(vname) {
62 if (!vname || vname == "_unknown")
64 this.gameInfo.vname = vname;
65 const vModule = await import("@/variants/" + vname + ".js");
66 window.V = vModule.VariantRules;
67 // Method to replace diagrams in loaded HTML
68 const replaceByDiag = (match, p1, p2) => {
69 const args = this.parseFen(p2);
70 return getDiagram(args);
72 // (AJAX) Request to get rules content (plain text, HTML)
74 require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
75 .replace(/(fen:)([^:]*):/g, replaceByDiag);
77 startGame: function(mode) {
78 if (this.gameInProgress)
80 this.gameInProgress = true;
81 this.display = "computer";
82 this.gameInfo.mode = mode;
83 this.gameInfo.userStop = false;
84 this.gameInfo.fen = V.GenRandInitFen();
86 stopGame: function() {
87 this.gameInProgress = false;
88 this.gameInfo.userStop = true;
89 this.gameInfo.mode = "analyze";
99 background-color: lightgrey
102 figure.diagram-container
103 margin: 15px 0 15px 0
115 margin-left: calc(10% - 20px)
117 @media screen and (max-width: 630px)
119 margin: 0 auto 10px auto
122 margin-right: calc(10% - 20px)
123 @media screen and (max-width: 630px)
133 background-color: #FFCC66
139 // To show (new) pieces, and/or there values...
140 figure.showPieces > img
143 figure.showPieces > figcaption
152 ol, ul:not(.browser-default)
155 ul:not(.browser-default)
158 ul:not(.browser-default) > li
159 list-style-type: disc
162 background-color: #e5e5ca
165 background-color: #6f8f57
167 // TODO: following is duplicated
171 display: inline-block
176 padding-bottom: 12.5%
189 img.piece, img.mark-square
203 filter: brightness(50%)