Commit 40c2ed8c by BellCodeEditor

save project

parent abf2a29d
Showing with 12 additions and 3 deletions
...@@ -15,7 +15,7 @@ class Hero: # 英雄类 ...@@ -15,7 +15,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)+"点伤害,";
enemy.hp -= self.attack; enemy.hp -= self.attack;
if enemy.hp > 0: if enemy.hp > 0:
...@@ -39,4 +39,13 @@ class Player(Hero): # 玩家英雄 ...@@ -39,4 +39,13 @@ class Player(Hero): # 玩家英雄
print("玩家的血量值为:",self.hp); print("玩家的血量值为:",self.hp);
print("玩家的攻击力为:",self.attack); print("玩家的攻击力为:",self.attack);
player = Player("后羿"); player = Player("后羿");
\ No newline at end of file enemy = Hero("Imagime Dragons");
print("-" * 30 + '''
''' + " 战斗开始");
while 1:
Hero.combat() = input("请选择战斗(1)或治疗(2)");
Player.combat(player, enemy);
Hero.combat(enemy, 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