- const animate = (this.gameInfo.vname != "Dark");
- this.$refs.basegame.play(compMove[0], animate);
- if (compMove.length == 2)
- setTimeout( () => { this.$refs.basegame.play(compMove[1], animate); }, 750);
- else //250 == length of animation (TODO: should be a constant somewhere)
- setTimeout( () => this.lockCompThink = false, 250);
+ if (this.currentUrl != document.location.href) return; //page change
+ // NOTE: Dark and 2-moves are incompatible
+ const animate = this.gameInfo.vname != "Dark";
+ const animDelay = animate ? 250 : 0;
+ let moveIdx = 0;
+ let self = this;
+ (function executeMove() {
+ self.$set(self.game, "moveToPlay", compMove[moveIdx++]);
+ if (moveIdx >= compMove.length) {
+ self.compThink = false;
+ if (self.game.score != "*")
+ //user action
+ self.$emit("game-stopped");
+ } else setTimeout(executeMove, 500 + animDelay);
+ })();