"""
需求:11点小游戏
人员超出11点默认为0
每次选完牌后询问是否继续
"""
import random
result = {}
user_list = ["yy", "ww", "gg"]
total_poke_list = [ ("小王",14),("大王",15) ]
color_list = ["红桃", "黑桃", "方片", "梅花"]
num_list = []
for num in range(1, 14):
num_list.append(num)
for color in color_list:
for num in num_list:
item = (color, num,)
total_poke_list.append(item)
for user in user_list:
score = 0
index = random.randint(0, len(total_poke_list) - 1)
poke = total_poke_list.pop(index)
value = poke[1]
if poke[1] > 10:
value = 0.5
score += value
print("给{}发的牌:{}{},此刻所有牌面值总和:{}".format(user, poke[0], poke[1], score))
while True:
choice = input("是否继续要牌(Y/N)?")
choice = choice.upper()
if choice not in {"Y", "N"}:
print("输入错误,请重新输入。")
continue
if choice == "N":
print("{}不要拍了".format(user))
break
index = random.randint(0, len(total_poke_list) - 1)
poke = total_poke_list.pop(index)
value = poke[1]
if poke[1] > 10:
value = 0.5
score += value
print("给{}发的牌:{}{},此刻所有牌面值总和:{}".format(user, poke[0], poke[1], score))
if score > 11:
print("用户{}爆了".format(user))
score = 0
break
result[user] = score
print(result)