import random
print('21点游戏开始啦!')
jb=5000
while True:
while True:
sf=input("是否玩?")
if sf=="否":
break
mon=int(input("%s%d%s"%("你的金币:",jb,",你要赌的金币(n>0,n<=金币数):")))
if mon!=0:
if mon<=jb:
break
print('你有两张牌,电脑也有(一张暗牌,一张名牌)是什么待会说。')
lap=random.randint(1,10)
fir=random.randint(1,10)
sec=random.randint(1,10)
print('你:')
print(fir)
print(sec)
print("目前和为:")
sum=fir+sec
print(sum)
print('接下来,问你是你可以回答1或2,1为继续发牌,2为停止发牌。')
for i in range(26):
ste=int(input('1 or 2 ?'))
if ste==1:
thi=random.randint(1,10)
print(thi)
print("目前和为:")
sum=sum+thi
print(sum)
if sum>21:
print("你爆牌了!")
break
elif ste==2:
break
else:
print("请认真审题")
print("电脑:")
print('?')
lapsum=0
tim=random.randint(1,5)
for i in range(tim):
lap=random.randint(1,10)
print(lap)
lapsum=lapsum+lap
if lapsum>21:
break
lapfir=random.randint(1,10)
print("电脑第一张是:")
print(lapfir)
lapsum=lapsum+lapfir
print("电脑和为:")
print(lapsum)
if sum>21:
if lapsum>21:
print("|平局|")
else:
print("|失败|")
jb=jb-mon
print(jb)
else:
if lapsum>21:
print("|胜利|")
jb+=mon
elif lapsum==sum:
print("|平局|")
elif lapsum>sum:
print("|失败|")
jb=jb-mon
print(jb)
else:
print("|胜利|")
jb+=mon
print("游戏结束!")#代码真长啊!
if jb==0:
print("no noney!")
break