Commit 746a8d7b by BellCodeEditor

save project

parent 0b22f59e
Showing with 15 additions and 8 deletions
# 英雄角色类
class Hero():
def __init__(self, name):
class Hero:
def __init__(self,name,Hero_type):
self.level = 1
self.hp = 350
self.attack = 40
......@@ -11,8 +11,15 @@ class Hero():
info2 = '造成' + str(self.attack) + '点伤害,'
if enemy.hp < 0:
info3 = enemy.name + '阵亡'
class Player():
super().__init__()
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
else:
info3= enemy.name + '还剩' + str(enemy.hp) + '生命'
print(info1 + info2 + info3)
class Player(Hero):
def __init__(self,name,Hero_type):
super().__init__(name,Hero_type)
self.hp = 350
self.attack = 30
self.Hero_type = Hero_type
print('角色'+self.name+'创建成功英雄类型为'+ self.Hero_type)
print('当前等级,血量,攻击力,分别为',self.level,self.hp,self.attack)
houyi = Player('后羿','射手')
\ 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