day19作业

六月ゝ 毕业季﹏ 提交于 2019-11-30 22:50:36
class Hero():
    def __init__(self, nickname, aggressivity, life_value, money, armor):
        self.nickname = nickname
        self.aggressivity = aggressivity
        self.life_value = life_value
        self.money = money
        self.armor = armor

    def attack(self, enemy):
        damage_value = self.aggressivity - enemy.armor
        enemy.life_value -= damage_value

class Garen(Hero):
    camp = 'Demacia'
    def __init__(self, nickname,
                 aggressivity = 58,
                 life_value = 455,
                 money=100,
                 armor=10):
        Hero.__init__(self, nickname, aggressivity, life_value, money, armor)

class Riven(Hero):
    camp = 'Noxus'
    def __init__(self, nickname,
                 aggressivity = 54,
                 life_value = 414,
                 money=1001,
                 armor=3):
        Hero.__init__(self, nickname, aggressivity, life_value, money, armor)

class BlackCleaver:
    def __init__(self, price=475,
                 aggrev=9,
                 life_value = 100):
        self.price=price
        self.aggrev = aggrev
        self.life_value = life_value

    def fire(self, enemy):
        enemy.life_value -= 1000

    def update(self, owner):
        owner.money -= self.price
        owner.aggressivity += self.aggrev
        owner.life_value += self.life_value


r1 = Riven("草丛伦")
g1 = Garen("盖文")
b1 = BlackCleaver()
if r1.money > b1.price:
    r1.b1 = b1
    b1.update(r1)
print("r1 aggress",r1.aggressivity)
print("g1 armor", g1.armor)
print("g1 life_value", g1.life_value)
r1.attack(g1)
print("g1 life_value", g1.life_value)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!