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="watchComputerGame")
7 | Observe a sample game
8 button(v-show="!gameInProgress" @click="playAgainstComputer")
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:
40 gameInfo: function() {
49 "$route": function(newRoute) {
50 this.tryChangeVariant(newRoute.params["vname"]);
53 created: async function() {
54 // NOTE: variant cannot be set before store is initialized
55 this.tryChangeVariant(this.$route.params["vname"]);
59 const fenParts = fen.split(" ");
61 position: fenParts[0],
63 orientation: fenParts[2],
67 tryChangeVariant: async function(vname) {
68 if (!vname || vname == "_unknown")
71 const vModule = await import("@/variants/" + vname + ".js");
72 window.V = vModule.VariantRules;
73 // Method to replace diagrams in loaded HTML
74 const replaceByDiag = (match, p1, p2) => {
75 const args = this.parseFen(p2);
76 return getDiagram(args);
78 // (AJAX) Request to get rules content (plain text, HTML)
80 require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
81 .replace(/(fen:)([^:]*):/g, replaceByDiag);
83 startGame: function() {
84 if (this.gameInProgress)
86 this.gameInProgress = true;
87 this.display = "computer";
88 this.fen = V.GenRandInitFen();
90 stopGame: function() {
91 this.gameInProgress = false;
92 this.mode = "analyze";
94 playAgainstComputer: function() {
98 watchComputerGame: function() {
110 background-color: lightgrey
113 figure.diagram-container
114 margin: 15px 0 15px 0
126 margin-left: calc(10% - 20px)
128 @media screen and (max-width: 630px)
130 margin: 0 auto 10px auto
133 margin-right: calc(10% - 20px)
134 @media screen and (max-width: 630px)
144 background-color: #FFCC66
150 // To show (new) pieces, and/or there values...
151 figure.showPieces > img
154 figure.showPieces > figcaption
163 ol, ul:not(.browser-default)
166 ul:not(.browser-default)
169 ul:not(.browser-default) > li
170 list-style-type: disc
173 background-color: #e5e5ca
176 background-color: #6f8f57
178 // TODO: following is duplicated
182 display: inline-block
187 padding-bottom: 12.5%
200 img.piece, img.mark-square
214 filter: brightness(50%)