Some advances. TODO: test board.js, and then game.js, and then implement room.js
[vchess.git] / public / javascripts / components / game.js
index 39c12c0..ca79125 100644 (file)
@@ -4,7 +4,7 @@
 // Game logic on a variant page: 3 modes, analyze, computer or human
 Vue.component('my-game', {
        // gameId: to find the game in storage (assumption: it exists)
-       props: ["gameId","mode","allowChat","allowMovelist"],
+       props: ["gameId","fen","mode","allowChat","allowMovelist"],
        data: function() {
                return {
                        // if oppid == "computer" then mode = "computer" (otherwise human)
@@ -24,6 +24,11 @@ Vue.component('my-game', {
                        vr: null, //VariantRules object, describing the game state + rules
                };
        },
+       watch: {
+               fen: function(newFen) {
+                       this.vr = new VariantRules(newFen);
+               },
+       },
        computed: {
                showChat: function() {
                        return this.allowChat && this.mode=='human' && this.score != '*';