Skip to content

Commit

Permalink
add nullcheck for publishing func
Browse files Browse the repository at this point in the history
  • Loading branch information
linomp committed Mar 30, 2024
1 parent dba6c88 commit 5ce06f2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mvp/server/core/game/GameSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def check_if_game_over(self) -> bool:

return self.is_game_over

async def advance_one_turn(self, publishing_func: Callable[['GameSession'], None]) -> list[MachineState]:
async def advance_one_turn(self, publishing_func: Callable[['GameSession'], None] | None = None) -> list[
MachineState]:
collected_machine_states_during_turn = []

self.last_updated = datetime.now()
Expand All @@ -85,7 +86,9 @@ async def advance_one_turn(self, publishing_func: Callable[['GameSession'], None
self.available_funds += math.ceil(REVENUE_PER_DAY / TIMESTEPS_PER_MOVE)
self._log()

publishing_func(self)
if publishing_func is not None:
publishing_func(self)

await asyncio.sleep(GAME_TICK_INTERVAL)

self.machine_state.update_prediction(
Expand Down

0 comments on commit 5ce06f2

Please sign in to comment.