Merge pull request #114 from Berserker66/send_finish_on_connect

Send game finished state on connect
This commit is contained in:
Fabian Dill 2020-06-23 15:07:27 +02:00 committed by GitHub
commit 8c358a449b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -818,6 +818,8 @@ async def process_server_cmd(ctx: Context, cmd, args):
msgs.append(['LocationScouts', list(ctx.locations_scouted)])
if msgs:
await ctx.send_msgs(msgs)
if ctx.finished_game:
await send_finished_game(ctx)
elif cmd == 'ReceivedItems':
start_index, items = args
@ -1121,6 +1123,14 @@ async def track_locations(ctx : Context, roomid, roomdata):
await ctx.send_msgs([['LocationChecks', new_locations]])
async def send_finished_game(ctx: Context):
try:
await ctx.send_msgs([['GameFinished', '']])
ctx.finished_game = True
except Exception as ex:
logging.exception(ex)
async def game_watcher(ctx : Context):
prev_game_timer = 0
perf_counter = time.perf_counter()
@ -1160,11 +1170,7 @@ async def game_watcher(ctx : Context):
delay = 7 if ctx.slow_mode else 2
if gameend[0]:
if not ctx.finished_game:
try:
await ctx.send_msgs([['GameFinished', '']])
ctx.finished_game = True
except Exception as ex:
logging.exception(ex)
await(send_finished_game(ctx))
if time.perf_counter() - perf_counter < delay:
continue