Commit 65af4d89 by BellCodeEditor

save project

parent e35ede85
Showing with 19 additions and 4 deletions
......@@ -3,7 +3,7 @@ class Hero(object):
def __init__(self, name):
self.name = name
self.level = 1
self.hp = 250
self.hp = 300
self.attack = 40
self.max_hp = self.hp
......@@ -30,27 +30,42 @@ class Hero(object):
class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.hp = 10000000000000000
self.attack = 50
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
def cure(self): # 治疗
blood=random.randint(30,51)
self.hp=self.hp + blood
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",+blood,",目前的血量为:",self.hp)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print('-'*30)
print(' 战斗开始!')
print(" 按b键放彩蛋")
print(" 按q键放必杀")
while True:
print('-'*30)
choice=input("请选择战斗方式:(1攻击)/(2治疗)")
choice=input("请选择战斗方式:(1攻击/2治疗/w退出)")
if choice == "1":
houyi.combat(yase)
elif choice == "2":
houyi.cure()
elif choice == "q":
elif choice == "w":
print("游戏结束")
break
elif choice =="q":
print("游戏结束,后羿胜利")
break
elif choice =="b":
print("游戏结束,后羿挑衅亚瑟,亚瑟放必杀,后羿卒!")
break
else:
print("请重新输入1/2")
continue
......
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