掷骰子游戏:

==========掷骰子游戏=========

可选择的参加游戏的角色是:1.貂蝉  2.刘备  3.孙悟空  4.诸葛亮 5.曹操

输入参加游戏的角色是: 1

貂蝉进入游戏……

貂蝉请充值(金额必须是100的倍数):   ---》注意:充值3次不成功退出游戏,----》注意: 如果充值成功

充值成功的金额是: 1000元

 

貂蝉请下注(必须是50的倍数,不能大于充值金额):   ---》可以反复下注

下注金额是:100

# 注意:是两个骰子 猜大 小  大:两个骰子的和大于6或者两个骰子相同,否则为小,系统产生两个1-6之间的随机数作为骰子的个数

貂蝉猜大小:大

如果猜对了,则下注金额翻倍加到总金额中,猜错了则总金额减去下注金额

 

询问是否下一轮游戏? --注意: 可以继续下一轮游戏,仍然从下注开始

 

 

import random
import time


def start_game():
'''开始猜大小的游戏'''
print("欢迎进入掷骰子游戏游戏!!")
your_name = input('输入玩家姓名: ')
names = ['刘备', '张飞','貂蝉']
if your_name in names:
print("玩家{}进入游戏".format(your_name))
else:
print('Invalid input!')
current_money = 0 # 币
print('You have ${} now.请充钱!!'.format(current_money))
time.sleep(1)
current_money = int(input("请输入充值金额(金额必须是100的倍数):")) # 冲钱
a = 0
while a > 3:


if current_money % 100 == 0:
print('充值成功,You have ${} now.'.format(current_money))
break
else:
print("充值必须是100的倍数,充值不成功请再次充值!")
a += 1
continue

shaiz1 = random.randint(0, 6)
shaiz2 = random.randint(0, 6)
shaiz = shaiz1 + shaiz2 # 筛子数字总和
print(shaiz)
while current_money > 0:
print('<<<<<<<<<<<<<<<<<<<< Game Starts! >>>>>>>>>>>>>>>>>>>>')

put_money = int(input("请输入下注金额:(必须是50的倍数,不能大于充值金额)"))

if put_money % 50 != 0 and put_money > current_money:
continue
else:
print('You have ${} now.'.format(current_money))
your_choice = input('Big or Small: ')
choices = ['Big', 'Small']
if your_choice in choices:
pass
else:
print('Invalid input!')
if your_choice == 'Big':
if shaiz > 6:
print("答对了哦!")
current_money += put_money * 2
print('You have ${} now.'.format(current_money))
play_again = input("是否继续?--yes/no:")
if play_again == "yes":
continue
elif play_again == 'no':
break
else:
print("错了哦!")
current_money -= put_money
print('You have ${} now.'.format(current_money))
play_again = input("是否继续?--yes/no:")
if play_again == "yes":
continue
elif play_again == 'no':
break
if your_choice == 'Small':
if shaiz < 6:
print("答对了哦!")
current_money += put_money * 2
print('You have ${} now.'.format(current_money))
play_again = input("是否继续?--yes/no:")
if play_again == "yes":
continue
elif play_again == 'no':
break
else:
print("错了哦!")
current_money -= put_money
print('You have ${} now.'.format(current_money))
play_again = input("是否继续?--yes/no:")
if play_again == "yes":
continue
elif play_again == 'no':
break

else:
print('Game Over!')
print("欢迎再来玩掷骰子游戏游戏!!")

if __name__ == '__main__':
start_game()