Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. import random
  2. class Wojownik:
  3. Name = "dywan"
  4. Level = 0
  5. Exp = 500
  6. AExp = 0
  7. MaxHp = 30
  8. Ahp = 30
  9. MinDmg = 3
  10. MaxDmg = 6
  11. Names = ["Mietek", "Zenek", "Adolf", "Tadek", "Robert", "Dywan", "Bazant"]
  12. def __init__(self):
  13. self.Name = "Wojownik"
  14. self.Level = 0
  15. self.Exp = 500
  16. self.AExp = 0
  17. self.MaxHp = random.randint(20, 30)
  18. self.Ahp = self.MaxHp
  19. self.MinDmg = random.randint(1, 8)
  20. self.MaxDmg = self.MinDmg + random.randint(1, 3)
  21.  
  22.  
  23. def attack(self, Wojownik):
  24. Wojownik.Ahp = Wojownik.Ahp - random.randint(self.MinDmg, self.MaxDmg)
  25.  
  26. def lifeSteal(self, Wojownik):
  27. dmg = random.randint(self.MinDmg, self.MaxDmg)/2
  28. Wojownik.Ahp = Wojownik.Ahp - dmg
  29. if self.Ahp !=self.MaxHp:
  30. self.Ahp = self.Ahp + dmg
  31. if self.Ahp > self.MaxDmg:
  32. self.Ahp = self.MaxHp
  33.  
  34. def showHp(self):
  35. print(self.Ahp)
  36.  
  37. def showStats(self):
  38. print("Nazwa: %s\n Level: %d \n Exp: %d \n AExp %d \n MaxHp: %d \n Ahp: %d \n MinDmg: %d \n MaxDmg: %d \n" %(self.Name, self.Level, self.Exp, self.AExp, self.MaxHp, self.Ahp, self.MinDmg, self.MaxDmg))
  39.  
  40. def setName(self):
  41. self.Name = input("Podaj nazwe swojego wojownika")
  42.  
  43. def setName2(self):
  44. self.Name = self.Names[random.randint(0, len(self.Names) - 1)]
  45.  
  46.  
  47. postac = Wojownik()
  48. postac.setName()
  49.  
  50.  
  51. enemies = []
  52.  
  53. for i in range(10):
  54. p = Wojownik()
  55. p.setName2()
  56. enemies.append(p)
  57.  
  58. while postac.Ahp > 0:
  59. for i in enemies:
  60. while i.Ahp > 0 | postac.Ahp > 0:
  61. switch = int(input("1 Atak \n2 Lifesteal \n3 Pokaz statystyki \n4 Samobojstwo\n"))
  62. if switch == 1:
  63. postac.attack(i)
  64. elif switch == 2:
  65. postac.lifeSteal(i)
  66. elif switch == 3:
  67. postac.showStats()
  68. i.showStats()
  69. elif switch == 4:
  70. postac.Ahp = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement