# 1。電腦出拳,随機出拳1-3
import random
import easygui
answer = easygui.buttonbox("你敢跟老八猜拳嗎?",
choices=("敢", "不敢"))
if answer == "敢":
win = 0
lose = 0
draw = 0
for i in range(1):
computer = random.randint(1, 3) # 數字
# 2。我們出拳
we = easygui.enterbox("你想出什麼")
# we = input("你想出什麼") # 字元串
we = int(we)
# 3。判斷
result = computer - we
if 1 <= we <= 3: # we<1 或者 we >3
if computer - we == -1 or computer - we == 2:
easygui.msgbox("勝利")
win = win + 1
elif computer - we == 1 or computer - we == -2:
easygui.msgbox("lose")
lose = lose + 1
elif computer - we == 0:
easygui.msgbox("平局")
draw = draw + 1
if computer == 1:
easygui.msgbox("電腦出了石頭")
elif computer == 3:
easygui.msgbox("電腦出了剪刀")
elif computer == 2:
easygui.msgbox("電腦出了布")
else:
easygui.msgbox("錯誤")
# 功能更新:戰績顯示
easygui.msgbox("你赢了"+str(win)+"局")
easygui.msgbox("你真蔡"+lose+"局")
easygui.msgbox("平局"+draw+"局")
elif answer == "不敢":
easygui.msgbox("我*****")