gemuese.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. This file is part of Verrücktes Gemüse.
  8. Verrücktes Gemüse is free software: you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation, either version 3 of the License, or
  11. (at your option) any later version.
  12. Verrücktes Gemüse is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. --------------------------------------------------------------------------
  19. """
  20. import mod.switch
  21. gemList = [] # Gemueseliste
  22. class Gemuese:
  23. def __init__ (self, art):
  24. self.art = str(art)
  25. self.vocab = [] # Vocabular / sounds
  26. self.vocabStr = [] # Vocabular / strings
  27. self.variation = 0 # variation file in current mode
  28. self.sleepTime = 0
  29. gemList.append(self)
  30. def AddVocab (self, sound, text):
  31. """ adds the sounds and texts into lists """
  32. self.vocab.append(sound)
  33. self.vocabStr.append(text)
  34. def ResetVariation(self, activMode):
  35. """ reset variation and play again """
  36. self.variation = 0
  37. self.Play(activMode)
  38. def Play(self, activMode):
  39. """ plays sound and print text from lists """
  40. if mod.switch.modeList[activMode] != mod.switch.drums: # no len(self.vocab[mode][self.variation]) possible for drums
  41. if self.variation < len(self.vocab[mod.switch.activMode]): # check if variation is not out of range
  42. self.vocab[activMode][self.variation].play()
  43. print("["+self.art+"]\n{}\n".format(self.vocabStr[activMode][self.variation]))
  44. self.sleepTime = self.vocab[mod.switch.activMode][self.variation].get_length()
  45. self.variation = self.variation + 1
  46. else:
  47. self.ResetVariation(activMode)
  48. else: # drum mode has no variation
  49. self.vocab[activMode].play()
  50. print("["+self.art+"] - {}".format(self.vocabStr[activMode]))
  51. tomate = Gemuese ("Tomate")
  52. apfel = Gemuese ("Apfel")
  53. paprika = Gemuese ("Paprika")
  54. orange = Gemuese ("Orange")
  55. zitrone = Gemuese ("Zitorne")
  56. kartoffel = Gemuese ("Kartoffel")