Commit d4c7f1b1 by BellCodeEditor

save project

parent 2ec4afcd
Showing with 7 additions and 14 deletions
...@@ -3,15 +3,15 @@ class Hero(object): ...@@ -3,15 +3,15 @@ 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 = random.randint(100,200) self.hp = 250
self.attack = random.randint(50,250) self.attack = 40
self.max_hp = self.hp + (self.hp*0.2) self.max_hp = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp = self.hp + (self.hp*2) self.hp = self.hp + (self.hp*0.5)
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+"使用了治疗,血量增加:",(self.hp*1.2),",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", (self.hp*0.5),",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
...@@ -31,7 +31,7 @@ class Hero(object): ...@@ -31,7 +31,7 @@ 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 = 300 self.hp = 200
self.attack = 50 self.attack = 50
self.max_hp = self.hp self.max_hp = self.hp
self.hero_type = hero_type self.hero_type = hero_type
...@@ -59,8 +59,7 @@ while True: ...@@ -59,8 +59,7 @@ while True:
print('游戏结束') print('游戏结束')
break break
else: else:
print('—'*30) print('重输!')
print('重新输入1/2:')
continue continue
b=random.randint(1,3) b=random.randint(1,3)
if b==3: if b==3:
...@@ -68,9 +67,3 @@ while True: ...@@ -68,9 +67,3 @@ while True:
else: else:
yase.combat(houyi) yase.combat(houyi)
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