Commit 4822cce2 by BellCodeEditor

save project

parent 96ec2fe8
Showing with 4 additions and 8 deletions
......@@ -5,8 +5,9 @@ class Hero(object):
self.hp = 250
self.attack = 40
self.name = name
def combat(self,enemy): # 攻击
def combat(self,enemy):
enemy.hp = enemy.hp - self.attack
info1 = self.name + "对" + enemy.name + "发起了进攻"
info2 = "造成了" + str(self.attack) + "点伤害"
......@@ -18,13 +19,8 @@ class Hero(object):
info4 = enemy.name + "阵亡,游戏结束"
info = info1 + info2 + info4
print(info)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(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