more random

This commit is contained in:
Jonas Zeunert
2022-08-31 17:32:30 +02:00
parent 5fb8bb54f0
commit a0d2083b01

View File

@@ -41,10 +41,14 @@ class LampGroup:
self.currentLampPtr -= 1
def toggleRandom(self, sleepTime):
random_lamp = random.choice(self.lamps)
random_lamp.activate()
count = random.randint(1,8)
random_lamps = random.choices(self.lamps, count)
for lamp in random_lamps:
lamp.activate()
time.sleep(sleepTime)
random_lamp.deactivate()
for lamp in random_lamps:
lamp.deactivate()
def cycle(self):
if self.currentLamp:
self.currentLamp.deactivate()