我是一个业余的 Python 程序员,我正在尝试做一个双倍或没有的赌博游戏,基本上你下注一定数量的钱,你有机会获得双倍的投入或失去你投入的资金。
似乎当我运行这个脚本时,我下了赌注,没有任何反应,钱标签没有改变,我不知道如何调试。
from appJar import gui
import random
# GUI Tab Name
win = gui('Double or Nothing')
# Starting Money
# Declares the odds
array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# declaring the random array choice.
random = int(random.choice(array))
# starting money amount.
money = 500
# This is the define for the 'Insert Bet' button.
def press(name):
bet = int(win.getEntry('Bet'))
if name == 'InsertBet':
win.setLabel('outcome', int(random))
outcomes = int(win.getLabel('outcome'))
# The formula used to deduct and add Winnings
# If random is a number larger than seven, i would like to deduct
if random >= int(7) :
money == (int(money) - bet) + (bet * 2)
win.setLabel('showMon', '$' + str(int(money)))
elif random <= int(6) :
money == int(money) - bet
win.setLabel('showMon', '$' + str(int(money)))
# To Display How much money you have.
win.addLabel('showMon', '$' + str(int(money)))
win.addLabel("Insert amount money")
win.addEmptyLabel('outcome')
win.addEntry('Bet')
win.addButton('Insert Bet', press)
# start the GUI
win.go()