6 input#fen(v-model="curFen" @input="adjustFenSize()")
7 button(@click="gotoFen()") {{ st.tr["Go"] }}
8 BaseGame(:game="game" :vr="vr" ref="basegame")
12 import BaseGame from "@/components/BaseGame.vue";
13 import { store } from "@/store";
14 import { ArrayFun } from "@/utils/array";
20 // gameRef: to find the game in (potentially remote) storage
24 gameRef: { //given in URL (rid = remote ID)
29 players:[{name:"Analyse"},{name:"Analyse"}],
32 vr: null, //"variant rules" object initialized from FEN
34 //people: [], //players + observers //TODO later: interactive analyze...
38 // NOTE: no watcher for $route change, because if fenStart doesn't change
39 // then it doesn't trigger BaseGame.re_init() and the result is weird.
40 "vr.movesCount": function(fen) {
41 this.curFen = this.vr.getFen();
46 this.gameRef.vname = this.$route.params["vname"];
47 if (this.gameRef.vname == "Dark")
49 alert(this.st.tr["Analyse in Dark mode makes no sense!"]);
50 history.back(); //or this.$router.go(-1)
54 this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
59 initialize: async function() {
60 // Obtain VariantRules object
61 const vModule = await import("@/variants/" + this.gameRef.vname + ".js");
62 window.V = vModule.VariantRules;
65 loadGame: function() {
66 // NOTE: no need to set score (~unused)
67 this.game.vname = this.gameRef.vname;
68 this.game.fen = this.gameRef.fen;
69 this.curFen = this.game.fen;
71 this.vr = new V(this.game.fen);
72 this.game.mycolor = this.vr.turn;
73 this.$set(this.game, "fenStart", this.gameRef.fen);
75 adjustFenSize: function() {
76 let fenInput = document.getElementById("fen");
77 fenInput.style.width = this.curFen.length + "ch";
80 this.gameRef.fen = this.curFen;