added stop ai worker method
This commit is contained in:
parent
7bc110655e
commit
009ee46a62
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue