# 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 < Smurf.LIMIT_HAPPY:
            return "glad"
        elif unhappiness < Smurf.LIMIT_OKEY:
            return "okej"
        elif unhappiness < Smurf.LIMIT_FRUSTRATED:
            return "frustrerad"
        else:
            return "arg"

    # Update state when time passes (called by all actions)
    def passTime (self):
        self.hunger += Smurf.POINTS_TIME
        self.boredom += Smurf.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 ())

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

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