Added play_random function.

This commit is contained in:
Storm Dragon 2019-12-04 13:39:16 -05:00
parent 1a724ada21
commit 4e6b6ded7c

View File

@ -11,6 +11,7 @@ from xdg import BaseDirectory
import pygame
import pyperclip
import random
import re
import requests
import speechd
import subprocess
@ -73,6 +74,13 @@ 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 instructions():
# Read in the instructions file
try: