Advertisement
Guest User

Untitled

a guest
Dec 6th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. import random
  2. class human:
  3.     def __init__(self,life,name):
  4.         self.life = round(life * (random.randrange(80, 120, 1)/100))
  5.         self.name = name
  6.  
  7. class Warrior(human):
  8.  
  9.     def __init__(self,life, name, armor = 1, weaponpower = 1):
  10.         human.__init__(self, life, name)
  11.         self.armor = round(armor * (random.randrange(80, 120, 1)/100))
  12.         self.weaponpower = round(weaponpower * (random.randrange(80, 120, 1)/100))
  13.  
  14. firstwarrior = Warrior(100,"Rick",3,3)
  15. secondwarrior = Warrior(220, "Bart",1,2)
  16. print (firstwarrior.life) # проверки
  17. print(secondwarrior.life)
  18.  
  19.  
  20. print (f'{firstwarrior.name}, life {firstwarrior.life}, armor {firstwarrior.armor}, weapon {firstwarrior.weaponpower}, vs '
  21.        f'{secondwarrior.name}, life {secondwarrior.life}, armor {secondwarrior.armor}, weapon {secondwarrior.weaponpower}')
  22. print ("Let's Battle!")
  23.  
  24. # я могу сделать рандом и потом first или second бъёт другого, но хочется сделать больше войнов и соотв
  25. def createlistofwarriors():
  26.     listofwarriors = []
  27.     # моск сломался тут--->
  28.     for x in Warrior():
  29.         listofwarriors += Warrior.name
  30.     return listofwarriors
  31.  
  32. listofwarriors = createlistofwarriors()
  33.  
  34. print(listofwarriors)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement