catching the ValueError in the activity list
when pressing enter because enter is not an integer
This commit is contained in:
parent
a72fe6c275
commit
3c43fe9ca7
|
@ -7,18 +7,10 @@
|
|||
Some interesting things I could add to the
|
||||
tamagotchi programme which shouldn't be too hard:
|
||||
|
||||
* ~~create a loop~~
|
||||
* ~~give it happiness~~
|
||||
* ~~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~~
|
||||
* 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
|
||||
* 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
|
||||
* ~~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.
|
||||
|
|
|
@ -31,13 +31,16 @@ while pet_functions.is_alive():
|
|||
print("What would you like to do?")
|
||||
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:
|
||||
pet_functions.feeding()
|
||||
elif chosen_activity == 2:
|
||||
pet_functions.playing()
|
||||
elif chosen_activity == 3:
|
||||
pet_functions.stroking()
|
||||
elif chosen_activity == 4:
|
||||
try:
|
||||
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.stroking()
|
||||
elif chosen_activity == 4:
|
||||
pet_functions.pet_stats()
|
||||
except ValueError:
|
||||
pet_functions.pet_stats()
|
||||
print("Your pet died.")
|
||||
|
|
Reference in New Issue