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" }],
37 vr: null, //"variant rules" object initialized from FEN
42 // NOTE: no watcher for $route change, because if fenStart doesn't change
43 // then it doesn't trigger BaseGame.re_init() and the result is weird.
44 "vr.movesCount": function() {
45 this.curFen = this.vr.getFen();
50 this.gameRef.vname = this.$route.params["vname"];
51 this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
55 initialize: async function() {
56 // Obtain VariantRules object
57 const vModule = await import("@/variants/" + this.gameRef.vname + ".js");
58 window.V = vModule.VariantRules;
61 loadGame: function() {
62 // NOTE: no need to set score (~unused)
63 this.game.vname = this.gameRef.vname;
64 this.game.fen = this.gameRef.fen;
65 this.curFen = this.game.fen;
67 this.vr = new V(this.game.fen);
68 this.game.mycolor = this.vr.turn;
69 this.$set(this.game, "fenStart", this.gameRef.fen);
71 adjustFenSize: function() {
72 let fenInput = document.getElementById("fen");
73 fenInput.style.width = this.curFen.length + "ch";
75 tryGotoFen: function() {
76 if (V.IsGoodFen(this.curFen))
78 this.gameRef.fen = this.curFen;