8 @input="adjustFenSize(); tryGotoFen()"
17 import BaseGame from "@/components/BaseGame.vue";
18 import { store } from "@/store";
24 // gameRef: to find the game in (potentially remote) storage
29 //given in URL (rid = remote ID)
34 players: [{ name: "Analyse" }, { name: "Analyse" }],
40 // NOTE: no watcher for $route change, because if fenStart doesn't change
41 // then it doesn't trigger BaseGame.re_init() and the result is weird.
43 this.gameRef.vname = this.$route.params["vname"];
44 this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
48 initialize: async function() {
49 // Obtain VariantRules object
50 const vModule = await import("@/variants/" + this.gameRef.vname + ".js");
51 window.V = vModule.VariantRules;
54 loadGame: function() {
55 // NOTE: no need to set score (~unused)
56 this.game.vname = this.gameRef.vname;
57 this.game.fen = this.gameRef.fen;
58 this.curFen = this.game.fen;
60 this.game.mycolor = V.ParseFen(this.gameRef.fen).turn;
61 this.$set(this.game, "fenStart", this.gameRef.fen);
63 // Triggered by "fenchange" emitted in BaseGame:
64 setFen: function(fen) {
68 adjustFenSize: function() {
69 let fenInput = document.getElementById("fen");
70 fenInput.style.width = this.curFen.length + "ch";
72 tryGotoFen: function() {
73 if (V.IsGoodFen(this.curFen))
75 this.gameRef.fen = this.curFen;