added stop ai worker method

This commit is contained in:
mig 2017-04-04 23:35:05 +02:00
parent 7bc110655e
commit 009ee46a62

View file

@ -414,7 +414,7 @@ JocGame.prototype.GetWho = function() {
}
JocGame.prototype.HumanTurn = function() {
if(this.mBoard.mMoves.length==0) {
if(!this.mBoard.mMoves || this.mBoard.mMoves.length==0) {
this.mCurrentLevel=-1;
this.mBoard.GenerateMoves(this);
}
@ -583,6 +583,17 @@ JocGame.prototype.StartThreadedMachine = function(aOptions,algo) {
});
}
JocGame.prototype.StopThreadedMachine = function() {
if(this.aiWorker) {
try {
this.aiWorker.terminate();
delete this.aiWorker;
} catch(e) {
console.warn("Cannot terminate worker",e);
}
}
}
JocGame.prototype.ScheduleStep = function() {
this.mNextSchedule = this.ExecuteStep;
}