d1b669ecb164b2fa5d59587900e48e4a6c83de56
[vchess.git] / client / src / views / Analyze.vue
1 <template lang="pug">
2 main
3 BaseGame(:game="game" :vr="vr" ref="basegame")
4 </template>
5
6 <script>
7 import BaseGame from "@/components/BaseGame.vue";
8 import { store } from "@/store";
9 import { ArrayFun } from "@/utils/array";
10
11 export default {
12 name: 'my-analyze',
13 components: {
14 BaseGame,
15 },
16 // gameRef: to find the game in (potentially remote) storage
17 data: function() {
18 return {
19 st: store.state,
20 gameRef: { //given in URL (rid = remote ID)
21 vname: "",
22 fen: ""
23 },
24 game: {
25 players:[{name:"Analyze"},{name:"Analyze"}],
26 mode: "analyze"
27 },
28 vr: null, //"variant rules" object initialized from FEN
29 //people: [], //players + observers //TODO later: interactive analyze...
30 };
31 },
32 watch: {
33 "$route": function(to, from) {
34 this.gameRef.fen = to.query["fen"].replace(/_/g, " ");
35 this.gameRef.vname = to.params["vname"];
36 this.loadGame();
37 },
38 },
39 created: function() {
40 this.gameRef.fen = this.$route.query["fen"].replace(/_/g, " ");
41 this.gameRef.vname = this.$route.params["vname"];
42 this.loadGame();
43 },
44 methods: {
45 loadGame: async function() {
46 this.game.vname = this.gameRef.vname;
47 this.game.fen = this.gameRef.fen;
48 const vModule = await import("@/variants/" + this.game.vname + ".js");
49 window.V = vModule.VariantRules;
50 this.vr = new V(this.game.fen);
51 },
52 },
53 };
54 </script>
55
56 <style lang="sass">
57 // TODO
58 </style>