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" :fen="fen"
14 :mode="mode" :sub-mode="subMode"
15 @computer-think="gameInProgress=false" @game-over="stopGame")
19 import Game from "@/components/Game.vue";
20 import { store } from "@/store";
29 subMode: "", //'auto' for game CPU vs CPU
30 gameInProgress: false,
36 // Method to replace diagrams in loaded HTML
37 const replaceByDiag = (match, p1, p2) => {
38 const args = this.parseFen(p2);
39 return getDiagram(args);
41 // (AJAX) Request to get rules content (plain text, HTML)
43 require("raw-loader!pug-plain-loader!@/rules/" +
44 this.$route.params["vname"] + "/" + this.st.lang + ".pug")
45 .replace(/(fen:)([^:]*):/g, replaceByDiag);
49 const fenParts = fen.split(" ");
51 position: fenParts[0],
53 orientation: fenParts[2],
57 startGame: function() {
58 if (this.gameInProgress)
60 this.gameInProgress = true;
61 this.mode = "computer";
62 this.display = "computer";
63 this.fen = V.GenRandInitFen();
65 stopGame: function() {
66 this.gameInProgress = false;
67 this.mode = "analyze";
69 playAgainstComputer: function() {
73 watchComputerGame: function() {
74 this.subMode = "auto";