Commit fb191aba by BellCodeEditor

save project

parent 40518f79
Showing with 15 additions and 5 deletions
......@@ -8,10 +8,10 @@ class Hero(object):
self.max_hp = self.hp
def cure(self): # 治疗
self.hp += 60
self.hp += -60
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+",血量增加:", 60,",目前的血量为:",self.hp)
print(self.name+"看了会好康的,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
......@@ -31,14 +31,22 @@ class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.attack = 60
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)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
def cure(self): # 治疗
n = random.randint(30,50)
self.hp +=
self.hp += random.randint(30,50)
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"看了会好康的,血量增加:",n ,",目前的血量为:",self.hp)
houyi = Player("射手", "阿伟")
yase = Hero("杰哥")
print("="*30)
print(" 开始战斗 ")
while True:
......@@ -46,6 +54,8 @@ while True:
choice = input("请选择技能(1攻击/2治疗)")
if choice == "q":
print("老子投降")
print("杰哥:让我看看!")
print("你:不要!")
break
elif choice == "1":
houyi.combat(yase)
......
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