From f6a7acad197c284e1507ee94060eac5f72a9d63a Mon Sep 17 00:00:00 2001 From: caitsith2 Date: Tue, 23 Jun 2020 06:03:21 -0700 Subject: [PATCH] Send game finished state on connect --- MultiClient.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/MultiClient.py b/MultiClient.py index 5450f9d7..c4aad884 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -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