?
擲骰子游戲:
==========擲骰子游戲=========
可選擇的參加游戲的角色是:1.貂蟬? 2.劉備? 3.孫悟空? 4.諸葛亮 5.曹操
輸入參加游戲的角色是: 1
貂蟬進入游戲……
貂蟬請充值(金額必須是100的倍數):?? ---》注意:充值3次不成功退出游戲,----》注意: 如果充值成功
充值成功的金額是: 1000元
?
貂蟬請下注(必須是50的倍數,不能大于充值金額):?? ---》可以反復下注
下注金額是:100
# 注意:是兩個骰子 猜大 小? 大:兩個骰子的和大于6或者兩個骰子相同,否則為小,系統產生兩個1-6之間的隨機數作為骰子的個數
貂蟬猜大小:大
如果猜對了,則下注金額翻倍加到總金額中,猜錯了則總金額減去下注金額
?
詢問是否下一輪游戲? --?注意: 可以繼續下一輪游戲,仍然從下注開始
?
?
import random
import timedef 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 = 0while a > 3:if current_money % 100 == 0:print('充值成功,You have ${} now.'.format(current_money))breakelse:print("充值必須是100的倍數,充值不成功請再次充值!")a += 1continueshaiz1 = 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:continueelse:print('You have ${} now.'.format(current_money))your_choice = input('Big or Small: ')choices = ['Big', 'Small']if your_choice in choices:passelse:print('Invalid input!')if your_choice == 'Big':if shaiz > 6:print("答對了哦!")current_money += put_money * 2print('You have ${} now.'.format(current_money))play_again = input("是否繼續?--yes/no:")if play_again == "yes":continueelif play_again == 'no':breakelse:print("錯了哦!")current_money -= put_moneyprint('You have ${} now.'.format(current_money))play_again = input("是否繼續?--yes/no:")if play_again == "yes":continueelif play_again == 'no':breakif your_choice == 'Small':if shaiz < 6:print("答對了哦!")current_money += put_money * 2print('You have ${} now.'.format(current_money))play_again = input("是否繼續?--yes/no:")if play_again == "yes":continueelif play_again == 'no':breakelse:print("錯了哦!")current_money -= put_moneyprint('You have ${} now.'.format(current_money))play_again = input("是否繼續?--yes/no:")if play_again == "yes":continueelif play_again == 'no':breakelse:print('Game Over!')print("歡迎再來玩擲骰子游戲游戲!!")if __name__ == '__main__':start_game()