-
-
Save parzibyte/fa5d0d523d0ceebe783451bd1b869248 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
____ _____ _ _ _ | |
| _ \ | __ \ (_) | | | | |
| |_) |_ _ | |__) |_ _ _ __ _____| |__ _ _| |_ ___ | |
| _ <| | | | | ___/ _` | '__|_ / | '_ \| | | | __/ _ \ | |
| |_) | |_| | | | | (_| | | / /| | |_) | |_| | || __/ | |
|____/ \__, | |_| \__,_|_| /___|_|_.__/ \__, |\__\___| | |
__/ | __/ | | |
|___/ |___/ | |
____________________________________ | |
/ Si necesitas ayuda, contáctame en \ | |
\ https://parzibyte.me / | |
------------------------------------ | |
\ ^__^ | |
\ (oo)\_______ | |
(__)\ )\/\ | |
||----w | | |
|| || | |
Creado por Parzibyte (https://parzibyte.me). Este encabezado debe mantenerse intacto, | |
excepto si este es un proyecto de un estudiante. | |
""" | |
import random | |
class Tamagotchi: | |
def __init__(self, nombre): | |
genero = random.choice(["Masculino", "Femenino"]) | |
print("Tu Tamagotchi es " + genero) | |
self.genero = genero | |
self.nombre = nombre | |
self.hambre = 10 | |
self.felicidad = 10 | |
self.salud = 0 | |
def evento(self, accion): | |
self.hambre -= 1 | |
self.felicidad -= 1 | |
if accion == "alimentar": | |
self.alimentar() | |
elif accion == "jugar": | |
self.jugar() | |
def alimentar(self): | |
print("Has alimentado a " + self.nombre) | |
self.hambre += 2 | |
if self.hambre > 10: | |
# Sobrealimentado | |
self.salud += 2 | |
pass | |
def jugar(self): | |
print("Juegas con " + self.nombre) | |
self.felicidad += 3 | |
# Evitar sobrepasar | |
if self.felicidad > 10: | |
self.felicidad = 10 | |
def muere(self): | |
if self.salud >= 10 or self.felicidad <= 0 or self.hambre <= 0: | |
return True | |
else: | |
return False | |
def imprimir_estado(self): | |
print("Hambre: " + str(self.hambre)) | |
print("Felicidad: " + str(self.felicidad)) | |
print("Salud: " + str(self.salud)) | |
def main(): | |
nombre = input("Ingresa el nombre de tu Tamagotchi: ") | |
tamagotchi = Tamagotchi(nombre) | |
while not tamagotchi.muere(): | |
tamagotchi.imprimir_estado() | |
eleccion = "" | |
while not eleccion in ["1", "2", "3"]: | |
eleccion = input(""" | |
1. Alimentar | |
2. Jugar | |
3. Nada | |
Elige: """) | |
if eleccion == "1": | |
tamagotchi.evento("alimentar") | |
elif eleccion == "2": | |
tamagotchi.evento("jugar") | |
elif eleccion == "3": | |
tamagotchi.evento("") | |
print(tamagotchi.nombre + " ha muerto") | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment