Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class human:
- def __init__(self,life,name):
- self.life = round(life * (random.randrange(80, 120, 1)/100))
- self.name = name
- class Warrior(human):
- def __init__(self,life, name, armor = 1, weaponpower = 1):
- human.__init__(self, life, name)
- self.armor = round(armor * (random.randrange(80, 120, 1)/100))
- self.weaponpower = round(weaponpower * (random.randrange(80, 120, 1)/100))
- firstwarrior = Warrior(100,"Rick",3,3)
- secondwarrior = Warrior(220, "Bart",1,2)
- print (firstwarrior.life) # проверки
- print(secondwarrior.life)
- print (f'{firstwarrior.name}, life {firstwarrior.life}, armor {firstwarrior.armor}, weapon {firstwarrior.weaponpower}, vs '
- f'{secondwarrior.name}, life {secondwarrior.life}, armor {secondwarrior.armor}, weapon {secondwarrior.weaponpower}')
- print ("Let's Battle!")
- # я могу сделать рандом и потом first или second бъёт другого, но хочется сделать больше войнов и соотв
- def createlistofwarriors():
- listofwarriors = []
- # моск сломался тут--->
- for x in Warrior():
- listofwarriors += Warrior.name
- return listofwarriors
- listofwarriors = createlistofwarriors()
- print(listofwarriors)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement