Commit 70d7949f by BellCodeEditor

save project

parent 7ff9be45
Showing with 15 additions and 9 deletions
......@@ -5,6 +5,7 @@ class Hero: # 英雄类
self.name = name
self.level = 1
self.hp = '出错了!"hp"未设置'
self.hp_max = self.hp
self.attack = '出错了!"attack"未设置'
self.max_hp = self.hp
......@@ -23,14 +24,19 @@ class Hero: # 英雄类
print(info)
exit()
def ziliao(self, ememy):
ememy.hp = ememy.hp + 10
print(str(ememy.name),'回血成功!血量加10点,目前血量:',str(ememy.hp))
def cure(self):
self.hp = self.hp + 10
if self.hp > self.hp_max:
self.hp = 250
print(str(self.name),'血量已达到最大限制!')
else:
print(str(self.name),'回血成功!血量加10点,目前血量:',str(self.hp))
class Player(Hero): # 玩家英雄
def __init__(self,name,hp,attack):
super().__init__(name)
self.hp = hp
self.hp_max = self.hp
self.attack = attack
print(str(self.name)+'创建成功!血量:',str(self.hp),',攻击力:',str(self.attack))
......@@ -42,10 +48,10 @@ while True:
user_input = str(input('请选择英雄技能(1:攻击,2:回血)'))
if user_input == "1":
player1.combat(player2)
pl_hp_a = player2.hp
if pl_hp_a < 20:
player1.ziliao(player2)
else:
if player2.hp > 50:
player2.combat(player1)
else:
player2.cure()
if user_input == "2":
player2.ziliao(player1)
\ No newline at end of file
player2.cure()
player1.cure()
\ 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