# The class Smurf represents Tamaguchi-like smurfs who can be hungry
# or bored
class Smurf (object):
    # Limits for various moods
    LIMIT_HAPPY = 5
    LIMIT_OKEY = 10
    LIMIT_FRUSTRATED = 15

    # Points to add or subtract from hunger or boredom states
    POINTS_EAT = 4
    POINTS_PLAY = 4
    POINTS_TIME = 1
    
    def __init__ (self, name, hunger = 4, boredom = 4):
        self.name = name
        # These two attributes contain the state of the smurf
        self.hunger = hunger
        self.boredom = boredom

    # Return the mood of the smurf based on the state self.hunger or
    # self.boredom
    def mood (self):
        unhappiness = self.hunger + self.boredom
        if unhappiness < self.LIMIT_HAPPY:
            return "glad"
        elif unhappiness < self.LIMIT_OKEY:
            return "okej"
        elif unhappiness < self.LIMIT_FRUSTRATED:
            return "frustrerad"
        else:
            return "arg"

    # Update state when time passes (called by all actions)
    def passTime (self):
        self.hunger += self.POINTS_TIME
        self.boredom += self.POINTS_TIME

    # Present ourselves and report the state
    def talk (self):
        print ("Jag är en smurf som heter %s." % self.name)
        print ("Jag är %s." % self.mood ())
        self.passTime ()

    # Eat some food
    def eat (self):
        print ("Mums!")
        self.hunger -= self.POINTS_EAT
        # Make sure that self.hunger isn't negative:
        if self.hunger < 0:
            self.hunger = 0
        self.passTime ()

    # Play
    def play (self):
        print ("Tjohoo!")
        self.boredom -= self.POINTS_PLAY
        # Make sure that self.hunger isn't negative:
        if self.boredom < 0:
            self.boredom = 0
        self.passTime ()

# This is the main program logic
def main ():
    namn = input ("Vad ska smurfen heta? ")
    smurf = Smurf (namn)

    choice = None
    while choice != "0":
        # Print a menu
        print ("""
Sköta smurf

0 - Sluta
1 - Lyssna till din smurf
2 - Mata smurfen
3 - Lek med smurfen
""")
        choice = input ("Välj: ")

        if choice == "0":
            print ("Hejdå!")
            
        elif choice == "1":
            smurf.talk ()
        elif choice == "2":
            smurf.eat ()
        elif choice == "3":
            smurf.play ()
        else:
            # The user 
            print (choice, "är inte ett giltigt val. Försök igen!")

# Start the program
main ()
