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 VariantRules(v-show="display=='rules'" :vname="variant.name")
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 VariantRules from "@/components/VariantRules";
31 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"]);
50 tryChangeVariant: async function(vname) {
51 if (vname == "_unknown")
53 if (this.st.variants.length > 0)
55 const idxOfVar = this.st.variants.findIndex(e => e.name == vname);
56 this.variant = this.st.variants[idxOfVar];
59 this.variant.name = vname;
60 const vModule = await import("@/variants/" + vname + ".js");
61 window.V = vModule.VariantRules;
63 startGame: function() {
64 if (this.gameInProgress)
66 this.gameInProgress = true;
67 this.mode = "computer";
68 this.display = "computer";
69 this.fen = V.GenRandInitFen();
71 stopGame: function() {
72 this.gameInProgress = false;
73 this.mode = "analyze";
75 playAgainstComputer: function() {
79 watchComputerGame: function() {
80 this.subMode = "auto";