#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 30 18:15:12 2019

@author: moetom
--------------------------------------------------------------------------
This file is part of Verrücktes Gemüse.

Verrücktes Gemüse is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Verrücktes Gemüse is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
"""

import mod.switch
gemList = []    # Gemueseliste

class Gemuese:
    
    def __init__ (self, art):
        self.art = str(art)
        self.vocab = []             # Vocabular / sounds
        self.vocabStr = []          # Vocabular / strings 
        self.variation = 0          # variation file in current mode
        self.sleepTime = 0
        gemList.append(self)
        
    def AddVocab (self, sound, text):
        """ adds the sounds and texts into lists """
        self.vocab.append(sound)
        self.vocabStr.append(text)
            
    def ResetVariation(self, activMode):
        """ reset variation and play again """
        self.variation = 0
        self.Play(activMode)
        
    def Play(self, activMode):
        """ plays sound and print text from lists """
        if mod.switch.modeList[activMode] != mod.switch.drums:   # no len(self.vocab[mode][self.variation]) possible for drums
            if self.variation < len(self.vocab[mod.switch.activMode]):  # check if variation is not out of range
                self.vocab[activMode][self.variation].play()
                print("["+self.art+"]\n{}\n".format(self.vocabStr[activMode][self.variation]))
                self.sleepTime = self.vocab[mod.switch.activMode][self.variation].get_length()
                self.variation = self.variation + 1
            else:
                self.ResetVariation(activMode)
        else:                                               # drum mode has no variation
            self.vocab[activMode].play()
            print("["+self.art+"] - {}".format(self.vocabStr[activMode]))
            


tomate = Gemuese ("Tomate")
apfel = Gemuese ("Apfel")
paprika = Gemuese ("Paprika")
orange = Gemuese ("Orange")
zitrone = Gemuese ("Zitorne")
kartoffel = Gemuese ("Kartoffel")





