Commit a65bb31f by BellCodeEditor

auto save

parent beb166ed
Showing with 24 additions and 10 deletions
...@@ -6,13 +6,17 @@ class Hero(object): ...@@ -6,13 +6,17 @@ class Hero(object):
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.max_hp = self.hp self.max_hp = self.hp
self.jingshen = 10
def cure(self): # 治疗 def cure(self): # 治疗
self.hp+=55 self.hp+=55
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
elif self.jingshen == 0:
print(selfname+"被精神污染了,3秒后死亡")
time(3)
print("您已阵亡")
exit()
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻," info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害," info2 = "造成"+str(self.attack)+"点伤害,"
...@@ -25,9 +29,9 @@ class Hero(object): ...@@ -25,9 +29,9 @@ class Hero(object):
info3 = enemy.name+"阵亡,游戏结束" info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
print('你干嘛啊~~') print(enemy.name+':你干嘛~~诶哟~~')
print(self.name+':你是傻逼呀')
exit() exit()
class Player(Hero): class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
super().__init__(name) super().__init__(name)
...@@ -44,17 +48,30 @@ class Player(Hero): ...@@ -44,17 +48,30 @@ class Player(Hero):
self.hp+=c self.hp+=c
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp self.hp=self.max_hp
elif self.jingshen == 0:
print(selfname+"被精神污染了,3秒后死亡")
time(3)
print("您已阵亡")
exit()
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
while True: while True:
print('-'*30) print('-'*30)
a=input("请选择技能:1攻击/2治疗") a=input("请选择技能:1攻击/2治疗/3巴嘎武器/4呕呕/5全体目光向我看齐/6` OK do the 发")
if int(a)==1: if int(a)==1:
houyi.combat(yase) houyi.combat(yase)
elif int(a)==2: elif int(a)==2:
houyi.cure() houyi.cure()
elif int(a)==3:
houyi.hp -= houyi.hp
elif int(a)==4:
yase.jingshen -= 1
elif int(a)==5:
yase.jingshen -= 5
elif int(a)==6:
print("你已阵亡")
exit()
elif a=="q": elif a=="q":
print('游戏结束') print('游戏结束')
break break
...@@ -66,6 +83,3 @@ while True: ...@@ -66,6 +83,3 @@ while True:
yase.cure() yase.cure()
else: else:
yase.combat(houyi) yase.combat(houyi)
\ No newline at end of file
\ No newline at end of file
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