Created
October 6, 2022 16:50
-
-
Save edo0xff/7e9abbaf4a47640bea2af7949187ee02 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
from __future__ import annotations | |
from random import random | |
class Jugador: | |
def __init__(self): | |
self.hp: int = 100 | |
self.mp: int = 100 | |
self.nombre: str = '' | |
self.ataque: int = 10 | |
self.posiones_mana: int = 5 | |
self.posiones_hp: int = 5 | |
def accionAtacar(self, objetivo: Jugador): | |
print(f"\n > {self.nombre} ha atacado a {objetivo.nombre}") | |
if self.mp >= 20: | |
ataque_aumento = int(self.ataque * random()) | |
print(f" > Usando mana aumenta su ataque en: {ataque_aumento}") | |
danio = self.ataque + ataque_aumento | |
self.mp -= 20 | |
else: | |
print(" > Sin mana, el ataque se reduce") | |
if random() > 0.5: | |
danio = 1 | |
else: | |
danio = 0 | |
objetivo.hp -= danio | |
print(f" > {objetivo.nombre} -{danio}hp") | |
def accionRecuperarVida(self): | |
print(f"\n > {self.nombre} quiere usar una pocion de vida...") | |
if self.posiones_hp > 0: | |
print(" > La usa con exito.") | |
self.hp += 50 | |
self.posiones_hp -= 1 | |
else: | |
print(" > No quedan posiones de vida!") | |
def accionRecuperarMana(self): | |
print(f"\n > {self.nombre} quiere usar una pocion de mana...") | |
if self.posiones_mana > 0: | |
print(" > La usa con exito") | |
self.mp += 50 | |
self.posiones_mana -= 1 | |
else: | |
print(" > No quedan posiones de mana!") | |
def mostrarDatos(self): | |
print("\n------------------------") | |
print(f" {self.nombre}") | |
print(f" HP: {self.hp}") | |
print(f" MP: {self.mp}") | |
print(f" Posiones de vida: {self.posiones_hp}") | |
print(f" Posiones de mana: {self.posiones_mana}") | |
print("------------------------") | |
jugador_1 = Jugador() | |
jugador_2 = Jugador() | |
print(""" | |
|\ /) | |
/\_\\__ (_// | |
| `>\-` _._ //`) | |
\ /` \\ _.-`:::`-._ // | |
` \|` ::: `|/ | |
| ::: | | |
|.....:::.....| | |
|:::::::::::::| | |
| ::: | | |
\ ::: / | |
\ ::: / | |
`-. ::: .-' | |
//`:::`\\ | |
// ' \\ | |
|/ \\ | |
Bienvenido a la arena de batalla por comandos! | |
---------------------------------------------- | |
""") | |
jugador_1.nombre = input("Jugador 1: Ingresa tu nombre: ") | |
jugador_2.nombre = input("Jugador 2: Ingresa tu nombre: ") | |
def menu_de_acciones(): | |
print("1) Atacar") | |
print("2) Recuperar mana") | |
print("3) Recuperar vida") | |
while True: | |
print(f"\nTurno de {jugador_1.nombre}") | |
menu_de_acciones() | |
accion = input(f"\n{jugador_1.nombre}, que quieres hacer: ") | |
if accion == "1": | |
jugador_1.accionAtacar(jugador_2) | |
elif accion == "2": | |
jugador_1.accionRecuperarMana() | |
elif accion == "3": | |
jugador_1.accionRecuperarVida() | |
jugador_1.mostrarDatos() | |
jugador_2.mostrarDatos() | |
if jugador_2.hp <= 0: | |
print(f"\n{jugador_2.nombre} perdiste!") | |
break | |
print(f"\nTurno de {jugador_2.nombre}") | |
menu_de_acciones() | |
accion = input(f"\n{jugador_2.nombre}, que quieres hacer: ") | |
if accion == "1": | |
jugador_2.accionAtacar(jugador_1) | |
elif accion == "2": | |
jugador_2.accionRecuperarMana() | |
elif accion == "3": | |
jugador_2.accionRecuperarVida() | |
jugador_1.mostrarDatos() | |
jugador_2.mostrarDatos() | |
if jugador_1.hp <= 0: | |
print(f"\n{jugador_1.nombre} perdiste!") | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment