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 Game(v-show="display=='computer'" :gid-or-fen="fen"
14 :mode="mode" :sub-mode="subMode" :variant="variant"
15 @computer-think="gameInProgress=false" @game-over="stopGame")
19 import Game from "@/components/Game.vue";
20 import { store } from "@/store";
21 import { getDiagram } from "@/utils/printDiagram";
30 variant: {id: 0, name: "_unknown"}, //...yet
34 subMode: "", //'auto' for game CPU vs CPU
35 gameInProgress: false,
41 $route: function(newRoute) {
42 this.tryChangeVariant(newRoute.params["vname"]);
45 created: async function() {
46 // NOTE: variant cannot be set before store is initialized
47 this.tryChangeVariant(this.$route.params["vname"]);
51 const fenParts = fen.split(" ");
53 position: fenParts[0],
55 orientation: fenParts[2],
59 tryChangeVariant: async function(vname) {
60 if (vname == "_unknown")
62 if (this.st.variants.length > 0)
64 const idxOfVar = this.st.variants.findIndex(e => e.name == vname);
65 this.variant = this.st.variants[idxOfVar];
68 this.variant.name = vname;
69 const vModule = await import("@/variants/" + vname + ".js");
70 window.V = vModule.VariantRules;
71 // Method to replace diagrams in loaded HTML
72 const replaceByDiag = (match, p1, p2) => {
73 const args = this.parseFen(p2);
74 return getDiagram(args);
76 // (AJAX) Request to get rules content (plain text, HTML)
78 require("raw-loader!@/rules/" + vname + "/" + this.st.lang + ".pug")
79 .replace(/(fen:)([^:]*):/g, replaceByDiag);
81 startGame: function() {
82 if (this.gameInProgress)
84 this.gameInProgress = true;
85 this.mode = "computer";
86 this.display = "computer";
87 this.fen = V.GenRandInitFen();
89 stopGame: function() {
90 this.gameInProgress = false;
91 this.mode = "analyze";
93 playAgainstComputer: function() {
97 watchComputerGame: function() {
98 this.subMode = "auto";
109 background-color: lightgrey
112 figure.diagram-container
113 margin: 15px 0 15px 0
125 margin-left: calc(10% - 20px)
127 @media screen and (max-width: 630px)
129 margin: 0 auto 10px auto
132 margin-right: calc(10% - 20px)
133 @media screen and (max-width: 630px)
143 background-color: #FFCC66
149 // To show (new) pieces, and/or there values...
150 figure.showPieces > img
153 figure.showPieces > figcaption
162 ol, ul:not(.browser-default)
165 ul:not(.browser-default)
168 ul:not(.browser-default) > li
169 list-style-type: disc
172 background-color: #e5e5ca
175 background-color: #6f8f57
177 // TODO: following is duplicated
181 display: inline-block
186 padding-bottom: 12.5%
199 img.piece, img.mark-square
213 filter: brightness(50%)