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