aden -easgui高級版猜拳遊戲

# 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("我*****")
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章