Last active
February 12, 2023 22:04
-
-
Save Haylin-chama/aaeac47fd0e0399fac33 to your computer and use it in GitHub Desktop.
Simulación de Batlla Pokemon en Python
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
#Nombre: funciones | |
#Autor: Equipo Pokeweas Python | |
#Fecha: 28-10-2014 | |
#Descripcion: Tarea Final (funciones) | |
import random | |
def Validar(): | |
a=raw_input("Valor: ") | |
if a.isdigit(): #Funcion para corroborar que una linea de caracteres correspondan exclusivamente a numeros | |
#Es una funcion bool de verdadero o falso | |
return a | |
print "Ingrese un valor numerico." | |
Validar() #Funcion que se llama a si misma en caso que no sea una linea de numeros | |
def ValidarEquipo(): | |
return a | |
def ValidarPokemons(): | |
#Validar cantidad de pokemons en el equipo. | |
a=int(Validar()) | |
if a>=1 and a<=6: | |
return a | |
print "Ingrese un valor entre 1 y 6 porfavor." | |
ValidarPokemons() #Funcion recursiva que se llama a si misma en caso que no sea un numero entre 1 y 6 | |
def Limpiar(): | |
import os | |
#En caso del que el sistema operativo sea WINDOWS | |
if os.name=='nt': | |
os.system('cls') #Limpiar Pantalla | |
#En caso del que el sistema operativo sea LINUS | |
if os.name=='posix': | |
os.system('clear') | |
def Lucha(): | |
return | |
def atk(): | |
return | |
def habilidades(): | |
return | |
#Planta#Fuego#Agua#Bicho#Normal#Veneno#Electrico#Tierra#Lucha#Psiquico#Roca#Fantasma#Hielo#Dragon | |
def eq_usuario(n_poke_eq, n): | |
arch="Equipo"+str(n)+".txt" | |
usuario=open(arch,"w") | |
print "\n Su equipo de ", n_poke_eq, " pokemons es:\n" | |
i=0 | |
while i!=n_poke_eq: | |
if n==1: | |
npoke=raw_input("Nombre Pokemon que quiere: ") | |
archivo=open("lista_pokemon.txt", "r") | |
a=False | |
for linea in archivo: | |
dato=linea.split(" ") | |
if dato[1]==npoke: | |
print "Pokemon",i+1, ": ",dato[1],'\n' | |
usuario.write(linea) | |
a=True | |
if a==False: | |
print "Pokemon no valido, ingrese pokemon",i | |
i=i-1 | |
i=i+1 | |
archivo.close() | |
if n==2: | |
num_p=random.randint(1, 151) | |
archivo=open("lista_pokemon.txt", "r") | |
for linea in archivo: | |
dato=linea.split(" ") | |
if int(dato[0])==num_p: | |
print "Pokemon",i+1, ": ",dato[1] ##Borar Linea al entregar | |
usuario.write(linea) | |
archivo.close() | |
i=i+1 | |
usuario.close() | |
def dan(A, P, D, B, E): | |
V=random.randint(85, 100) | |
dano=0.01*B*E*V*(((0.2*50+1)*A*P/(25*D))+2) | |
return dano | |
def B(atk, t_poke): | |
bono=1 | |
if t_atk==t_poke: | |
bono=1.5 | |
return bono | |
def E(t_poke_en_uso, t_poke_rival): | |
efectividad=1 | |
inmune=inmunidad(t_poke_en_uso, t_poke_rival) | |
resis, debil=resistencia(t_poke_en_uso, t_poke_rival) | |
if inmune==1: | |
efectividad=0 | |
else: | |
if resis==1: | |
efectividad=0.5 | |
if debil==1: | |
efectividad=2 | |
return efectividad | |
def inmunidad(t_poke_en_uso, t_poke_rival): | |
inmune=0 | |
if (t_poke_en_uso=="Normal") and (t_poke_rival=="Fantasma"): | |
inmune=1 | |
if (t_poke_en_uso=="Fantasma") and ((t_poke_rival=="Normal") or (t_poke_rival=="Lucha")): | |
inmune=1 | |
if (t_poke_en_uso=="Tierra") and (t_poke_rival=="Electrico"): | |
inmune=1 | |
return inmune | |
def resistencia(t_poke_en_uso, t_poke_rival): | |
resis=0 | |
debil=0 | |
if t_poke_en_uso=="Planta": | |
if (t_poke_rival=="Electrico") or (t_poke_rival=="Planta") or (t_poke_rival=="Tierra") or (t_poke_rival=="Agua"): | |
resis=1 | |
if (t_poke_rival=="Bicho") or (t_poke_rival=="Fuego") or (t_poke_rival=="Hielo") or (t_poke_rival=="Veneno"): | |
debil=1 | |
if t_poke_en_uso=="Fuego": | |
if (t_poke_rival=="Bicho") or (t_poke_rival=="Fuego") or (t_poke_rival=="Planta") or (t_poke_rival=="Hielo"): | |
resis=1 | |
if (t_poke_rival=="Tierra") or (t_poke_rival=="Roca") or (t_poke_rival=="Agua"): | |
debil=1 | |
if t_poke_en_uso=="Agua": | |
if (t_poke_rival=="Fuego") or (t_poke_rival=="Agua") or (t_poke_rival=="Hielo"): | |
resis=1 | |
if (t_poke_rival=="Electrico") or (t_poke_rival=="Planta"): | |
debil=1 | |
if t_poke_en_uso=="Bicho": | |
if (t_poke_rival=="Planta") or (t_poke_rival=="Lucha") or (t_poke_rival=="Tierra"): | |
resis=1 | |
if (t_poke_rival=="Fuego") or (t_poke_rival=="Roca"): | |
debil=1 | |
if t_poke_en_uso=="Normal": | |
if (t_poke_rival=="Lucha"): | |
debil=1 | |
if t_poke_en_uso=="Veneno": | |
if (t_poke_rival=="Bicho") or (t_poke_rival=="Planta") or (t_poke_rival=="Lucha") or (t_poke_rival=="Veneno"): | |
resis=1 | |
if (t_poke_rival=="Tierra") or (t_poke_rival=="Psiquico"): | |
debil=1 | |
if t_poke_en_uso=="Electrico": | |
if (t_poke_rival=="Electrico"): | |
resis=1 | |
if (t_poke_rival=="Tierra"): | |
debil=1 | |
if t_poke_en_uso=="Tierra": | |
if (t_poke_rival=="Veneno") or (t_poke_rival=="Roca"): | |
resis=1 | |
if (t_poke_rival=="Planta") or (t_poke_rival=="Hielo") or (t_poke_rival=="Agua"): | |
debil=1 | |
if t_poke_en_uso=="Lucha": | |
if (t_poke_rival=="Bicho") or (t_poke_rival=="Roca"): | |
resis=1 | |
if (t_poke_rival=="Psiquico"): | |
debil=1 | |
if t_poke_en_uso=="Psiquico": | |
if (t_poke_rival=="Psiquico") or (t_poke_rival=="Lucha"): | |
resis=1 | |
if (t_poke_rival=="Bicho") or (t_poke_rival=="Fantasma"): | |
debil=1 | |
if t_poke_en_uso=="Roca": | |
if (t_poke_rival=="Normal") or (t_poke_rival=="Fuego") or (t_poke_rival=="Veneno"): | |
resis=1 | |
if (t_poke_rival=="Lucha") or (t_poke_rival=="Planta") or (t_poke_rival=="Tierra") or (t_poke_rival=="Agua"): | |
debil=1 | |
if t_poke_en_uso=="Fantasma": | |
if (t_poke_rival=="Bicho") or (t_poke_rival=="Veneno"): | |
resis=1 | |
if (t_poke_rival=="Fantasma"): | |
debil=1 | |
if t_poke_en_uso=="Hielo": | |
if (t_poke_rival=="Hielo"): | |
resis=1 | |
if (t_poke_rival=="Lucha") or (t_poke_rival=="Fuego") or (t_poke_rival=="Roca"): | |
debil=1 | |
if t_poke_en_uso=="Dragon": | |
if (t_poke_rival=="Fuego") or (t_poke_rival=="Electrico") or (t_poke_rival=="Planta") or (t_poke_rival=="Agua"): | |
resis=1 | |
if (t_poke_rival=="Dragon") or (t_poke_rival=="Hielo"): | |
debil=1 | |
return resis, debil | |
#De aqui en adelante es un metodo de prueba para consola, luego lo borro. | |
##NO TOCAR## | |
def main(): | |
print " Bienvenido\n" | |
reinicio=1 | |
while reinicio!=0: | |
print "\nIngrese el numero de combates que desea..." | |
n_combates=Validar() | |
Limpiar() | |
print "\nPlayer 1:\n Ingrese numero de pokemon por equipo (entre 1 y 6)" | |
n_poke_eq=ValidarPokemons() | |
Limpiar() | |
usuario1=eq_usuario(n_poke_eq,1) | |
print "\nComputador: " | |
#Debe tener la misma cantidad de pokemones que uno. | |
usuario2=eq_usuario(n_poke_eq,2) | |
print "\n Daremos paso a las batallas pokemon... \n" | |
raw_input("Pulsa una tecla para continuar...") | |
Limpiar() | |
for n_batalla in range(int(n_combates)): | |
print "La batalla n' ",n_batalla," esta a punto de empezar..." | |
raw_input() | |
print "Player 2:\n" | |
n_poke_eq2=ValidarPokemonsAleatorio() | |
usuario2=eq_usuario(n_poke_eq2, 2) | |
raw_input("Pulsa una tecla para continuar...") | |
if __name__ == '__main__': | |
try: | |
main()## your code, typically one function call | |
except: | |
import sys | |
print sys.exc_info()[0] | |
import traceback | |
print traceback.format_exc() | |
finally: | |
raw_input("Pulsa una tecla para continuar...") |
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
#Nombre: programa_principal | |
#Autor: Equipo Pokeweas Python | |
#Fecha: 28-10-2014 | |
#Descripcion: Tarea Final (principal) | |
import funciones | |
try: | |
print " Bienvenido\n" | |
reinicio=1 | |
while reinicio!=0: | |
print "\nIngrese el numero de combates que desea..." | |
n_combates=funciones.Validar() | |
funciones.Limpiar() | |
print "\nPlayer 1:\n Ingrese numero de pokemon por equipo (entre 1 y 6)" | |
n_poke_eq=funciones.ValidarPokemons() | |
funciones.Limpiar() | |
usuario1=funciones.eq_usuario(n_poke_eq,1) | |
print "\nComputador: " | |
#Debe tener la misma cantidad de pokemones que uno. | |
usuario2=funciones.eq_usuario(n_poke_eq,2) | |
print "\n Daremos paso a las batallas pokemon... \n" | |
raw_input("Pulsa una tecla para continuar...") | |
funciones.Limpiar() | |
for n_batalla in range(int(n_combates)): | |
print "La batalla n' ",n_batalla," esta a punto de empezar..." | |
raw_input() | |
print "Player 2:\n" | |
n_poke_eq2=funciones.ValidarPokemonsAleatorio() | |
usuario2=funciones.eq_usuario(n_poke_eq2, 2) | |
raw_input("Pulsa una tecla para continuar...") | |
except: | |
import sys | |
print sys.exc_info()[0] | |
import traceback | |
print traceback.format_exc() | |
finally: | |
raw_input("Pulsa una tecla para continuar...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment