{
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}) }
},
[
},
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) {
this.endGame(this.mycolor=="w"?"0-1":"1-0");
},
newGame: function(mode, fenInit, color, oppId) {
- const fen = fenInit || VariantRules.GenRandInitFen();
+ const fen = "nrqkbrnb/pppppppp/8/8/8/8/PPPPPPPP/RKQBNRBN w 1111 -";//fenInit || VariantRules.GenRandInitFen();
console.log(fen); //DEBUG
if (mode=="human" && !oppId)
{
return;
}
}
- else if (score == "*")
- return this.continueGame("computer");
}
}
else if (mode == "friend")
else if (mode == "computer")
{
this.compWorker.postMessage(["init",this.vr.getFen()]);
- this.mycolor = (Math.random() < 0.5 ? 'w' : 'b');
+ this.mycolor = "w";//(Math.random() < 0.5 ? 'w' : 'b');
if (this.mycolor != this.vr.turn)
this.playComputerMove();
}
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
if (["human","computer","friend"].includes(this.mode))
this.updateStorage(); //after our moves and opponent moves
if (this.mode == "computer" && this.vr.turn != this.mycolor && this.score == "*")
+ {
+ console.log(this.vr.moves.length + " " + this.vr.turn + " " + this.mycolor);
this.playComputerMove();
+ }
},
undo: function() {
// Navigate after game is over