Commit 7349cff8 by BellCodeEditor

auto save

parent 733750f7
Showing with 104 additions and 35 deletions
try:
lb=[]
while True:
untie=int(input('请输入:'))
if untie=='q':
break
except:
print('输入错误,请输入数字')
else:
lb.append(untie)
print('_'*30)
\ No newline at end of file
print('hello world')
\ No newline at end of file
import random
class hero:
def __init__(a,name):
a.name=name
a.hp=random.randint(100,500)
a.g=random.randint(20,40)
a.luck=random.randint(1,10)
def gongji(self,enemy):
enemy.hp=enemy.hp-enemy.g
x1=self.name+"对"+enemy.name+'发起攻击,'
x2='造成'+str(self.g)+'伤害,'
if enemy.hp>0:
x3=enemy.name+'剩余'+str(enemy.hp)+'血量'
x=x1+x2+x3
print(x)
else:
print(enemy.name+"死亡,游戏结束")
exit()
class guaiwu(hero):
pass
palyer=hero(input('请输入英雄名:'))
yao=guaiwu("狐妖")
print(palyer.name)
print('血量',palyer.hp)
print('攻击',palyer.g)
print('*'*30)
print(yao.name)
print('血量',yao.hp)
print('攻击',yao.g)
print('*'*30)
while True:
palyer.gongji(yao)
yao.gongji(palyer)
\ No newline at end of file
# 报菜名
# 悟空和诺依到了一家特色餐馆,这家餐馆最大的特色就是有个自动报菜名机器人
# 通常它会自动说出今天的前菜有哪些汤有哪些主菜有哪些等等~
# 可是今儿它有些bug产生的结果很奇怪,你可以检查出来么?
today_menu={'前菜':{'熏鲢鱼':20,'生蚝':20,'面包':10},
'汤':{'玉米浓汤':15,'蔬菜汤':15,'海鲜汤':15},
'主菜':{'鱼':40,'虾':30,'蟹':20,'贝壳类':20},
'间菜':{'牛扒':25,'煨菜':25,'肉排':30},
"烧烤和沙拉":{'需要':15,'不需要':0},
'甜品':{'可丽露':20,'优格吐司':15,'蓝莓松饼':20}
}
for k,v in today_menu.items():
if k!="烧烤和沙拉" :
print('今日' + k + '有:')
for i in v:
print(i,end='')
#依次告诉客人今天的各类菜有哪些选择
print()
\ No newline at end of file
# new_data=''
# with open(r'C:\Users\18724\Desktop\123.txt','r',encoding='utf-8') as file1:
# #a=file1.read()
# #print(a)
# for data in file1:
# if '小黑:12本'in data:
# data=data.replace('小黑:12本','小黑: 11本')
# new_data+=data
# with open(r'C:\Users\18724\Desktop\123.txt','w',encoding='utf-8') as file1:
# file1.write(new_data)
# with open(r'C:\Users\18724\Desktop\123.txt','a',encoding='utf-8') as file1:
# file1.write('小王:3本\n')
# with open(r'C:\Users\18724\Desktop\123.txt','r',encoding='utf-8') as file1:
# a=file1.read()
class hero:
def __init__(self,name,hp,gong,level,type):
self.hp=hp
self.gong=gong
self.level=level
self.name=name
self.type=type
print('角色'+self.name+'已生成'+'英雄类型为:',self.type)
print('当前血量,攻击力,等级分别为:',self.hp,self.gong,self.level)
def dr(self,enemy):
enemy.hp-=self.gong
info1=self.name+'向'+enemy.name+'发起进攻,'
info2=enemy.name+'受到'+str(self.gong)+'伤害,'
if enemy.hp>0:
info3=enemy.name+'还剩'+str(enemy.hp)+'血量.'
info=info1+info2+info3
print(info)
else:
print('该英雄已阵亡')
class Player(hero):
def __init__(self,name):
self.name=name
self.hp=200
self.gong=50
# def sj(a):
# a.hp=a.hp+50
# a.fang=a.fang+50
# a.gong=a.gong+50
# a.level=a.level+1
# houyi=hero(5000,100,100,'后羿',1)
# yase=hero(6000,500,1,'亚瑟',1)
# print(houyi.hp)
# houyi.sj()
# print(houyi.hp)
# print(yase.hp)
# yase.sj()
# print(yase.hp)
yase=hero('亚瑟',500,30,1,'战士')
houyi=Player('后羿')
while True:
yase.dr(houyi)
if houyi.hp<=0:
break
houyi.dr(yase)
if yase.hp<=0:
break
\ 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