Commit bbd2ab37 by BellCodeEditor

auto save

parent 82bf6a86
Showing with 12 additions and 7 deletions
...@@ -3,12 +3,12 @@ class Hero(object): ...@@ -3,12 +3,12 @@ class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.level = 1 self.level = 1
self.hp = 250 self.hp = 350
self.attack = 40 self.attack = 45
self.max_hp = self.hp self.max_hp = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp+=55 self.hp+=random.randint(40,55)
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+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
...@@ -35,8 +35,8 @@ class Hero(object): ...@@ -35,8 +35,8 @@ class Hero(object):
class Player(Hero): class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
super().__init__(name) super().__init__(name)
self.hp = 210 self.hp = 310
self.attack = 60 self.attack = 50
self.max_hp = self.hp self.max_hp = self.hp
self.hero_type = hero_type self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type) print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
...@@ -52,6 +52,8 @@ houyi = Player("射手", "后羿")#yase = Player("战士","垭瑟") ...@@ -52,6 +52,8 @@ houyi = Player("射手", "后羿")#yase = Player("战士","垭瑟")
yase = Hero("垭瑟")#houyi = Hero("射手", "后羿") yase = Hero("垭瑟")#houyi = Hero("射手", "后羿")
print(" !!战斗开始!!") print(" !!战斗开始!!")
print("-"*50) print("-"*50)
c = 290
d = 250
while True: while True:
a = input("你要使用什么技能?(1攻击/2治疗/q退出)") a = input("你要使用什么技能?(1攻击/2治疗/q退出)")
if a=='1': if a=='1':
...@@ -65,8 +67,9 @@ while True: ...@@ -65,8 +67,9 @@ while True:
print("请重新输入") print("请重新输入")
continue continue
#b = random.randint(1,2) #b = random.randint(1,2)
if yase.hp==150: if yase.hp<=c:
houyi.shengji() houyi.shengji()
c -= 60
b = input("你要使用什么技能?(1攻击/2治疗/q退出)") b = input("你要使用什么技能?(1攻击/2治疗/q退出)")
if b=='1': if b=='1':
yase.combat(houyi) yase.combat(houyi)
...@@ -78,7 +81,9 @@ while True: ...@@ -78,7 +81,9 @@ while True:
else: else:
print("请重新输入") print("请重新输入")
continue continue
if houyi.hp<=d:
yase.shengji()
d -= 50
# houyi.combat(yase) # houyi.combat(yase)
# yase.combat(houyi) # yase.combat(houyi)
# houyi.cure() # houyi.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