From 3aee60bbc475fbaacfa56af6f927ebbbe2361b98 Mon Sep 17 00:00:00 2001 From: Nebucatnetzer Date: Sun, 12 Jul 2015 22:11:47 +0200 Subject: [PATCH] stuff inside which I don't know yet --- README.md | 5 ++- __pycache__/pet_functions.cpython-34.pyc | Bin 4150 -> 5071 bytes __pycache__/pet_variables.cpython-34.pyc | Bin 525 -> 550 bytes pet_functions.py | 51 ++++++++++++++++++++--- pet_variables.py | 1 + tamagotchi.py | 7 +++- 6 files changed, 54 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4ad6fd9..0489059 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,9 @@ Some interesting things I could add to the tamagotchi programme which shouldn't be too hard: -* poke it to make it speak, pokes let it loose a happiness point * 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. @@ -56,3 +54,6 @@ 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. +## 12.07.2015 +Added the function to poke the pet and it will speak. +If you poke to many times it will get angry. diff --git a/__pycache__/pet_functions.cpython-34.pyc b/__pycache__/pet_functions.cpython-34.pyc index abc493ca8061714487b43b0d8f28f7a7fdd5007a..98e8d6bd3203ec22499ce51fb6f45fa0bc6edfb6 100644 GIT binary patch literal 5071 zcmcIo&2Jmm5ufF9`6cSpmSx9D^OVGKnW|C~r%5ZMbyKB|6SOi4xiCx=6;^yJa>eB? z^LA;OMAD0UEKnfmA-(iaAcy`7z4y{TVUO)em;M1g^*6K2C9Oz6fFNA%uc{WHArs}_;Q*P?)^UC9Z+tXi%Ycg)Gk|jaG-Am8e}MT_IhiKY(S8G`@AA>!cf`7la1UB)ur~0_i2v%R-}Z zh4iY>i=@{`UlAGuu999CdYSY!(i=i!@O9ERgkB~60_mGVW8#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do$^_1TmluSA7x@1Igr7mO diff --git a/__pycache__/pet_variables.cpython-34.pyc b/__pycache__/pet_variables.cpython-34.pyc index b3332e1df56860f7543b267a9c0bc581b7e5e69e..08d1ccdac43bfd618987a6a1d07180ebd3d36d27 100644 GIT binary patch delta 103 zcmeBWS;nILj)#|P^^rxPGZ+~d9y1^TAfLejh>No(DyMNq2{5E^GX!h$OziRHc*z13 u_tO-dcxQuX6jwohc4~ZberaCGN`@jfpiB|l;^LHv%4y8On%om7`7--y3QT;yfpaB8 U5i3xth;{NB#xO>?$;?cO0BW@mR{#J2 diff --git a/pet_functions.py b/pet_functions.py index eef0373..792be50 100644 --- a/pet_functions.py +++ b/pet_functions.py @@ -1,14 +1,25 @@ +# imports the global variables import pet_variables +# imports the time library needed to delay certain functions import time +# imports the random library needed to generate a random number for +# the guessing game from random import randint +# imports the os library needed to clear the terminal import os +# imports the pygame library needed to play the sound in the +# poking function +from pygame import mixer + # variables needed for the guessing game secret = randint(1, 10) +### Functions providing the basic function of the programm +# a function which displays the pet's stats in a nice way.' def pet_stats(): - os.system('clear') #for Linux + os.system('clear') print(pet_variables.pet_name) print(pet_variables.pet_photo) print("Status: " + pet_variables.pet_status) @@ -60,10 +71,13 @@ 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.") +### Functions to increase and decrease stats ### def increase_hunger(): pet_variables.pet_hunger = pet_variables.pet_hunger + 1 +def increase_poke_count(): + pet_variables.poke_count = pet_variables.poke_count + 1 def increase_happiness(): if pet_variables.pet_happiness < pet_variables.max_happiness: @@ -89,6 +103,8 @@ def decrease_health(): if pet_variables.pet_health > 0: pet_variables.pet_health = pet_variables.pet_health - 1 +def decrease_poke_count(): + pet_variables.poke_count = pet_variables.poke_count - 1 # The function to decrease the stats and make the pet "live" needs to # run in the background. @@ -96,6 +112,7 @@ def decrease_stats(): while True: time.sleep(15) decrease_hunger() + decrease_poke_count() if pet_variables.pet_hunger <= 0: decrease_health() decrease_happiness() @@ -103,18 +120,20 @@ def decrease_stats(): ### Activities ### -# 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 -# and health. - +# A function which simulates stroking it doesn't have any +# effect on the pet. def stroking(): - os.system('clear') #for Linux + os.system('clear') print() print("You're stroking the back of your pet gently.") print("It makes comforting noises and leans against your hand.") time.sleep(1) +# 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 +# and health. def feeding(): + os.system('clear') print("Hungriness of " + pet_variables.pet_name + ": " + pet_variables.pet_hunger * "*") feeding_confirmed = input("Do you want to feed your pet?") if feeding_confirmed in ("Y", "y"): @@ -124,6 +143,7 @@ def feeding(): # A simple guessing game which increases the pet's happiness def playing(): guess = 0 + os.system('clear') while guess != secret: g = input("Guess the Number") guess = int(g) @@ -136,3 +156,22 @@ def playing(): print("Too low") increase_happiness() print("Game over!") + +# let's you poke the pet and it will talk +# if you poke it more than 3 times it will get angry at you +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() + mixer.init() + mixer.music.load('happy.mp3') + mixer.music.play() + time.sleep(5) + else: + print("You annoyed " + pet_variables.pet_name + "." + " It got angry at you.") + decrease_happiness() + mixer.init() + mixer.music.load('angry.mp3') + mixer.music.play() + time.sleep(3) diff --git a/pet_variables.py b/pet_variables.py index 2373b74..9fa9ca1 100644 --- a/pet_variables.py +++ b/pet_variables.py @@ -21,3 +21,4 @@ owl = "(^0M0^)" # programme variables beginning_finished = False +poke_count = 0 diff --git a/tamagotchi.py b/tamagotchi.py index b4b53b8..2546eb5 100644 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -29,9 +29,10 @@ while pet_functions.is_alive(): print() # Present the player with activities to choose from 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. - try: + print("1: Feeding, 2: Playing, 3: Stroke Pet,") + print("4: Poking, 5: Show Stats,") + try: chosen_activity = int(input("Choose the desired activity:")) if chosen_activity == 1: pet_functions.feeding() @@ -40,6 +41,8 @@ while pet_functions.is_alive(): elif chosen_activity == 3: pet_functions.stroking() elif chosen_activity == 4: + pet_functions.poking() + elif chosen_activity == 5: pet_functions.pet_stats() except ValueError: pet_functions.pet_stats()