From 128db7946b44a2f4e9b8bc99ba3bec3f4d9b67e1 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Thu, 9 Jul 2015 00:19:44 +0200 Subject: [PATCH] fix a sync bug --- pet_variables.py | 23 +++++++++++++++++++++++ tamagotchi.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/pet_variables.py b/pet_variables.py index e69de29..354c103 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -0,0 +1,23 @@ +# The pet's stats +pet_name = "Fluffy" +pet_photo = "<`)))><" +pet_status = "youngling" +pet_health = 5 +pet_age = 0 +pet_hunger = 5 +pet_happiness = 5 +pet_stomach + +# 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 diff --git a/tamagotchi.py b/tamagotchi.py index e69de29..9528506 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -0,0 +1,43 @@ +# 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.stroking() + elif chosen_activity == 4: + pet_functions.pet_stats() +print("Your pet died.")