Commit 13d53e21 by BellCodeEditor

auto save

parent 272439ec
Showing with 4 additions and 4 deletions
...@@ -7,15 +7,15 @@ class Hero(object): ...@@ -7,15 +7,15 @@ class Hero(object):
self.name = name self.name = name
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
infor1=self.name+"对"+enemy.name+"发起进攻" infor1=f"{self.name}对{enemy.name}发起进攻"
infor2="造成"+str(self.attack)+"点伤害" infor2=f"造成{str(self.attack)}点伤害"
enemy.hp-=self.attack enemy.hp-=self.attack
if enemy.hp>0: if enemy.hp>0:
infor3=enemy.name+"剩余"+str(enemy.hp)+"血" infor3=f"{enemy.name}剩余{str(enemy.hp)}血"
infor=infor1+infor2+infor3 infor=infor1+infor2+infor3
print(infor) print(infor)
else: else:
infor3=enemy.name+"阵亡,游戏结束" infor3="{enemy.name}阵亡,游戏结束"
infor=infor1+infor2+infor3 infor=infor1+infor2+infor3
print(infor) print(infor)
exit() exit()
......
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