Commit c0021170 by BellCodeEditor

save project

parent 3ef7be28
Showing with 9 additions and 9 deletions
...@@ -8,10 +8,11 @@ class Hero(object): # 英雄类 ...@@ -8,10 +8,11 @@ class Hero(object): # 英雄类
self.max_hp = self.hp self.max_hp = self.hp
def cure(self): def cure(self):
self.hp+=60 a=random.randint(30,40)
self.hp+=a
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
print(self.name+'使用了治疗,血量增加:'+str(60)+',目前的血量为:',self.hp) print(self.name+'使用了治疗,血量增加:'+str(a)+',目前的血量为:',self.hp)
def combat(self, enemy): # 攻击功能 def combat(self, enemy): # 攻击功能
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
...@@ -39,12 +40,10 @@ class Player(Hero): # 玩家英雄 ...@@ -39,12 +40,10 @@ class Player(Hero): # 玩家英雄
print('当前等级、血量、攻击力分别为:',self.level,self.hp,self.attack) print('当前等级、血量、攻击力分别为:',self.level,self.hp,self.attack)
def cure(self): def cure(self):
a=random.randint(30,40) self.hp+=60
self.hp+=random.randint(30,40)
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
print(self.name+'使用了治疗,血量增加:'+str(a)+',目前的血量为:',self.hp) print(self.name+'使用了治疗,血量增加:'+'60'+',目前的血量为:',self.hp)
houyi = Player("射手","后羿") houyi = Player("射手","后羿")
yase = Hero('垭瑟') yase = Hero('垭瑟')
print('-'*30) print('-'*30)
...@@ -63,7 +62,7 @@ while True: ...@@ -63,7 +62,7 @@ while True:
print('请重新输入') print('请重新输入')
continue continue
status=random.randint(1,3) status=random.randint(1,3)
if status==3: if status==1:
yase.cure()
else :
yase.combat(houyi) yase.combat(houyi)
else :
yase.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