fix a bug where time could go in negatives after a restart

This commit is contained in:
lagaffe 2026-06-30 17:03:23 +02:00
parent cedafd5e10
commit dd8131e55a

View file

@ -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) {