Commit e56d6619 by BellCodeEditor

save project

parent 9ef3d606
Showing with 14 additions and 4 deletions
...@@ -4,10 +4,20 @@ class Hero: ...@@ -4,10 +4,20 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
def upgrade(self):
self.level=self.level+1 def combat(self,enemy):
self.hp=self.hp+50 enemy.hp=self.attack
self.attack=self.attack+4 info1=self.nam+"对"+enemy.name+"发起进攻,"
info2="造成"+str(self.attack)+"点伤害,"
if enemy.hp>0:
info3=enemy.name+"还剩下"+str(self.hp)+"血量"
info=info1+info2+info3
print(info)
else:
info3=enemy.name+"阵亡,游戏结束"
info=info1+info2+info3
print(info)
yese=Hero("垭瑟",300,20) yese=Hero("垭瑟",300,20)
yese.upgrade() yese.upgrade()
......
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