Advertisement
lzerokoo

Classgame

Mar 6th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.58 KB | None | 0 0
  1. # -*- coding: cp1252 -*-
  2. import random
  3. class Jugador(object):
  4.     def __init__(self, nombre="Jugador"):
  5.         self.nombre= nombre
  6.         self.hp_max=random.randrange(45,55)
  7.         self.mp_max=random.randrange(40,50)
  8.         self.fuerza=random.randrange(3,7)
  9.         self.inteligencia=random.randrange(2,5)
  10.         self.hp=self.hp_max
  11.         self.mp=self.mp_max
  12.         self.habilidades=[Bola_de_fuego(),Golpe_letal(),Golpear()]
  13.     def __str__(self):
  14.         return str(self.nombre)+" HP" +str(self.hp_max)+"/"+str(self.hp)
  15.     def stats(self):
  16.         print self.nombre
  17.         print "Hp: ",self.hp_max," (max) / ",self.hp
  18.         print "Mp: ",self.mp_max, " (max)/ ", self.mp
  19.         print "Fuerza:",self.fuerza
  20.         print "Inteligencia:",self.inteligencia
  21.     def eleccion(self):
  22.         print "Elija una habilidad"
  23.         print "0-Bola de fuego (10 MP)"
  24.         print "1-Golpe Letal (5 MP)"
  25.         print "2-Golpear (0 MP)"
  26.         try:
  27.             x= input("> ")
  28.             values=[0,1,2]
  29.             if x in values:
  30.                 return x
  31.             else:
  32.                 print "Has usado un valor no valido\nataque por defecto:\nGolpear"
  33.                 x=2
  34.         except:
  35.             print "Has usado un valor no valido\nataque por defecto:\nGolpear"
  36.             x=2
  37.             x=int(x)
  38.         return x
  39. class AI(object):
  40.     def __init__(self):
  41.         self.hp_max=random.randrange(50,65)
  42.         self.mp_max=random.randrange(40,50)
  43.         self.fuerza=random.randrange(3,7)
  44.         self.inteligencia=random.randrange(2,5)
  45.         self.hp=self.hp_max
  46.         self.mp=self.mp_max
  47.         self.habilidades=[Bola_de_fuego(),Golpe_letal(),Golpear()]
  48.     def __str__(self):
  49.         return "AI: " + " HP" +str(self.hp_max)+"/"+str(self.hp)
  50.     def stats(self):
  51.         print "Hp: ",self.hp_max," (max) / ",self.hp
  52.         print "Mp: ",self.mp_max, " (max)/ ", self.mp
  53.         print "Fuerza",self.fuerza
  54.         print "Inteligencia",self.inteligencia
  55.     def eleccion(self):
  56.         x=random.randrange(0,3)
  57.         return x
  58. class Bola_de_fuego(object):
  59.     def __init__(self):
  60.         self.dano=0
  61.         self.nombre="BOLA DE FUEGO"
  62.     def devolver_ataque(self,origen):
  63.         if origen.mp<10:
  64.             return 0
  65.         else:
  66.             self.dano=random.randrange(13,19)+origen.inteligencia
  67.             origen.mp+= -10
  68.             return self.dano
  69. class Golpe_letal(object):
  70.     def __init__(self):
  71.         self.nombre="GOLPE LETAL"
  72.         self.dano=0
  73.     def devolver_ataque(self,origen):
  74.         if origen.mp<5:
  75.             return 0
  76.         else:
  77.             self.dano=random.randrange(7,15)+origen.fuerza
  78.             origen.mp-=5
  79.             return self.dano
  80. class Golpear(object):
  81.     def __init__(self):
  82.         self.nombre="Golpear"
  83.         self.dano=0
  84.     def devolver_ataque(self,origen):
  85.         self.dano=origen.fuerza+origen.inteligencia
  86.         return self.dano
  87.  
  88. def sumatoria(a,b):
  89.     return a+b
  90. def main():
  91.     ldano1=[]
  92.     ldano2=[]
  93.     try:
  94.         modo=input(" BIENVENIDOS A CLASS GAME\nModo de juego\n1-Single Player\n2-Multiplayer\n> ")
  95.     except:
  96.         print "Has ingresado un dato invalido, mode de juego por defecto:\n1 Jugador"
  97.         modo=1
  98.     if modo==1:
  99.         j2=AI()
  100.     if modo==2:
  101.         name=raw_input("ingrese su nombre j2; ")
  102.         j2=Jugador(name)
  103.     name=raw_input("ingrese su nombre j1: ")
  104.     j1=Jugador(name)
  105.     print"STATS J1"
  106.     j1.stats()
  107.     tiempo=raw_input("....")
  108.     print "STATS J2"
  109.     j2.stats()
  110.     tiempo=raw_input(".....")
  111.     while j1.hp>0 and j2.hp>0:
  112.  
  113.         print "Turno J1"
  114.         print j1
  115.         print "mp",j1.mp
  116.         print j2
  117.         elec1=j1.eleccion()
  118.         print "Se utilizo la hablidad",j1.habilidades[elec1].nombre
  119.         dano1=j1.habilidades[elec1].devolver_ataque(j1)
  120.         print "dano efectuado",dano1
  121.         ldano1.append(dano1)
  122.         j2.hp-=dano1
  123.         if j1.hp<=0 or j2.hp<=0:
  124.             break
  125.         tiempo=raw_input(".....")
  126.         print "...."
  127.         print "Turno J2"
  128.         print j1
  129.         print j2
  130.         print "mp",j2.mp
  131.         elec2=j2.eleccion()
  132.         print "Se utilizo la hablidad",j2.habilidades[elec2].nombre
  133.         dano2=j2.habilidades[elec2].devolver_ataque(j2)
  134.         print "dano efectuado",dano2
  135.         ldano2.append(dano2)
  136.         j1.hp-=dano2
  137.         tiempo=raw_input(".....")
  138.     if j1.hp>0:
  139.         print "Gano j1"
  140.     else:
  141.         print "Gano j2"
  142.     ldano1=tuple(ldano1)
  143.     ldano2=tuple(ldano2)
  144.     dmg1=reduce(sumatoria,ldano1)
  145.     dmg2=reduce(sumatoria,ldano2)
  146.     return (dmg1,dmg2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement