Commit 8cdb6686 by BellCodeEditor

save project

parent 1edbbbfd
Showing with 6 additions and 8 deletions
...@@ -9,7 +9,7 @@ class Hero(object): ...@@ -9,7 +9,7 @@ class Hero(object):
def combat(self,enemy): # 攻击 def combat(self,enemy): # 攻击
enemy.hp = enemy.hp - self.attack enemy.hp = enemy.hp - self.attack
info1 = self.name + "对" + enemy.name + "发起了进攻," info1 = self.name + "对" + enemy.name + "发起了进攻,"
info2 = "造成了" + str(self.attack) + "点伤," info2 = "造成了" + str(self.attack) + "点伤,"
if enemy.hp >0: if enemy.hp >0:
info3 = enemy.name + "还剩下" + str(enemy.hp) + "血量" info3 = enemy.name + "还剩下" + str(enemy.hp) + "血量"
info = info1+info2+info3 info = info1+info2+info3
...@@ -20,13 +20,11 @@ class Hero(object): ...@@ -20,13 +20,11 @@ class Hero(object):
print(info) print(info)
class player(Hero): class player(Hero):
def __init__(self,name): def __init__(self,name):
super().__init__(name) super().__init__(name)
self.hp = 250 self.hp = 200
self.attack = 40 self.attack = 50
print("角色,"+self.name+"创建成功")
print("角色的,等级,血量,伤害:"+str(self.level)+" "+str(self.hp)+" "+str(self.attack))
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= player("后羿") houyi= player("后羿")
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