Commit 4c00dbd9 by BellCodeEditor

auto save

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