<template lang="pug">
BaseGame(
+ ref="basegame"
:game="game"
:vr="vr"
@newmove="processMove"
"gameInfo.fen": function() {
this.launchGame();
},
- "gameInfo.score": function(newScore) {
- if (newScore != "*") {
- this.game.score = newScore; //user action
- if (!this.compThink) this.$emit("game-stopped"); //otherwise wait for comp
- }
- }
},
- // Modal end of game, and then sub-components
created: function() {
// Computer moves web worker logic:
this.compWorker = new Worker();
let moveIdx = 0;
let self = this;
(function executeMove() {
- self.$set(self.game, "moveToPlay", compMove[moveIdx++]);
+ self.$refs["basegame"].play(compMove[moveIdx++], "received");
if (moveIdx >= compMove.length) {
self.compThink = false;
if (self.game.score != "*")
if (mycolor != "w" || this.gameInfo.mode == "auto")
this.playComputerMove();
},
+ // NOTE: a "goto" action could lead to an error when comp is thinking,
+ // but it's OK because from the user viewpoint the game just stops.
playComputerMove: function() {
this.timeStart = Date.now();
this.compThink = true;
gameOver: function(score, scoreMsg) {
this.game.score = score;
this.game.scoreMsg = scoreMsg;
- this.$emit("game-over", score); //bubble up to Rules.vue
+ if (!this.compThink) this.$emit("game-stopped"); //otherwise wait for comp
}
}
};