Commit 3e5d910d by BellCodeEditor

save project

parent f00c0daa
Showing with 12 additions and 3 deletions
...@@ -6,9 +6,17 @@ class Hero(object): ...@@ -6,9 +6,17 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(): # 攻击 def combat(self,eab): # 攻击
??? eab.hp-=self.attack
l1=self.name+"对"+eab.name+"攻击"
l2="造成"+str(self.attack)+"伤害"
if eab.hp > 0:
l3=eab.name+"还剩下"+str(eab.hp)
ll=l1+l2+l3
print(ll)
else:
print(eab.name+"阵亡了"+"游戏结束")
exit()
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) 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