Commit ae5b2bac by BellCodeEditor

save project

parent c96da38c
Showing with 17 additions and 3 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -6,7 +7,7 @@ class Hero(object): ...@@ -6,7 +7,7 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.max_hp = self.hp self.max_hp = self.hp
def cure(self,enemy): def cure(self):
self.hp+=65 # 治疗 self.hp+=65 # 治疗
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
...@@ -41,6 +42,20 @@ yase = Hero("垭瑟") ...@@ -41,6 +42,20 @@ yase = Hero("垭瑟")
print('-'*30) print('-'*30)
print(' 战斗开始') print(' 战斗开始')
while True: while True:
print('-'*30) print('-'*30)
a=input('请输入技能:1治疗/2攻击') a=input('请输入技能:1治疗/2攻击')
if a=='q':
\ No newline at end of file print('游戏结束!!!')
elif a== '1':
houyi.cure()
elif a=='2':
houyi.combat(yase)
else:
print('请重新输入!!!')
continue
nam=random.randint(1,3)
if nam==1:
yase.cure()
else:
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