From afbb3d74360e9d3de630daa83b6e05055cc7a857 Mon Sep 17 00:00:00 2001 From: Eden Kirin Date: Fri, 12 May 2023 20:39:31 +0200 Subject: [PATCH] Cleanup --- hopper/engine.py | 8 ++++---- hopper/models/board.py | 14 +++++++------- hopper/watchdog.py | 4 +--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/hopper/engine.py b/hopper/engine.py index 5646d61..340cb63 100644 --- a/hopper/engine.py +++ b/hopper/engine.py @@ -179,14 +179,14 @@ class GameEngine: ) def on_purchase_timer_tick(time_left) -> None: - logging.info(f"Product selection countdown timer tick, time left: {time_left}") + logging.info( + f"Product selection countdown timer tick, time left: {time_left}" + ) def on_purchase_timer_done() -> None: logging.info("Ding ding! Product selection countdown timer timeout") self._purchase_countdown_timer = None - asyncio.run( - self.ws_server.send_product_selection_timeout_message() - ) + asyncio.run(self.ws_server.send_product_selection_timeout_message()) self.game_state = GameState.RUNNING asyncio.run(self.send_game_dump()) diff --git a/hopper/models/board.py b/hopper/models/board.py index 34933e3..d4b3c60 100644 --- a/hopper/models/board.py +++ b/hopper/models/board.py @@ -14,6 +14,13 @@ BOARD_DUMP_CHARS: dict[ObjectType, str] = { } +def create_random_position(board_width: int, board_height: int) -> Position: + return Position( + x=random.randint(0, board_width - 1), + y=random.randint(0, board_height - 1), + ) + + @dataclass class LayerObject: type_: ObjectType @@ -102,10 +109,3 @@ class BoardLayout: ) ) return layers - - -def create_random_position(board_width: int, board_height: int) -> Position: - return Position( - x=random.randint(0, board_width - 1), - y=random.randint(0, board_height - 1), - ) diff --git a/hopper/watchdog.py b/hopper/watchdog.py index 9c45b7a..a1c0488 100644 --- a/hopper/watchdog.py +++ b/hopper/watchdog.py @@ -10,9 +10,7 @@ from settings import settings class InactivityWatchdog(Thread): - def __init__( - self, players: PlayerList, ws_server: WSServer = None - ) -> None: + def __init__(self, players: PlayerList, ws_server: WSServer = None) -> None: self.players = players self.ws_server = ws_server self.stop_event = Event()