用户:冥界阴阳查看:0 回复:0 评论:0 创建时间:2021-02-06T19:37:19
【作品展示】

【作品介绍】
初始本金是1000元,默认喵是1倍,赢了,获得一倍金额,输了,扣除1倍金额。玩家选择喵,押大或押小;
输入喵金额;
摇3个骰子,11≤骰子总数≤18为大,3≤骰子总数≤10为小;
如果赢了,获得1倍金额,输了,扣除1倍金额,本金为0时,游戏结束。
【作品源代码】
import random
def roll_dice(numbers=3, points=None):
print('----- 摇骰子 -----')
if points is None:
points = []
while numbers > 0:
point = random.randrange(1, 7)
points.append(point)
numbers = numbers - 1
return points
def roll_result(total):
isBig = 11 <= total <= 18
isSmall = 3 <= total <= 10
if isBig:
return '大'
elif isSmall:
return '小'
def start_game():
your_money = 1000
while your_money > 0:
print('----- 游戏开始 -----')
choices = ['大', '小']
your_choice = input('请喵,大 or 小:')
your_bet = input('喵金额:')
if your_choice in choices:
points = roll_dice()
total = sum(points)
youWin = your_choice == roll_result(total)
if youWin:
print('骰子点数:', points)
print('恭喜,你赢了 {} 元,你现在有 {} 元本金'.format(
your_bet, your_money + int(your_bet)))
your_money = your_money + int(your_bet)
else:
print('骰子点数:', points)
print('很遗憾,你输了 {} 元,你现在有 {} 元本金'.format(
your_bet, your_money - int(your_bet)))
your_money = your_money - int(your_bet)
else:
print('格式有误,请重新输入')
else:
print('游戏结束')
start_game()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn