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 pygame
import pyperclip import pyperclip
import random import random
import re
import requests import requests
import speechd import speechd
import subprocess import subprocess
@ -73,6 +74,13 @@ def initialize_gui(gameTitle):
time.sleep(soundData['game-intro'].get_length()) time.sleep(soundData['game-intro'].get_length())
return soundData 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(): def instructions():
# Read in the instructions file # Read in the instructions file
try: try: