diff --git a/README.md b/README.md index d8f0bb2..0489059 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ tamagotchi programme which shouldn't be too hard: * sleeping with all values with over 50% full heals the pet if it has lost health * add pooping and cleaning function * let it get sick if it's health is low, by random chance or if there's too much poop -* decrease the hunger value after x seconds * add sleep function, you have to switch the lights off otherwise it will have nightmare and loose one health point. * add the possibility to get sick. Maybe compare two random numbers. * add a function to restart the game or exit it after the pet died. diff --git a/__pycache__/pet_functions.cpython-34.pyc b/__pycache__/pet_functions.cpython-34.pyc index 98e8d6b..b119929 100644 Binary files a/__pycache__/pet_functions.cpython-34.pyc and b/__pycache__/pet_functions.cpython-34.pyc differ diff --git a/__pycache__/pet_variables.cpython-34.pyc b/__pycache__/pet_variables.cpython-34.pyc index 08d1ccd..279b3e6 100644 Binary files a/__pycache__/pet_variables.cpython-34.pyc and b/__pycache__/pet_variables.cpython-34.pyc differ diff --git a/pet_functions.py b/pet_functions.py index 792be50..aae1089 100644 --- a/pet_functions.py +++ b/pet_functions.py @@ -110,7 +110,7 @@ def decrease_poke_count(): # run in the background. def decrease_stats(): while True: - time.sleep(15) + time.sleep(pet_variables.day) decrease_hunger() decrease_poke_count() if pet_variables.pet_hunger <= 0: @@ -163,7 +163,7 @@ def poking(): os.system('clear') if pet_variables.poke_count < 4: print("You poke " + pet_variables.pet_name + " and it starts to speak.") - pet_variables.increase_poke_count() + increase_poke_count() mixer.init() mixer.music.load('happy.mp3') mixer.music.play() @@ -175,3 +175,12 @@ def poking(): mixer.music.load('angry.mp3') mixer.music.play() time.sleep(3) + +# A function which let's the pet sleep and regenerates it's stats +def sleeping(): + os.system('clear') + print("Your pet is sleeping now.") + if pet_variables.max_hunger / pet_variables.pet_hunger > 0.5: + print("Sleeping works") + else: + print("Something is broken") diff --git a/pet_variables.py b/pet_variables.py index 9fa9ca1..4b56398 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -22,3 +22,4 @@ owl = "(^0M0^)" # programme variables beginning_finished = False poke_count = 0 +day = 15 diff --git a/tamagotchi.py b/tamagotchi.py index 2546eb5..d40c80d 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -31,7 +31,7 @@ while pet_functions.is_alive(): print("What would you like to do?") # Start the chosen activity and go back to the activity selector. print("1: Feeding, 2: Playing, 3: Stroke Pet,") - print("4: Poking, 5: Show Stats,") + print("4: Poking, 5: Sleeping, 6: Show Stats") try: chosen_activity = int(input("Choose the desired activity:")) if chosen_activity == 1: @@ -43,6 +43,8 @@ while pet_functions.is_alive(): elif chosen_activity == 4: pet_functions.poking() elif chosen_activity == 5: + pet_functions.sleeping() + elif chosen_activity == 6: pet_functions.pet_stats() except ValueError: pet_functions.pet_stats()