小游戏-赌大小
import time
import random
name=input('请输入用户名:')
age=input('{}您好,请输入您的年龄:'.format(name))
user_info={'name':name,'age':int(age)}
user_properties=['X 1-5']
properties=['X3(250G)','X1-5(300G)']
if 10 < user_info['age'] <18:
gold=1000
elif 18<= user_info['age'] <30:
gold=1500
else:
gold=500
user_info['gold']=gold
print('{}您好,您的初始金币为{}'.format(user_info['name'],user_info['gold']))
print('\n')
time.sleep(2)
print('游戏说明'.center(50,'*'))
print('*'.ljust(53),'*')
print("*",end='')
print('电脑每次投掷三枚筛子,总点数>=10为大,否则为小'.center(32),end='')
print('*')
print('*'.ljust(53),'*')
print('*'*50)
print('\n')
result=input('是否开始游戏:(yes or no )')
if result.lower()=='yes':
while True:
dics=[]
for i in range(0,3):
dics.append(random.randint(1,6))
total=sum(dics)
user_guess=input('请输入大小(big or small:')
user_g=user_guess.strip().lower()
time.sleep(2)
print('筛子点数为{}'.format(dics),end='')
if (total>=10 and user_g=='big') or (total<10 and user_g=='small'):
print('您赢了!!!')
multi=1
if len(user_properties)>0:
answer=input('是否使用道具(yes or no ):')
if answer.lower()=='yes':
num=int(input('您拥有的道具有{},请选择使用第几个道具:'.format(user_properties )))
if user_properties[num]=='X 3':
muiti=3
print('奖金翻3倍')
elif user_properties=='X 1-5':
muiti=random.randint(1,5)
print('奖金翻%s'%(multi))
user_properties.remove(user_properties[num])
user_info['gold']+=100*multi
else:
user_info['gold']-=100
if user_info['gold']<=0:
print('您的金币已经用完,感谢您的游玩!!')
break
if user_info ['gold']%1000==0:
shop=input('您拥有的金币为{},请选择是否购买道具(yes or no):'.format(user_info['gold']))
if shop.lower()=='yes':
good_num=int(input('现有道具为{},请选择您要购买第几个道具:'.format(properties )))
if good_num ==1:
user_properties .append(properties[0])
user_info['gold']-=250
print('购买成功,花费250金币!')
else:
user_properties.append(properties[1])
user_info['gold']-=300
print('购买成功,花费300金币!')
else:
result2=input('您现有的金币为{},请选择是否继续玩游戏(y or n:'.format(user_info ['gold']))
else:
print('欢饮下次来玩!!!')
在这里插入代码片