Commit ebdeccfe by BellCodeEditor

save project

parent 0cf4adde
Showing with 16 additions and 10 deletions
......@@ -7,6 +7,12 @@ class Hero(object):
self.attack = 40
self.max_hp = self.hp
def cure(self):
self.hp+=60
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
......@@ -35,12 +41,12 @@ class Player(Hero):
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
print('-'*30)
print(' 战斗开始')
def cure(self):
c=random.randint(35,50)
self.hp+=c
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
def cure(self):
c=random.randint(35,50)
self.hp+=c
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
......@@ -50,7 +56,7 @@ while True:
if a == "1":
houyi.combat(yase)
elif a == "2":
cure(houyi)
houyi.cure()
elif a == "q":
print("游戏退出")
break
......@@ -59,10 +65,10 @@ while True:
continue
num=random.randint(1,3)
if num == "1" or "2":
if num == 1 or num==2:
yase.combat(houyi)
elif num == "3":
cure(yase)
elif num == 3:
yase.cure()
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