Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: cp1252 -*-
- import random
- class Jugador(object):
- def __init__(self, nombre="Jugador"):
- self.nombre= nombre
- self.hp_max=random.randrange(45,55)
- self.mp_max=random.randrange(40,50)
- self.fuerza=random.randrange(3,7)
- self.inteligencia=random.randrange(2,5)
- self.hp=self.hp_max
- self.mp=self.mp_max
- self.habilidades=[Bola_de_fuego(),Golpe_letal(),Golpear()]
- def __str__(self):
- return str(self.nombre)+" HP" +str(self.hp_max)+"/"+str(self.hp)
- def stats(self):
- print self.nombre
- print "Hp: ",self.hp_max," (max) / ",self.hp
- print "Mp: ",self.mp_max, " (max)/ ", self.mp
- print "Fuerza:",self.fuerza
- print "Inteligencia:",self.inteligencia
- def eleccion(self):
- print "Elija una habilidad"
- print "0-Bola de fuego (10 MP)"
- print "1-Golpe Letal (5 MP)"
- print "2-Golpear (0 MP)"
- try:
- x= input("> ")
- values=[0,1,2]
- if x in values:
- return x
- else:
- print "Has usado un valor no valido\nataque por defecto:\nGolpear"
- x=2
- except:
- print "Has usado un valor no valido\nataque por defecto:\nGolpear"
- x=2
- x=int(x)
- return x
- class AI(object):
- def __init__(self):
- self.hp_max=random.randrange(50,65)
- self.mp_max=random.randrange(40,50)
- self.fuerza=random.randrange(3,7)
- self.inteligencia=random.randrange(2,5)
- self.hp=self.hp_max
- self.mp=self.mp_max
- self.habilidades=[Bola_de_fuego(),Golpe_letal(),Golpear()]
- def __str__(self):
- return "AI: " + " HP" +str(self.hp_max)+"/"+str(self.hp)
- def stats(self):
- print "Hp: ",self.hp_max," (max) / ",self.hp
- print "Mp: ",self.mp_max, " (max)/ ", self.mp
- print "Fuerza",self.fuerza
- print "Inteligencia",self.inteligencia
- def eleccion(self):
- x=random.randrange(0,3)
- return x
- class Bola_de_fuego(object):
- def __init__(self):
- self.dano=0
- self.nombre="BOLA DE FUEGO"
- def devolver_ataque(self,origen):
- if origen.mp<10:
- return 0
- else:
- self.dano=random.randrange(13,19)+origen.inteligencia
- origen.mp+= -10
- return self.dano
- class Golpe_letal(object):
- def __init__(self):
- self.nombre="GOLPE LETAL"
- self.dano=0
- def devolver_ataque(self,origen):
- if origen.mp<5:
- return 0
- else:
- self.dano=random.randrange(7,15)+origen.fuerza
- origen.mp-=5
- return self.dano
- class Golpear(object):
- def __init__(self):
- self.nombre="Golpear"
- self.dano=0
- def devolver_ataque(self,origen):
- self.dano=origen.fuerza+origen.inteligencia
- return self.dano
- def sumatoria(a,b):
- return a+b
- def main():
- ldano1=[]
- ldano2=[]
- try:
- modo=input(" BIENVENIDOS A CLASS GAME\nModo de juego\n1-Single Player\n2-Multiplayer\n> ")
- except:
- print "Has ingresado un dato invalido, mode de juego por defecto:\n1 Jugador"
- modo=1
- if modo==1:
- j2=AI()
- if modo==2:
- name=raw_input("ingrese su nombre j2; ")
- j2=Jugador(name)
- name=raw_input("ingrese su nombre j1: ")
- j1=Jugador(name)
- print"STATS J1"
- j1.stats()
- tiempo=raw_input("....")
- print "STATS J2"
- j2.stats()
- tiempo=raw_input(".....")
- while j1.hp>0 and j2.hp>0:
- print "Turno J1"
- print j1
- print "mp",j1.mp
- print j2
- elec1=j1.eleccion()
- print "Se utilizo la hablidad",j1.habilidades[elec1].nombre
- dano1=j1.habilidades[elec1].devolver_ataque(j1)
- print "dano efectuado",dano1
- ldano1.append(dano1)
- j2.hp-=dano1
- if j1.hp<=0 or j2.hp<=0:
- break
- tiempo=raw_input(".....")
- print "...."
- print "Turno J2"
- print j1
- print j2
- print "mp",j2.mp
- elec2=j2.eleccion()
- print "Se utilizo la hablidad",j2.habilidades[elec2].nombre
- dano2=j2.habilidades[elec2].devolver_ataque(j2)
- print "dano efectuado",dano2
- ldano2.append(dano2)
- j1.hp-=dano2
- tiempo=raw_input(".....")
- if j1.hp>0:
- print "Gano j1"
- else:
- print "Gano j2"
- ldano1=tuple(ldano1)
- ldano2=tuple(ldano2)
- dmg1=reduce(sumatoria,ldano1)
- dmg2=reduce(sumatoria,ldano2)
- return (dmg1,dmg2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement