adding a stroking function
This commit is contained in:
parent
ae77fcb86c
commit
02ced24cba
27
README.md
27
README.md
|
@ -13,7 +13,7 @@ tamagotchi programme which shouldn't be too hard:
|
||||||
* ~~give it points for hungriness~~
|
* ~~give it points for hungriness~~
|
||||||
* ~~add the guessing game and increase the happiness by one point when you finished the game~~
|
* ~~add the guessing game and increase the happiness by one point when you finished the game~~
|
||||||
* ~~create a list with things you can do~~
|
* ~~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
|
* poke it to make it speak, pokes let it loose a happiness point
|
||||||
* ~~add max values depending on the status~~
|
* ~~add max values depending on the status~~
|
||||||
* sleeping with all values with over 50% full heals the pet if it has lost health
|
* sleeping with all values with over 50% full heals the pet if it has lost health
|
||||||
|
@ -35,13 +35,30 @@ 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.
|
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.
|
I'll have to ask reddit how to do it.
|
||||||
|
|
||||||
## 06.07.2015
|
## 06.07.2015
|
||||||
I've written a function to decrease the stats in the background. Means the tamagotchi can now get hungry etc.
|
I've written a function to decrease the stats in the background.
|
||||||
However it currently doesn't work. I don't know why atm. If you call it independently it works just fine.
|
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
|
## 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.
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ def decrease_health():
|
||||||
pet_variables.pet_health = pet_variables.pet_health - 1
|
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():
|
def decrease_stats():
|
||||||
while True:
|
while True:
|
||||||
time.sleep(15)
|
time.sleep(15)
|
||||||
|
@ -102,9 +104,16 @@ def decrease_stats():
|
||||||
decrease_happiness()
|
decrease_happiness()
|
||||||
|
|
||||||
|
|
||||||
|
### Activities ###
|
||||||
|
|
||||||
# Increases the pets hungriness by +1 unless the hunger is bigger than
|
# 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
|
# the pet's maximum hunger. In this case the pet will vomit and looses hunger
|
||||||
# and health.
|
# and health.
|
||||||
|
|
||||||
|
def stroking():
|
||||||
|
print("You're stroking the back of your pet gently.")
|
||||||
|
print("It makes comforting noises and leans against your hand.")
|
||||||
|
|
||||||
def feeding():
|
def feeding():
|
||||||
print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*")
|
print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*")
|
||||||
feeding_confirmed = input("Do you want to feed your pet?")
|
feeding_confirmed = input("Do you want to feed your pet?")
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# The pet's stats
|
|
||||||
pet_name = "Fluffy"
|
|
||||||
pet_photo = "<`)))><"
|
|
||||||
pet_status = "youngling"
|
|
||||||
pet_health = 5
|
|
||||||
pet_age = 0
|
|
||||||
pet_hunger = 5
|
|
||||||
pet_happiness = 5
|
|
||||||
|
|
||||||
# age based max values
|
|
||||||
max_health = 5
|
|
||||||
max_hunger = 5
|
|
||||||
max_happiness = 10
|
|
||||||
|
|
||||||
# Pictures and symbols used ingame
|
|
||||||
cat = "(=^o.o^=)__"
|
|
||||||
mouse = "<:3 )~~~~"
|
|
||||||
fish = "<`)))><"
|
|
||||||
owl = "(^0M0^)"
|
|
||||||
|
|
||||||
# programme variables
|
|
||||||
beginning_finished = False
|
|
|
@ -1,41 +0,0 @@
|
||||||
# import the threading module
|
|
||||||
import threading
|
|
||||||
# import the pets_variables
|
|
||||||
import pet_variables
|
|
||||||
# a module which includes various custom functions
|
|
||||||
import pet_functions
|
|
||||||
|
|
||||||
|
|
||||||
# Beginning of the main routine which makes up the actual game.
|
|
||||||
|
|
||||||
# thread which runs in the background to cause hunger, etc
|
|
||||||
t = threading.Thread(target=pet_functions.decrease_stats)
|
|
||||||
t.start()
|
|
||||||
# Only starts if the pet is still alive.
|
|
||||||
while pet_functions.is_alive():
|
|
||||||
if not pet_variables.beginning_finished:
|
|
||||||
# Let the player choose his pet and skip the beginning from then on.
|
|
||||||
pet_functions.beginning()
|
|
||||||
pet_variables.beginning_finished = True
|
|
||||||
print()
|
|
||||||
print()
|
|
||||||
print("Your pet is currently a youngling which means it's needs a lot of attention.")
|
|
||||||
print("Take good care of it or it will die very soon.")
|
|
||||||
# checks if the pet has reached a new life stage and updates it accordingly
|
|
||||||
pet_functions.aging()
|
|
||||||
print()
|
|
||||||
# Each round print the pets stats so that the player can see them.
|
|
||||||
pet_functions.pet_stats()
|
|
||||||
print()
|
|
||||||
# Present the player with activities to choose from
|
|
||||||
print("What would you like to do?")
|
|
||||||
print("1: Feeding, 2: Playing, 3: 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:
|
|
||||||
pet_functions.feeding()
|
|
||||||
elif chosen_activity == 2:
|
|
||||||
pet_functions.playing()
|
|
||||||
elif chosen_activity == 3:
|
|
||||||
pet_functions.pet_stats()
|
|
||||||
print("Your pet died.")
|
|
Reference in New Issue