X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FRules.vue;h=74c4e84248d7de1c7e3df159ebd00969ff116be0;hp=738e25fa3572630e4f4ea5c90a94d03be66353dd;hb=6dd02928259482332d639bb71d2c44ff684fcfb5;hpb=d6c1bf3726afae94867854dda76df2848770068c diff --git a/client/src/views/Rules.vue b/client/src/views/Rules.vue index 738e25fa..74c4e842 100644 --- a/client/src/views/Rules.vue +++ b/client/src/views/Rules.vue @@ -10,8 +10,7 @@ button(v-show="gameInProgress" @click="stopGame") | Stop game .section-content(v-show="display=='rules'" v-html="content") - ComputerGame(v-show="display=='computer'" - :fen="fen" :mode="mode" :vname="variant.name" + ComputerGame(v-show="display=='computer'" :game-info="gameInfo" @computer-think="gameInProgress=false" @game-over="stopGame") @@ -28,14 +27,24 @@ export default { data: function() { return { st: store.state, - variant: {id: 0, name: "_unknown"}, //...yet content: "", display: "rules", - mode: "versus", gameInProgress: false, + // variables passed to ComputerGame: + vname: "_unknown", + mode: "versus", fen: "", }; }, + computed: { + gameInfo: function() { + return { + fen: this.fen, + mode: this.mode, + vname: this.vname, + }; + }, + }, watch: { "$route": function(newRoute) { this.tryChangeVariant(newRoute.params["vname"]); @@ -58,13 +67,7 @@ export default { tryChangeVariant: async function(vname) { if (!vname || vname == "_unknown") return; - if (this.st.variants.length > 0) - { - const idxOfVar = this.st.variants.findIndex(e => e.name == vname); - this.variant = this.st.variants[idxOfVar]; - } - else - this.variant.name = vname; + this.vname = vname; const vModule = await import("@/variants/" + vname + ".js"); window.V = vModule.VariantRules; // Method to replace diagrams in loaded HTML