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'" :mycolor="mycolor" :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,
40 const vname = this.$route.params["vname"];
41 const idxOfVar = this.st.variants.indexOf(e => e.name == vname);
42 this.variant = this.st.variants[idxOfVar];
45 // Method to replace diagrams in loaded HTML
46 const replaceByDiag = (match, p1, p2) => {
47 const args = this.parseFen(p2);
48 return getDiagram(args);
50 // (AJAX) Request to get rules content (plain text, HTML)
52 require("raw-loader!pug-plain-loader!@/rules/" +
53 this.$route.params["vname"] + "/" + this.st.lang + ".pug")
54 .replace(/(fen:)([^:]*):/g, replaceByDiag);
58 const fenParts = fen.split(" ");
60 position: fenParts[0],
62 orientation: fenParts[2],
66 startGame: function() {
67 if (this.gameInProgress)
69 this.gameInProgress = true;
70 this.mode = "computer";
71 this.display = "computer";
72 this.fen = V.GenRandInitFen();
74 stopGame: function() {
75 this.gameInProgress = false;
76 this.mode = "analyze";
78 playAgainstComputer: function() {
82 watchComputerGame: function() {
83 this.subMode = "auto";