Fix timeleft calculation

This commit is contained in:
redfast00 2022-01-25 21:44:27 +01:00
parent 0522fe0a48
commit 22d02dee88
No known key found for this signature in database
GPG key ID: 5946E0E34FD0553C

View file

@ -179,7 +179,7 @@ def status():
# Client can then extrapolate if it wants to
status_dict['timeleft'] = (web_to_serial.game_duration - (datetime.now() - serial_to_web.game_start)).total_seconds()
elif serial_to_web.gamestate == Gamestate.GAMEOVER:
status_dict['timeleft'] = (serial_to_web.game_stop - serial_to_web.game_start).total_seconds()
status_dict['timeleft'] = max(0, (web_to_serial.game_duration - (serial_to_web.game_stop - serial_to_web.game_start)).total_seconds())
if serial_to_web.gamestate in (Gamestate.DISCOVER, Gamestate.GAME, Gamestate.GAMEOVER):
status_dict['puzzles'] = [