Commit 508e62a0 by BellCodeEditor

save project

parent 2c419424
Showing with 7 additions and 2 deletions
...@@ -5,6 +5,7 @@ class Hero(object): ...@@ -5,6 +5,7 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
self.max.hp = self.hp
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
info1 = self.name + '对' + enemy.name + '造成了' + str(self.attack) + '点伤害,' info1 = self.name + '对' + enemy.name + '造成了' + str(self.attack) + '点伤害,'
...@@ -16,8 +17,11 @@ class Hero(object): ...@@ -16,8 +17,11 @@ class Hero(object):
info2 = enemy.name + '阵亡,游戏结束' info2 = enemy.name + '阵亡,游戏结束'
print(info1 + info2) print(info1 + info2)
exit() exit()
class Player(Hero):
def __init__(name):
super().__init__(name)
self.hp = 200
self.attack = 50
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