From f407348d630033576e3f606e0985ef26b2cbd8d4 Mon Sep 17 00:00:00 2001 From: Stefan Bethke Date: Sun, 15 Jun 2025 18:25:30 +0200 Subject: [PATCH] Randomize animations --- buba/bubaanimator.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/buba/bubaanimator.py b/buba/bubaanimator.py index 6ea2272..6978d57 100644 --- a/buba/bubaanimator.py +++ b/buba/bubaanimator.py @@ -146,14 +146,9 @@ class BubaAnimator: self.log.debug("No animations, sleeping...") sleep(2) else: - while True: - next = random.randint(0, len(self.animations) - 1) - if next != last: - break - last = next - a = self.animations[next] - self.log.debug(f"Starting animation: {a}") - a.run() + for a in random.sample(self.animations, len(self.animations)): + self.log.debug(f"Starting animation: {a}") + a.run() def add(self, animation, *args, **kwargs): self.animations.append(animation(self.buba, *args, **kwargs))