From 8d90030011b31371b4452b1685a9cd968b50eca5 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 4 Dec 2019 18:06:03 -0500 Subject: [PATCH] Bug fixes. Improvements to play_randiom --- libstormgames.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libstormgames.py b/libstormgames.py index fc4359c..f7f0014 100755 --- a/libstormgames.py +++ b/libstormgames.py @@ -74,12 +74,15 @@ def initialize_gui(gameTitle): time.sleep(soundData['game-intro'].get_length()) return soundData -def play_random(soundName): -key = [] -for i in sounds.keys(): - if re.match("^" + soundName + ".*", i): - key.append(i) -psounds[random.choice(key)].play() +def play_random(sounds, soundName, pause = False): + key = [] + for i in sounds.keys(): + if re.match("^" + soundName + ".*", i): + key.append(i) + randomKey = random.choice(key) + sounds[randomKey].play() + if pause == True: + time.sleep(sounds[randomKey].get_length()) def instructions(): # Read in the instructions file