diff --git a/config.py b/config.py index 1607a13..0ea99cb 100644 --- a/config.py +++ b/config.py @@ -31,4 +31,4 @@ MAX_NETWORK_RETRIES = 10 NETWORK_SLEEP_TIME_SECONDS = 0.1 BANK_SLEEP_TIME = 0.1 BONUS_SLEEP_TIME = 0.1 -PLAYER_CHOOSE_INTERVAL = 3 +PLAYER_CHOOSE_INTERVAL = 1 diff --git a/events/StartGameEvent.py b/events/StartGameEvent.py index e069a86..8dbf322 100644 --- a/events/StartGameEvent.py +++ b/events/StartGameEvent.py @@ -8,8 +8,8 @@ import config from lamps.LampGroup import PLAYER_LAMPS + class StartGameEvent(Event): - isPlayerChoosing = True playerCount = 1 timer = None @@ -19,17 +19,19 @@ class StartGameEvent(Event): self.outHoleSolenoid = OutHoleSolenoid() super().__init__("Start Game Event") + def restart_timer(self): + if self.timer is not None: + self.timer.cancel() + self.timer = Timer(interval=config.PLAYER_CHOOSE_INTERVAL, function=self.player_choose_ended) + self.timer.start() + def trigger(self, target): if self.gameState.isPlaying: return super().trigger(target) - if not self.isPlayerChoosing: - self.isPlayerChoosing = True - self.timer = Timer(interval=config.PLAYER_CHOOSE_INTERVAL, function=self.player_choose_ended) - self.timer.start() - return + self.restart_timer() if self.playerCount == config.MAX_PLAYERS: PLAYER_LAMPS.deactivate()