Commit 0b3f4081 by BellCodeEditor

save project

parent 9a581ef4
Showing with 12 additions and 3 deletions
...@@ -4,10 +4,19 @@ class Hero(object): ...@@ -4,10 +4,19 @@ class Hero(object):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(self,enemy):
self.hp-=enemy.attack
info1=enemy.name+'对'+self.name+'发起了进攻,'
info2='造成了'+str(enemy.attack)+'点伤害'
if self.hp > 0:
info3=self.name+'还剩'+str(self.hp)+'血量'
info=info1+info2+info3
print(info)
else:
print(info1+info2+self.name+'已阵亡')
exit()
def combat(): # 攻击
???
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
......
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