Commit 4c00dbd9 by BellCodeEditor

auto save

parent a4aedcb5
Showing with 10 additions and 6 deletions
......@@ -5,15 +5,19 @@ class Hero:
self.attack=40
self.name=name
def a(self,enemy):
infot1=self.name+"对"+enemy.name+"发起了攻击"
infot2="造成"+str(self.attack)+"的伤害"
enemy.hp-=self.attack
if enemy.hp>0:
infot1=self.name+"对"+enemy.name+"发动了攻击"
infot2="造成"+str(self.attack)+"点伤害"
infot3=enemy.name+"还剩"+str(enemy.hp)+"滴血"
infot=infot1+infot2+infot3
print(infot)
else:
infot3=enemy.name+"被杀,游戏结束!"
infot3=enemy.name+"已阵亡,游戏结束"
infot=infot1+infot2+infot3
print(infot)
exit()
yase=Hero("亚瑟")
houyi=yase.a("后裔")
print(houyi)
houyi=Hero("后裔")
yase.a(houyi)
yase.a(houyi)
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