Commit 77eea871 by BellCodeEditor

save project

parent 0578d6a0
Showing with 13 additions and 4 deletions
...@@ -9,6 +9,7 @@ class Hero: # 英雄类 ...@@ -9,6 +9,7 @@ class Hero: # 英雄类
def combat(self, enemy): # 攻击功能 def combat(self, enemy): # 攻击功能
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害," info2 = "造成"+str(self.attack)+"点伤害,"
...@@ -24,12 +25,20 @@ class Hero: # 英雄类 ...@@ -24,12 +25,20 @@ class Hero: # 英雄类
exit() exit()
class Player(Hero): # 玩家英雄 class Player(Hero): # 玩家英雄
def __init__(self,name): def __init__(self,name,q):
super().__init__(name) super().__init__(name)
self.hp = 200 self.hp = 200
self.attack = 50 self.attack = 50
self.q=q
print("角色,"+self.name+","+"成功创建,类型为:"+self.q)
print("玩家的名字为,攻击力为,血量值为:",self.name,self.attack,self.hp)
player = Player("后羿") player = Player("后羿",'射手')
print("玩家的血量值为:",player.hp) player = Player("凯",'射手')
print("玩家的攻击力为:",player.attack)
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