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 div(v-show="display=='rules'" v-html="content" class="section-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";
33 subMode: "", //'auto' for game CPU vs CPU
34 gameInProgress: false,
39 // TODO: variant is initialized before store initializes, so remain null (I think)
41 const vname = this.$route.params["vname"];
42 const idxOfVar = this.st.variants.indexOf(e => e.name == vname);
43 this.variant = this.st.variants[idxOfVar];
46 // Method to replace diagrams in loaded HTML
47 const replaceByDiag = (match, p1, p2) => {
48 const args = this.parseFen(p2);
49 return getDiagram(args);
51 // (AJAX) Request to get rules content (plain text, HTML)
53 // TODO: why doesn't this work? require("raw-loader!pug-plain-loader!@/rules/"...)
54 require("raw-loader!@/rules/" +
55 this.$route.params["vname"] + "/" + this.st.lang + ".pug")
56 .replace(/(fen:)([^:]*):/g, replaceByDiag);
60 const fenParts = fen.split(" ");
62 position: fenParts[0],
64 orientation: fenParts[2],
68 startGame: function() {
69 if (this.gameInProgress)
71 this.gameInProgress = true;
72 this.mode = "computer";
73 this.display = "computer";
74 this.fen = V.GenRandInitFen();
76 stopGame: function() {
77 this.gameInProgress = false;
78 this.mode = "analyze";
80 playAgainstComputer: function() {
84 watchComputerGame: function() {
85 this.subMode = "auto";