mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Send game finished state on connect
This commit is contained in:
@@ -818,6 +818,8 @@ async def process_server_cmd(ctx: Context, cmd, args):
|
|||||||
msgs.append(['LocationScouts', list(ctx.locations_scouted)])
|
msgs.append(['LocationScouts', list(ctx.locations_scouted)])
|
||||||
if msgs:
|
if msgs:
|
||||||
await ctx.send_msgs(msgs)
|
await ctx.send_msgs(msgs)
|
||||||
|
if ctx.finished_game:
|
||||||
|
await send_finished_game(ctx)
|
||||||
|
|
||||||
elif cmd == 'ReceivedItems':
|
elif cmd == 'ReceivedItems':
|
||||||
start_index, items = args
|
start_index, items = args
|
||||||
@@ -1121,6 +1123,14 @@ async def track_locations(ctx : Context, roomid, roomdata):
|
|||||||
await ctx.send_msgs([['LocationChecks', new_locations]])
|
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):
|
async def game_watcher(ctx : Context):
|
||||||
prev_game_timer = 0
|
prev_game_timer = 0
|
||||||
perf_counter = time.perf_counter()
|
perf_counter = time.perf_counter()
|
||||||
@@ -1160,11 +1170,7 @@ async def game_watcher(ctx : Context):
|
|||||||
delay = 7 if ctx.slow_mode else 2
|
delay = 7 if ctx.slow_mode else 2
|
||||||
if gameend[0]:
|
if gameend[0]:
|
||||||
if not ctx.finished_game:
|
if not ctx.finished_game:
|
||||||
try:
|
await(send_finished_game(ctx))
|
||||||
await ctx.send_msgs([['GameFinished', '']])
|
|
||||||
ctx.finished_game = True
|
|
||||||
except Exception as ex:
|
|
||||||
logging.exception(ex)
|
|
||||||
|
|
||||||
if time.perf_counter() - perf_counter < delay:
|
if time.perf_counter() - perf_counter < delay:
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user