Craps赌博游戏-python3

"""
玩家掷两个骰子,每个骰子点数为1-6,如果第一次点数和为7或11,则玩家胜;
如果点数和为2、3或12,则玩家输庄家胜。
若和为其他点数,则记录第一次的点数和,玩家继续掷骰子,直至点数和等于第一次掷出的点数和则玩家胜;
若掷出的点数和为7则庄家胜。

Version: 1.0.0
Author: Catherine
Data: 2019-03-11
"""
import random

x = random.randint(1, 7)
y = random.randint(1, 7)

s = x + y
if (s == 7) or (s == 11):
    print("1:{}".format(s))
    print("玩家胜!!!")
elif (s == 2) or (s == 3) or (s == 12):
    print("2:{}".format(s))
    print("庄家胜!!!")
else:
    mark1 = s
    s = 0
    while mark1 != s:
        x = random.randint(1, 7)
        y = random.randint(1, 7)
        s = x + y
        if s == 7:
            print("3:{}".format(s))
            print("庄家胜!!!")
            break
    if mark1 == s:
        print("4:{}".format(s))
        print("玩家胜!!!")

猜你喜欢

转载自blog.csdn.net/u011280600/article/details/88391839