gemuese.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. Created on Thu Jan 30 18:15:12 2019
  5. @author: moetom
  6. """
  7. import mod.switch
  8. gemList = [] # Gemueseliste
  9. class Gemuese:
  10. def __init__ (self, art):
  11. self.art = str(art)
  12. self.vocab = [] # Vocabular / sounds
  13. self.vocabStr = [] # Vocabular / strings
  14. self.variation = 0 # variation file in current mode
  15. self.sleepTime = 0
  16. gemList.append(self)
  17. def AddVocab (self, sound, text):
  18. """ adds the sounds and texts into lists """
  19. self.vocab.append(sound)
  20. self.vocabStr.append(text)
  21. def ResetVariation(self, activMode):
  22. """ reset variation and play again """
  23. self.variation = 0
  24. self.Play(activMode)
  25. def Play(self, activMode):
  26. """ plays sound and print text from lists """
  27. if mod.switch.modeList[activMode] != mod.switch.drums: # no len(self.vocab[mode][self.variation]) possible for drums
  28. if self.variation < len(self.vocab[mod.switch.activMode]): # check if variation is not out of range
  29. self.vocab[activMode][self.variation].play()
  30. print("["+self.art+"]\n{}\n".format(self.vocabStr[activMode][self.variation]))
  31. self.sleepTime = self.vocab[mod.switch.activMode][self.variation].get_length()
  32. self.variation = self.variation + 1
  33. else:
  34. self.ResetVariation(activMode)
  35. else: # drum mode has no variation
  36. self.vocab[activMode].play()
  37. print("["+self.art+"] - {}".format(self.vocabStr[activMode]))
  38. tomate = Gemuese ("Tomate")
  39. apfel = Gemuese ("Apfel")
  40. paprika = Gemuese ("Paprika")
  41. orange = Gemuese ("Orange")
  42. zitrone = Gemuese ("Zitorne")
  43. kartoffel = Gemuese ("Kartoffel")