From 0e786ac17f1be3b93405614d5a840770bc6fff56 Mon Sep 17 00:00:00 2001 From: Jonas Zeunert Date: Wed, 31 Aug 2022 17:39:19 +0200 Subject: [PATCH] blaa --- GameState.py | 20 ++++++++++++++------ lamps/LampGroup.py | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/GameState.py b/GameState.py index 9593f8d..db204be 100644 --- a/GameState.py +++ b/GameState.py @@ -49,21 +49,29 @@ class GameState: def stopIdleLoop(self): self.isIdle.set() + self.deactivate_all() pass + def deactivate_all(self): + all_cabinet_lamps = [BONUS_LAMPS, BONUS_MULTIPLIER_LAMPS, CHAMP_LAMPS, + UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS, + TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS] + for lamp_group in all_cabinet_lamps: + lamp_group.deactivate() + async def idleLoop(self): all_cabinet_lamps = [BONUS_LAMPS, BONUS_MULTIPLIER_LAMPS, CHAMP_LAMPS, UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS, TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS] while True: - #for lamps in all_cabinet_lamps: - #for _ in lamps.lamps: - #lamps.cycle() - #if not self.isIdle: - # return - #time.sleep(0.1) random_group = random.choice(all_cabinet_lamps) random_group.toggleRandom(0.2) + for lamps in all_cabinet_lamps: + for _ in lamps.lamps: + lamps.cycle() + if self.isIdle.is_set(): + return + time.sleep(0.05) if self.isIdle.is_set(): return diff --git a/lamps/LampGroup.py b/lamps/LampGroup.py index 1425a46..8abb74b 100644 --- a/lamps/LampGroup.py +++ b/lamps/LampGroup.py @@ -43,9 +43,12 @@ class LampGroup: def toggleRandom(self, sleepTime): count = random.randint(1,3) random_lamps = random.choices(self.lamps, k=count) + for lamp in random_lamps: lamp.activate() + time.sleep(sleepTime) + for lamp in random_lamps: lamp.deactivate()