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();
|
||||
this.timerDisplay.start();
|
||||
this._timeoutStartTime = Date.now();
|
||||
this._timeoutId = setInterval(() => {
|
||||
this._timeoutId = setTimeout(() => {
|
||||
this._onTimeout();
|
||||
}, this.baseTimeout);
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ export class TimedGame extends Game {
|
|||
this._onTimeout();
|
||||
} else {
|
||||
this._timeoutStartTime = Date.now();
|
||||
this._timeoutId = setInterval(() => {
|
||||
this._timeoutId = setTimeout(() => {
|
||||
this._onTimeout();
|
||||
}, this.currentTimeout);
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ export class TimedGame extends Game {
|
|||
clearTimeout(this._timeoutId);
|
||||
this._timeoutId = undefined;
|
||||
this._timeoutStartTime = undefined;
|
||||
this.currentTimeout = this.baseTimeout;
|
||||
}
|
||||
|
||||
end(status) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue