- 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);
+ 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);
+ })();