猜拳小游戏

发布时间 2023-04-21 00:16:04作者: 头发未秃还能卷
import random

# 游戏规则以及奖品展示
dict1 = {"石头": 1, "剪刀": 2, "布": 3}
get_result = {6: "化妆品一套", 4: "口红自选", 2: "奶茶一杯"}

# 1,石头剪刀布的游戏 石头:1 剪刀:2 布:3
# i统计游戏运行的次数 count计算玩家的得分 user_count 统计玩家胜利的次数 computer_count 统计电脑胜利的次数 input_count密码输错的次数
i = 0
count = 0
user_count = 0
computer_count = 0
input_count = 0
# 提示语--游戏开启之前
print("_________❤❤❤❤是否充值缴费10元三次,支付成功开启猜拳游戏_________❤❤❤❤\n")

while input_count < 3:
# 判断是否输错三次
# 玩家输对密码开启游戏
keyword = input("--------------------------------充值成功-请输入密码????--开启游戏:----------------------------\n")
# 成功输对直接开启游戏
if keyword == "lry123":
print("游戏开始")
while i < 3:
# 玩家三次游戏结束
# 展示游戏规则和奖品
print(f"用户输入对应的数字或者出拳的结果,判断输赢:\n-------------------------\n{dict1}:\n")
print(f"奖品如下:{get_result}")
user_choice = int(input("用户请输入:\n"))
list1 = list(dict1.values())
i = i + 1
computer_choice = random.choice(list1)
if (user_choice == 1 and computer_choice == 2) or (user_choice == 2 and computer_choice == 3) or (
user_choice == 3 and computer_choice == 1):
print(f'玩家的出拳结果为{user_choice},电脑的出拳结果为{computer_choice},玩家胜利')
count = count + 2
user_count = user_count + 1
print(f'第{i}次游戏,玩家的此时的得分为{count}')
elif computer_choice == user_choice:
print(f'玩家的出拳结果为{user_choice},电脑的出拳结果为{computer_choice},平局')
count = count
print(f'第{i}次游戏,玩家的此时的得分为{count}')
else:
print(f'玩家的出拳结果为{user_choice},电脑的出拳结果为{computer_choice},玩家失败')
count = count - 2
print(f'第{i}次游戏,玩家的此时的得分为{count}')
computer_count = computer_count + 1
# 游戏结果统计游戏数据
print("_" * 100)
print(f"玩家胜利的次数为{user_count},电脑胜利的次数为{computer_count},总次数为3")
print(f"最终的得分为{count}")
# 统计奖品数据
if count in get_result.keys():
print("表现不错,你有奖品")
print(f"你得到的奖励是{get_result[count]}")
else:
print("表现不行,此次猜拳游戏没有奖励")
# 成功玩了三次游戏会退出系统 不能多玩
break
else:
# 进入游戏输错密码时
cishu = 2 - input_count
print(f"请检查是否充值10元,或者密码是否输错\n你还有{cishu}次机会!!!!!!")
input_count = input_count + 1

# 只有输错三次密码才提示这个
if input_count == 3:
print("输错三次密码锁机10分钟/还不充钱你是白嫖??")