- this.$refs.basegame.play(compMove[0], animate);
- const waitEndOfAnimation = () => {
- // 250ms = length of animation (TODO: some constant somewhere)
- setTimeout( () => {
-console.log("RESET: " + this.compThink);
- this.compThink = false;
- if (this.game.score != "*") //user action
- this.$emit("game-stopped");
- }, animate ? 250 : 0);
- };
- if (compMove.length == 2)
- {
- setTimeout( () => {
- this.$refs.basegame.play(compMove[1], animate);
- waitEndOfAnimation();
- }, 750);
- }
- else
- waitEndOfAnimation();
+ const animDelay = (animate ? 250 : 0);
+ let moveIdx = 0;
+ let self = this;
+ (function executeMove() {
+ self.$refs.basegame.play(compMove[moveIdx++], animate);
+ if (moveIdx >= compMove.length)
+ {
+ self.compThink = false;
+ if (self.game.score != "*") //user action
+ self.$emit("game-stopped");
+ }
+ else
+ setTimeout(executeMove, 500 + animDelay);
+ })();