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'"
14 :fen="fen" :mode="mode" :vname="variant.name"
15 @computer-think="gameInProgress=false" @game-over="stopGame")
19 import ComputerGame from "@/components/ComputerGame.vue";
20 import { store } from "@/store";
21 import { getDiagram } from "@/utils/printDiagram";
31 variant: {id: 0, name: "_unknown"}, //...yet
35 gameInProgress: false,
40 "$route": function(newRoute) {
41 this.tryChangeVariant(newRoute.params["vname"]);
44 created: async function() {
45 // NOTE: variant cannot be set before store is initialized
46 this.tryChangeVariant(this.$route.params["vname"]);
50 const fenParts = fen.split(" ");
52 position: fenParts[0],
54 orientation: fenParts[2],
58 tryChangeVariant: async function(vname) {
59 if (!vname || vname == "_unknown")
61 if (this.st.variants.length > 0)
63 const idxOfVar = this.st.variants.findIndex(e => e.name == vname);
64 this.variant = this.st.variants[idxOfVar];
67 this.variant.name = vname;
68 const vModule = await import("@/variants/" + vname + ".js");
69 window.V = vModule.VariantRules;
70 // Method to replace diagrams in loaded HTML
71 const replaceByDiag = (match, p1, p2) => {
72 const args = this.parseFen(p2);
73 return getDiagram(args);
75 // (AJAX) Request to get rules content (plain text, HTML)
77 require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
78 .replace(/(fen:)([^:]*):/g, replaceByDiag);
80 startGame: function() {
81 if (this.gameInProgress)
83 this.gameInProgress = true;
84 this.display = "computer";
85 this.fen = V.GenRandInitFen();
87 stopGame: function() {
88 this.gameInProgress = false;
89 this.mode = "analyze";
91 playAgainstComputer: function() {
95 watchComputerGame: function() {
107 background-color: lightgrey
110 figure.diagram-container
111 margin: 15px 0 15px 0
123 margin-left: calc(10% - 20px)
125 @media screen and (max-width: 630px)
127 margin: 0 auto 10px auto
130 margin-right: calc(10% - 20px)
131 @media screen and (max-width: 630px)
141 background-color: #FFCC66
147 // To show (new) pieces, and/or there values...
148 figure.showPieces > img
151 figure.showPieces > figcaption
160 ol, ul:not(.browser-default)
163 ul:not(.browser-default)
166 ul:not(.browser-default) > li
167 list-style-type: disc
170 background-color: #e5e5ca
173 background-color: #6f8f57
175 // TODO: following is duplicated
179 display: inline-block
184 padding-bottom: 12.5%
197 img.piece, img.mark-square
211 filter: brightness(50%)