Commit bf90f925 by BellCodeEditor

auto save

parent 48a9a0bf
Showing with 51 additions and 11 deletions
import random import random
lantiao = 10
hit = [7000,8000,9000,10000]
cint = random.choice(hit)
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.level = 1 self.level = 1
self.hp = 250 self.hp = 135000
self.attack = 40 self.attack = 8888
self.max_hp = self.hp self.max_hp = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp+=55 self.hp+=cint
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+"服用了一枚治疗丹,血量增加:", cint,",目前的血量为:",self.hp)
lantiao += 1
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)+"点伤害,"
enemy.hp -= self.attack enemy.hp -= self.attack
lantiao += 1
if lantiao > 10:
lantiao = 10
if enemy.hp > 0: if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量" info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3 info = info1+info2+info3
...@@ -25,14 +32,39 @@ class Hero(object): ...@@ -25,14 +32,39 @@ class Hero(object):
info3 = enemy.name+"阵亡,游戏结束" info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
print('你干嘛啊~~') if enemy.hp <= 0:
print("胜利")
if self.hp <= 0:
print("失败")
exit()
def qiang(self,enemy):
self.huai = self.attack+5000
infu1 = self.name+"对"+enemy.name+"发起攻击,"
infu2 = "造成"+str(self.huai)+"点伤害,"
enemy.hp -= self.huai
lantiao += 1
if lantiao > 10:
lantiao = 10
if enemy.hp > 0:
infu3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
infu = infu1+infu2+infu3
print(infu)
else:
infu3 = enemy.name+"阵亡,游戏结束"
infu = infu1+infu2+infu3
print(infu)
if enemy.hp <= 0:
print("胜利")
if self.hp <= 0:
print("失败")
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)
self.hp = 200 self.hp = 140000
self.attack = 50 self.attack = 8688
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)
...@@ -46,15 +78,21 @@ class Player(Hero): ...@@ -46,15 +78,21 @@ class Player(Hero):
self.hp=self.max_hp self.hp=self.max_hp
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强化")
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:
if lantiao >= 8:
lantiao -= 8
houyi.qiang(yase)
else:
print("蓝条不够,不可使用")
elif a=="q": elif a=="q":
print('游戏结束') print('游戏结束')
break break
...@@ -64,6 +102,8 @@ while True: ...@@ -64,6 +102,8 @@ while True:
b=random.randint(1,3) b=random.randint(1,3)
if b==3: if b==3:
yase.cure() yase.cure()
if b==2:
yase.qiang(houyi)
else: else:
yase.combat(houyi) 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