Commit 956223a0 by BellCodeEditor

auto save

parent f47689a4
Showing with 27 additions and 0 deletions
class Hero:
def __init__(self,name):
self.hp = 250
self.level = 1
self.attack = 40
self.name = name
def combat(self,enemy):
enemy.hp = enemy.hp - self.attack
info1 = self.name+"对"+enemy.name+"发起攻击,"
info2 = "造成"+str(self.attack)+"伤害,"
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
print(info1+info2+info3)
def upgrade(self):
self.hp=self.hp+50
self.level=self.level+200
self.attack=self.attack+60
# def downgrade(self):
# self.hp=self.hp-1
# self.level=self.level-100
# self.attack=self.attack-400
houyi=Hero("后羿")
print("等级为:",houyi.level)
yase=Hero("亚瑟")
houyi.combat(yase)
yase.upgrade()
yase.combat(houyi)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment