+ processMove: function(move) {
+ if (this.game.score != "*") return;
+ // Send the move to web worker (including his own moves)
+ this.compWorker.postMessage(["newmove", move]);
+ // subTurn condition for Marseille (and Avalanche) rules
+ if (
+ (!this.vr.subTurn || this.vr.subTurn <= 1) &&
+ (this.gameInfo.mode == "auto" || this.vr.turn != this.game.mycolor)
+ ) {
+ this.playComputerMove();
+ }
+ // Finally, update storage:
+ if (this.gameInfo.mode == "versus") {
+ const allowed_fields = ["appear", "vanish", "start", "end"];
+ const filtered_move = Object.keys(move)
+ .filter(key => allowed_fields.includes(key))
+ .reduce((obj, key) => {
+ obj[key] = move[key];
+ return obj;
+ }, {});
+ CompgameStorage.update(this.gameInfo.vname, {
+ move: filtered_move,
+ fen: move.fen
+ });
+ }
+ },
+ gameOver: function(score, scoreMsg) {
+ this.game.score = score;
+ this.game.scoreMsg = scoreMsg;
+ if (!this.compThink) this.$emit("game-stopped"); //otherwise wait for comp
+ }
+ }