Commit fdfa8e46 by BellCodeEditor

save project

parent d69056f4
Showing with 13 additions and 5 deletions
...@@ -7,8 +7,13 @@ class Hero(object): ...@@ -7,8 +7,13 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.max_hp = self.hp self.max_hp = self.hp
def asdfg(self):
self.attack+=80
print(self.name+"攻击力增加:", 80,",目前的攻击力为:",self.attack)
def cure(self): # 治疗 def cure(self): # 治疗
self.hp+=55 asd=random.randint(30,90)
self.hp+=asd
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)
...@@ -32,7 +37,7 @@ class Player(Hero): ...@@ -32,7 +37,7 @@ class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
super().__init__(name) super().__init__(name)
self.hp = 200 self.hp = 200
self.attack = 50 self.attack = 1
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)
...@@ -50,11 +55,13 @@ houyi = Player("射手", "后羿") ...@@ -50,11 +55,13 @@ houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
while True: while True:
print('-'*30) print('-'*30)
lamb=input('请选择释放英雄技能(1攻击/2治疗):') lamb=input('请选择释放英雄技能(1攻击/2治疗/3狂暴):')
if lamb=='1': if lamb=='1':
yase.combat(houyi) yase.combat(houyi)
elif lamb=='2': elif lamb=='2':
yase.cure() yase.cure()
elif lamb=='3':
yase.asdfg()
elif lamb =='p': elif lamb =='p':
print('退出') print('退出')
break break
...@@ -65,4 +72,6 @@ while True: ...@@ -65,4 +72,6 @@ while True:
if n==1: if n==1:
houyi.combat(yase) houyi.combat(yase)
elif n==2: elif n==2:
houyi.cure() houyi.cure()
\ No newline at end of file elif n==3:
houyi.asdfg()
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