Commit abf2a29d by BellCodeEditor

save project

parent 1f4f882d
Showing with 7 additions and 2 deletions
...@@ -7,8 +7,12 @@ class Hero: # 英雄类 ...@@ -7,8 +7,12 @@ class Hero: # 英雄类
self.max_hp = self.hp; self.max_hp = self.hp;
def cure(s): def cure(self):
self.max_hp self.hp += 60;
if self.hp > self.max_hp:
self.hp = self.max_hp;
print(self.name + "使用了治疗,血量增加了60");
def combat(self, enemy): # 攻击功能 def combat(self, enemy): # 攻击功能
info1 = self.name+"对"+enemy.name+"发起进攻,"; info1 = self.name+"对"+enemy.name+"发起进攻,";
...@@ -29,6 +33,7 @@ class Player(Hero): # 玩家英雄 ...@@ -29,6 +33,7 @@ class Player(Hero): # 玩家英雄
def __init__(self, name): def __init__(self, name):
super().__init__(name) super().__init__(name)
self.hp = 200; self.hp = 200;
self.max_hp = self.hp;
self.attack = 100; self.attack = 100;
print(self.name + "创建成功,英雄类型为:Player"); print(self.name + "创建成功,英雄类型为:Player");
print("玩家的血量值为:",self.hp); print("玩家的血量值为:",self.hp);
......
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