From: Benjamin Auder Date: Mon, 4 Feb 2019 22:01:08 +0000 (+0100) Subject: Reactivate game component, think about web(pack) worker X-Git-Url: https://git.auder.net/assets/doc/parser.js?a=commitdiff_plain;h=24340cae41e916d91088cc6988d8838b342a9c42;p=vchess.git Reactivate game component, think about web(pack) worker --- diff --git a/client/src/App.vue b/client/src/App.vue index 4ebc6e71..59b0371a 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -63,6 +63,10 @@ export default { st: store.state, }; }, +// // TODO: $route: ... +// gameRef: function() { +// this.loadGame(); +// }, }; diff --git a/client/src/components/Board.vue b/client/src/components/Board.vue index b7dac640..51632312 100644 --- a/client/src/components/Board.vue +++ b/client/src/components/Board.vue @@ -1,3 +1,4 @@ + diff --git a/client/src/playCompMove.js b/client/src/playCompMove.js index d6b0cea9..f58f9987 100644 --- a/client/src/playCompMove.js +++ b/client/src/playCompMove.js @@ -1,3 +1,5 @@ +// TODO: https://github.com/webpack-contrib/worker-loader +// https://stackoverflow.com/questions/48713072/how-to-get-js-function-into-webworker-via-importscripts // For asynchronous computer move search onmessage = function(e) { @@ -5,10 +7,10 @@ onmessage = function(e) { case "scripts": self.importScripts( - '/javascripts/base_rules.js', - '/javascripts/utils/array.js', - '/javascripts/variants/' + e.data[1] + '.js'); - self.V = eval(e.data[1] + "Rules"); + '@/base_rules.js', + '@/utils/array.js', + '@/variants/' + e.data[1] + '.js'); + self.V = eval("VariantRules"); break; case "init": const fen = e.data[1]; diff --git a/client/src/views/Rules.vue b/client/src/views/Rules.vue index 2cfd3318..1702b509 100644 --- a/client/src/views/Rules.vue +++ b/client/src/views/Rules.vue @@ -10,8 +10,8 @@ button(v-show="gameInProgress" @click="stopGame") | Stop game div(v-show="display=='rules'" v-html="content" class="section-content") - Game(v-show="display=='computer'" :mycolor="mycolor" :fen="fen" - :mode="mode" :sub-mode="subMode" + Game(v-show="display=='computer'" :mycolor="mycolor" :gid-or-fen="fen" + :mode="mode" :sub-mode="subMode" :variant="variant" @computer-think="gameInProgress=false" @game-over="stopGame") @@ -20,9 +20,13 @@ import Game from "@/components/Game.vue"; import { store } from "@/store"; export default { name: 'my-rules', + components: { + Game, + }, data: function() { return { st: store.state, + variant: null, content: "", display: "rules", mode: "computer", @@ -32,6 +36,11 @@ export default { fen: "", }; }, + created: function() { + const vname = this.$route.params["vname"]; + const idxOfVar = this.st.variants.indexOf(e => e.name == vname); + this.variant = this.st.variants[idxOfVar]; + }, mounted: function() { // Method to replace diagrams in loaded HTML const replaceByDiag = (match, p1, p2) => {