Commit 040fe162 by BellCodeEditor

save project

parent 194638e4
Showing with 25 additions and 23 deletions
import random
import tkinter.messagebox
lantiao = 0
hit = [7000,8000,9000,10000]
cint = random.choice(hit)
......@@ -15,7 +16,7 @@ class Hero(object):
self.hp+=cint
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"服用了一枚治疗丹,血量增加:", cint,",目前的血量为:",self.hp)
tkinter.messagebox.showerror(self.name+"服用了一枚治疗丹,血量增加:", cint,",目前的血量为:",self.hp)
lantiao = lantiao+1
def combat(self, enemy): # 普通攻击
global lantiao
......@@ -28,15 +29,15 @@ class Hero(object):
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
tkinter.messagebox.showerror(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
tkinter.messagebox.showerror(info)
if enemy.hp <= 0:
print("胜利")
tkinter.messagebox.showerror("胜利")
if self.hp <= 0:
print("失败")
tkinter.messagebox.showerror("失败")
exit()
def qiang(self,enemy):
......@@ -50,18 +51,18 @@ class Hero(object):
if enemy.hp > 0:
infu3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
infu = infu1+infu2+infu3
print(infu)
tkinter.messagebox.showerror(infu)
else:
infu3 = enemy.name+"阵亡,游戏结束"
infu = infu1+infu2+infu3
print(infu)
tkinter.messagebox.showerror(infu)
if enemy.hp <= 0:
print("胜利")
tkinter.messagebox.showerror("胜利")
if self.hp <= 0:
print("失败")
tkinter.messagebox.showerror("失败")
exit()
if lantiao < 8:
print("蓝条不够,不能使用")
tkinter.messagebox.showerror("蓝条不够,不能使用")
class Player(Hero):
def __init__(self,hero_type,name):
......@@ -70,33 +71,34 @@ class Player(Hero):
self.attack = 8688
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
print('-'*30)
print(' 战斗开始')
tkinter.messagebox.showerror("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
tkinter.messagebox.showerror("当前等级、血量、攻击力分别为:","self.level,self.hp,self.attack")
tkinter.messagebox.showerror("提示","'-'*30")
tkinter.messagebox.showerror("提示","' 战斗开始'")
def cure(self):
c=random.randint(35,50)
self.hp+=c
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
tkinter.messagebox.showerror(self.name+"使用了治疗,血量增加:",str(c),",目前的血量为:",self.hp)
houyi = Player("初级战将", "血影战神")
yase = Hero("只因少将")
while True:
print('-'*30)
a=input("请选择技能:1攻击/2治疗/3强化")
if int(a)==1:
a=tkinter.messagebox.askquestion("请选择技能:yes攻击/no治疗")
if a=="yes":
c = tkinter.messagebox.askquestion("请选择技能:yes伤害/no强化")
if c=="yes":
houyi.combat(yase)
elif int(a)==2:
houyi.cure()
elif int(a)==3:
else:
houyi.qiang(yase)
elif a=="no":
houyi.cure()
elif a=="q":
print('游戏结束')
tkinter.messagebox.showerror('游戏结束')
break
else:
print('重输!')
tkinter.messagebox.showerror('重输!')
continue
b=random.randint(1,3)
if b==3:
......
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