apparently a comment starts with "# " not just with "#"

This commit is contained in:
Andreas Zweili 2015-07-06 22:46:29 +02:00
parent 6bbd3c3a32
commit 395d072d0f
2 changed files with 45 additions and 35 deletions

View File

@ -2,32 +2,35 @@ import pet_variables
import time
from random import randint
#Pictures and symboles used ingame
# Pictures and symboles used ingame
cat = "(=^o.o^=)__"
mouse = "<:3 )~~~~"
fish = "<`)))><"
owl = "(^0M0^)"
#variables needed for the guessing game
secret = randint(1,10)
# variables needed for the guessing game
secret = randint(1, 10)
def pet_stats():
print(pet_variables.pet_name)
print(pet_variables.pet_photo)
print("Status: " + pet_variables.pet_status)
print("Age: " + str(pet_variables.pet_age))
print("Health: " + pet_variables.pet_health * "")
print("Health: " + pet_variables.pet_health * "")
print("Hunger: " + pet_variables.pet_hunger * "*")
print("Happines: " + pet_variables.pet_happiness * "")
#A function which checks if the pet is still alive
# A function which checks if the pet is still alive
def is_alive():
if pet_variables.pet_health > 0:
return True
else:
else:
return False
#A function which let's the player choose his pet.
def beginning():
# A function which let's the player choose his pet.
def beginning():
print("Which pet do you want to look after?")
print("1: Cat, 2: Mouse, 3: Fish, 4: Owl")
chosen_pet = int(input("Choose your pet:"))
@ -40,8 +43,9 @@ def beginning():
elif chosen_pet == 4:
pet_variables.pet_photo = owl
#A cunction which changes the status of the pet depending of the age value.
#Each status has it's own characteristics.
# A cunction which changes the status of the pet depending of the age value.
# Each status has it's own characteristics.
def aging():
pet_variables.pet_status
pet_variables.max_health
@ -62,35 +66,40 @@ def aging():
print("Congratulation your pet has become an elderly it needs now less food.")
print("However it's health is worse and it's grumpier than an adult.")
def decrease_hunger():
pet_variables.pet_hunger = pet_variables.pet_hunger - 1
def decrease_happiness():
pet_variables.pet_happiness = pet_variables.pet_happiness -1
def decrease_health():
pet_variables.pet_health = pet_variables.pet_health -1
def decrease_happiness():
pet_variables.pet_happiness = pet_variables.pet_happiness - 1
def decrease_health():
pet_variables.pet_health = pet_variables.pet_health - 1
def decrease_stats():
while True:
time.sleep(15)
if not pet_variables.pet_hunger == 0:
decrease_hunger()
else:
decrease_hunger()
if pet_variables.pet_hunger <= 0:
decrease_health()
decrease_happiness()
#Increases the pets hungriness by +1 unless the hunger is bigger than
#the pet's maximum hunger. In this case the pet womits and looses hunger
#and health.
# Increases the pets hungriness by +1 unless the hunger is bigger than
# the pet's maximum hunger. In this case the pet womits and looses hunger
# and health.
def feading():
pet_variables.pet_hunger
print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*")
feading_confirmed = input("Do you want to feed your pet?")
if feading_confirmed in ("Y","y"):
if feading_confirmed in ("Y", "y"):
pet_variables.pet_hunger = pet_variables.pet_hunger + 1
#A simple guessing game which increases the pet's happiness
# A simple guessing game which increases the pet's happiness
def playing():
pet_variables.pet_happiness
guess = 0

View File

@ -1,34 +1,35 @@
#import the threading module
# import the threading module
import threading
#import custom modules
#A function to nicely print out the pets stats
# import custom modules
# A function to nicely print out the pets stats
import pet_functions
#Variable needed to skip the beginning when finished
# Variable needed to skip the beginning when finished
beginning_finished = False
#Beginning of the main routine which makes up the actual game.
#Only starts if the pet is still alive.
while pet_functions.is_alive():
# Beginning of the main routine which makes up the actual game.
# Only starts if the pet is still alive.
while pet_functions.is_alive():
t = threading.Thread(target=pet_functions.decrease_stats)
t.start()
if not beginning_finished:
#Let the player choose his pet and skip the beginning from then on.
# Let the player choose his pet and skip the beginning from then on.
pet_functions.beginning()
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.")
#Each round print the pets stats so that the player can see them.
# 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
# Present the player with activities to choose from
print("What would you like to do?")
print("1: Feading, 2: Playing, 3: Show Stats")
#Start the chosen activity and go back to the activity selector.
# 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.feading()
@ -36,4 +37,4 @@ while pet_functions.is_alive():
pet_functions.playing()
elif chosen_activity == 3:
pet_functions.pet_stats()
print("Your pet died.")
print("Your pet died.")