From b8049a48e947e04e98ce678646cb31c84e1768c3 Mon Sep 17 00:00:00 2001 From: Nebucatnetzer Date: Fri, 10 Jul 2015 12:08:10 +0200 Subject: [PATCH] adding a pause of 1 second to the stroking function to make it more readable --- README.md | 42 +++++++++++++++++------ __pycache__/pet_functions.cpython-34.pyc | Bin 3880 -> 4149 bytes __pycache__/pet_variables.cpython-34.pyc | Bin 504 -> 525 bytes pet_functions.py | 11 ++++++ pet_variables.py | 1 + tamagotchi.py | 4 ++- 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b8facd0..37bba99 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ tamagotchi programme which shouldn't be too hard: * ~~give it points for hungriness~~ * ~~add the guessing game and increase the happiness by one point when you finished the game~~ * ~~create a list with things you can do~~ -* pet it to increase happiness +* ~~pet it to increase happiness~~ * poke it to make it speak, pokes let it loose a happiness point * ~~add max values depending on the status~~ * sleeping with all values with over 50% full heals the pet if it has lost health @@ -22,25 +22,45 @@ tamagotchi programme which shouldn't be too hard: * ~~let it age~~ * 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. +* 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. * add a function let the user exit the game * safe the stats in a text file +* make a seperate function for each age because it makes the aging +funciton more readable ## 30.6.2015 -Time function has to be implemented otherwise the decrease.* functions won't work. -It seems to work however the import time part has to go into the pet_functions.py file. -Maybe I should move all the imports to that file otherwise it's not clear why they are needed. +Time function has to be implemented otherwise the decrease.* functions +won't work. It seems to work however the import time part has to go into +the pet_functions.py file. Maybe I should move all the imports to that +file otherwise it's not clear why they are needed. -Moved all the imports to there relevant place +Moved all the imports to there relevant place And added the time import. Things are working now like intended. -However the pet doesn't get updated automatically. I currently don't know how to achieve that. +However the pet doesn't get updated automatically. +I currently don't know how to achieve that. I'll have to ask reddit how to do it. ## 06.07.2015 -I've written a function to decrease the stats in the background. Means the tamagotchi can now get hungry etc. -However it currently doesn't work. I don't know why atm. If you call it independently it works just fine. +I've written a function to decrease the stats in the background. +Means the tamagotchi can now get hungry etc. +However it currently doesn't work. I don't know why atm. If you call it +independently it works just fine. -In addition I've cleaned up the code a bit and made sure that the stats variables don't fall under 0 because that might cause some problems in the future. +In addition I've cleaned up the code a bit and made sure that the stats +variables don't fall under 0 because that might cause some problems +in the future. ## 07.07.2015 +I've fixed the decrease_stats function. However I wanted that it only +starts after the beginning is finished. So that the pet doesn't start +with a disadvantage. I currently don't know how to fix this. For the +moment it will work like this. I could add a function to the beginning +which resets the stats back to the default values. Might be a good work- +around however for the future I would like how to do it properly. + +## 08.07.2015 +The feature to the pet the pet will be so that it only prints a message. +It wouldn't be fun if it would increase happiness because that would be +too easy. + diff --git a/__pycache__/pet_functions.cpython-34.pyc b/__pycache__/pet_functions.cpython-34.pyc index 1b11897ef9a9783a82643a2b75c377de1300433e..7c06c37bc583d9c9967775c817498223069d3523 100644 GIT binary patch delta 387 zcmYjLO-n*S6uslC_eAGCjX;SYhAcxdEkjzgY1^U*qDAeVzUN2ko0>Ngx^ZEDpoX?> zi=dUX?ML(%+6Cngh@d+~)LibF%Q@%HoV$fbmU*XkY%&3K*lc~7uYU$TZD$WFgF*xZq<>$d%n)p)ngh144XZ-vOX zfyX+&8{pJ%TR|v))|PD(RDRFO$Plclyjhv?5*K5_c;j)#})&eFM|os0|&j~S2vkk8-%#KkESmGw+m7^2u2QkWT{IKU()LkcTH z6css{jB1 delta 111 zcmeBW`N6FGj)#})mhYU;^Mf8%6fXt3{mV1DL|5gA%&G8ijyIQ zjUkGQA%&eGikl&Yks*qQA%%k>ikBgUlOc+4Vrv*9|HL~%ldTyyu*d)nnf#Ga1^{oo B6x{#- diff --git a/pet_functions.py b/pet_functions.py index 3da37e3..5817181 100644 --- a/pet_functions.py +++ b/pet_functions.py @@ -93,6 +93,8 @@ def decrease_health(): pet_variables.pet_health = pet_variables.pet_health - 1 +# The function to decrease the stats and make the pet "live" needs to +# run in the background. def decrease_stats(): while True: time.sleep(15) @@ -102,9 +104,18 @@ def decrease_stats(): decrease_happiness() +### Activities ### + # Increases the pets hungriness by +1 unless the hunger is bigger than # the pet's maximum hunger. In this case the pet will vomit and looses hunger # and health. + +def stroking(): + print() + print("You're stroking the back of your pet gently.") + print("It makes comforting noises and leans against your hand.") + time.sleep(1) + def feeding(): print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*") feeding_confirmed = input("Do you want to feed your pet?") diff --git a/pet_variables.py b/pet_variables.py index 318a17f..2373b74 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -6,6 +6,7 @@ pet_health = 5 pet_age = 0 pet_hunger = 5 pet_happiness = 5 +pet_stomach = 0 # age based max values max_health = 5 diff --git a/tamagotchi.py b/tamagotchi.py index a232490..40412cb 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -29,7 +29,7 @@ while pet_functions.is_alive(): print() # Present the player with activities to choose from print("What would you like to do?") - print("1: Feeding, 2: Playing, 3: Show Stats") + print("1: Feeding, 2: Playing, 3: Stroke Pet, 4: Show Stats") # Start the chosen activity and go back to the activity selector. chosen_activity = int(input("Choose the desired activity:")) if chosen_activity == 1: @@ -37,5 +37,7 @@ while pet_functions.is_alive(): elif chosen_activity == 2: pet_functions.playing() elif chosen_activity == 3: + pet_functions.stroking() + elif chosen_activity == 4: pet_functions.pet_stats() print("Your pet died.")