fix a bug where time could go in negatives after a restart
This commit is contained in:
parent
cedafd5e10
commit
dd8131e55a
1 changed files with 3 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ export class TimedGame extends Game {
|
||||||
super.start();
|
super.start();
|
||||||
this.timerDisplay.start();
|
this.timerDisplay.start();
|
||||||
this._timeoutStartTime = Date.now();
|
this._timeoutStartTime = Date.now();
|
||||||
this._timeoutId = setInterval(() => {
|
this._timeoutId = setTimeout(() => {
|
||||||
this._onTimeout();
|
this._onTimeout();
|
||||||
}, this.baseTimeout);
|
}, this.baseTimeout);
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +34,7 @@ export class TimedGame extends Game {
|
||||||
this._onTimeout();
|
this._onTimeout();
|
||||||
} else {
|
} else {
|
||||||
this._timeoutStartTime = Date.now();
|
this._timeoutStartTime = Date.now();
|
||||||
this._timeoutId = setInterval(() => {
|
this._timeoutId = setTimeout(() => {
|
||||||
this._onTimeout();
|
this._onTimeout();
|
||||||
}, this.currentTimeout);
|
}, this.currentTimeout);
|
||||||
}
|
}
|
||||||
|
|
@ -46,6 +46,7 @@ export class TimedGame extends Game {
|
||||||
clearTimeout(this._timeoutId);
|
clearTimeout(this._timeoutId);
|
||||||
this._timeoutId = undefined;
|
this._timeoutId = undefined;
|
||||||
this._timeoutStartTime = undefined;
|
this._timeoutStartTime = undefined;
|
||||||
|
this.currentTimeout = this.baseTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
end(status) {
|
end(status) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue