},
[h('i', { 'class': { "material-icons": true } }, "accessibility")])
);
- if (variant != "Dark" &&
- (["idle","computer","friend"].includes(this.mode)
- || ["friend","human"].includes(this.mode) && this.score != "*"))
+ if (["idle","computer","friend"].includes(this.mode)
+ || (this.mode == "human" && this.score != "*"))
{
actionArray.push(
h('button',
[h('i', { 'class': { "material-icons": true } }, "computer")])
);
}
- if (variant != "Dark" &&
- (["idle","friend"].includes(this.mode)
- || ["computer","human"].includes(this.mode) && this.score != "*"))
+ if (variant != "Dark" && (["idle","friend"].includes(this.mode)
+ || (["computer","human"].includes(this.mode) && this.score != "*")))
{
actionArray.push(
h('button',
{
myReservePiecesArray.push(h('div',
{
- 'class': {'board':true, ['board'+sizeY+'-reserve']:true},
+ 'class': {'board':true, ['board'+sizeY]:true},
attrs: { id: this.getSquareId({x:sizeX+shiftIdx,y:i}) }
},
[
{
oppReservePiecesArray.push(h('div',
{
- 'class': {'board':true, ['board'+sizeY+'-reserve']:true},
+ 'class': {'board':true, ['board'+sizeY]:true},
attrs: { id: this.getSquareId({x:sizeX+(1-shiftIdx),y:i}) }
},
[
// before they appear on page:
const delay = Math.max(500-(Date.now()-self.timeStart), 0);
setTimeout(() => {
+ const animate = (variant!="Dark" ? "animate" : null);
if (self.mode == "computer") //warning: mode could have changed!
- self.play(compMove[0], "animate");
+ self.play(compMove[0], animate);
if (compMove.length == 2)
setTimeout( () => {
if (self.mode == "computer")
- self.play(compMove[1], "animate");
+ self.play(compMove[1], animate);
}, 750);
}, delay);
}
},
clickComputerGame: function(e) {
this.getRidOfTooltip(e.currentTarget);
+ if (this.mode == "computer" && this.score == "*"
+ && this.vr.turn != this.mycolor)
+ {
+ // Wait for computer reply first (avoid potential "ghost move" bug)
+ return;
+ }
this.newGame("computer");
},
clickFriendGame: function(e) {
return;
}
}
- else if (score == "*")
- return this.continueGame("computer");
}
}
else if (mode == "friend")
else if (mode == "computer")
{
this.compWorker.postMessage(["init",fen]);
- if (this.mycolor != this.vr.turn)
+ if (score == "*" && this.mycolor != this.vr.turn)
this.playComputerMove();
}
//else: nothing special to do in friend mode