From 8f090b951a62f6e1a6053f4c00214c6999829116 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sun, 12 Jul 2015 22:53:40 +0200 Subject: [PATCH] add the basis for a function which let's the pet sleep --- README.md | 1 - __pycache__/pet_functions.cpython-34.pyc | Bin 5071 -> 5360 bytes __pycache__/pet_variables.cpython-34.pyc | Bin 550 -> 563 bytes pet_functions.py | 13 +++++++++++-- pet_variables.py | 1 + tamagotchi.py | 4 +++- 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d8f0bb2..0489059 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ tamagotchi programme which shouldn't be too hard: * 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 -* 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. diff --git a/__pycache__/pet_functions.cpython-34.pyc b/__pycache__/pet_functions.cpython-34.pyc index 98e8d6bd3203ec22499ce51fb6f45fa0bc6edfb6..b1199299a198496ea2e96a6a0cbb17f054769d19 100644 GIT binary patch delta 826 zcmYjOJxml)5T3c+y`Q~zzvRFLiAPQYOAJH{(DR2w8;u4Mi6IaZg6@KM2e6e;uT$E}+$ z+5o=5p-*GG!s_>Lmr9uH0mp_X0FxFt2xE3{^BVp}EYOhl6uX)`+IvL1xo*rwuuOkr z8+e_b#~Opnh-8K9<*IkfF z=5{q_`o8REOP*GcS8$4Asgst+rk`d2)G&)NmJF*Lpl!nnP=-yIsjxqqIxcov`W|r-2#5%BL zMYV)i=ux_LHH@u6O^1NdfDTSw*Flz50i0Z&H_ULu&%m27Z*)XPImwDO;VsGHf*Ta8 zelZ+#wJ}?4c*}jWstABjLo4YqHGah}d$R7Yw2XQ4Zg5u-RsUG=w)E<5!;Z>0yUTy4CuULJvie zf)|BK=Olule?VnV{s2L|2tD@d&4Vn6;L(|FMctvbV)tMBmG_V8F8Zj%IR4+L$3P*FVai*30|gV zh42c!tL)%)I_GWUP1^N#@D^p&ZCs&W)lL77RJND^O`EQI@#6~|Z*-sl=pv*DTL@TK zu*Hf(?K>N~4x|>`Lof=8(tfr)bPpBqx0C|+sTR#RS2M_zxO;YScQxB{@?Ms$nUiwS z7ODz`LZ_H0_LI2BK|aC+sL;nUBVaRA(jgW8_h?fT-cTX;9>YviKJu}2nv-UR+QD+f zJ^vFOMa?j?{WrlP;&U3*jy304up&kN9$EHzw)_iC)((4Y#&f6KzTBYChoYuno;cNN-kW}Q>1B}q4LD(pDIFZCO+Bkt{Xuh!!O>x3Z3(X2i uFQ!B9ReW}C^+CGc%jV@>@<}FbX;l-m1EsZgb)BIY&H-%pHC@&f9sU8I7-%H` diff --git a/__pycache__/pet_variables.cpython-34.pyc b/__pycache__/pet_variables.cpython-34.pyc index 08d1ccdac43bfd618987a6a1d07180ebd3d36d27..279b3e6806063da6a9ba35527dc1ef2b43c201f1 100644 GIT binary patch delta 87 zcmZ3+vYAEs9S<*;>FGtG3mF+09y1^TAfLejh>Hs*DyMLWUG{1N~F delta 72 zcmdnYvW!Lf9S<+p>LZInXD~7_JZ3-wKt6*55Eo}nR8C>xVu%u$I5Cu+1t{XDDLC=% Qp2_PN;~5nu^D!v{07obf@&Et; diff --git a/pet_functions.py b/pet_functions.py index 792be50..aae1089 100644 --- a/pet_functions.py +++ b/pet_functions.py @@ -110,7 +110,7 @@ def decrease_poke_count(): # run in the background. def decrease_stats(): while True: - time.sleep(15) + time.sleep(pet_variables.day) decrease_hunger() decrease_poke_count() if pet_variables.pet_hunger <= 0: @@ -163,7 +163,7 @@ def poking(): os.system('clear') if pet_variables.poke_count < 4: print("You poke " + pet_variables.pet_name + " and it starts to speak.") - pet_variables.increase_poke_count() + increase_poke_count() mixer.init() mixer.music.load('happy.mp3') mixer.music.play() @@ -175,3 +175,12 @@ def poking(): mixer.music.load('angry.mp3') mixer.music.play() time.sleep(3) + +# A function which let's the pet sleep and regenerates it's stats +def sleeping(): + os.system('clear') + print("Your pet is sleeping now.") + if pet_variables.max_hunger / pet_variables.pet_hunger > 0.5: + print("Sleeping works") + else: + print("Something is broken") diff --git a/pet_variables.py b/pet_variables.py index 9fa9ca1..4b56398 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -22,3 +22,4 @@ owl = "(^0M0^)" # programme variables beginning_finished = False poke_count = 0 +day = 15 diff --git a/tamagotchi.py b/tamagotchi.py index 2546eb5..d40c80d 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -31,7 +31,7 @@ while pet_functions.is_alive(): print("What would you like to do?") # Start the chosen activity and go back to the activity selector. print("1: Feeding, 2: Playing, 3: Stroke Pet,") - print("4: Poking, 5: Show Stats,") + print("4: Poking, 5: Sleeping, 6: Show Stats") try: chosen_activity = int(input("Choose the desired activity:")) if chosen_activity == 1: @@ -43,6 +43,8 @@ while pet_functions.is_alive(): elif chosen_activity == 4: pet_functions.poking() elif chosen_activity == 5: + pet_functions.sleeping() + elif chosen_activity == 6: pet_functions.pet_stats() except ValueError: pet_functions.pet_stats()