输了不减钱,赢了也不加钱,为什么呢?另外,如果有更简单的方法来定义角色(),请告诉我。Python 2.7 这里是代码。
`from random import randint #import random intergers
b="Your color is Black." #Makes easier to define black
r="Your color is Red." #Makes easier to define red
print "Welcome to Roulette Simulator 2.0! This is made for people the age of 21+."
print "This is not avaliable for distribution. Please do not distribute."
print "By using this you undestand this is not real money."
print "Made by: Jacob Lloyd"
user_color_number = 0
number = 0
bet=0
monei = raw_input("How much money do you wish to start with? :>")
money = int(monei)
number_color=0
def role(): #define what a role() is
global number
number = (randint(0,36))
print number
if number == 28: #if then "==' means equal to
print b
if number == 26:
print b
if number == 11:
print b
if number == 20:
print b
if number == 17:
print b
if number == 22:
print b
if number == 15:
print b
if number == 24:
print b
if number == 13:
print b
if number == 0:
print ("Your color is Green.") #If number on roulette = zero make it green
if number == 10:
print b
if number == 29:
print b
if number == 8:
print b
if number == 31:
print b
if number == 6:
print b
if number == 33:
print b
if number == 4:
print b
if number == 35:
print b
if number == 2:
print b
if number == 9: #Starting red here
print r
if number == 30:
print r
if number == 7:
print r
if number == 32:
print r
if number == 5:
print r
if number == 34:
print r
if number == 3:
print r
if number == 36:
print r
if number == 1:
print r
if number == 27:
print r
if number == 25:
print r
if number == 12:
print r
if number == 19:
print r
if number == 18:
print r
if number == 21:
print r
if number == 16:
print r
if number == 23:
print r
if number == 14:
print r
continu=raw_input("Press enter to continue.")
color_numbers()
def bets(): #how much to bet
global bet
global money
print "You have $", money
minimum=25
if money == 0:
goodbye()
bet_amount = raw_input("How much would you like to bet? :> $")
if bet_amount is int:
bet = int(bet_amount)
if bet>>money: #if bet is more than money go to bet_too_much
bet_too_much()
color()
def not_a_bet():
print "Thats not a number. Please try again."
bets()
def bet_too_little():
print "Your bet is below minimum bets! The minimum bet is $26. Please try again."
bets()
def goodbye():
print"You are out of money. Press enter to exit!."
def bet_too_much(): #what happens if bet is too much
print "Your bet is too much. Please try again."
bets()
def win():
global bet
global money
print "You won!"
money = money ++ bet
play()
def lose():
global bet
global money
print "You lost, but don't give up yet!"
drop_money=1
if drop_money==0:
money=money -- bet #subtract bet from money
play()
def color():
global user_color_number
user_color=raw_input("Which color would you like to pick? Black or Red? :> ")
if user_color == "Black":
global user_color_number
print "You have bet on Black! "
user_color_number=1
role()
if user_color == "Red":
global user_number_color
print "You have bet on Red!"
user_color_number=2
role()
def win_or_lose():
global user_color_number
global number_color
if number_color == user_color_number:
win()
if number_color != user_color_number:
lose()
def color_numbers():
global number_color
global number
if number == 28: #if then "==' means equal to
number_color=1
if number == 26:
number_color=1
if number == 11:
number_color=1
if number == 20:
number_color=1
if number == 17:
number_color=1
if number == 22:
number_color=1
if number == 15:
number_color=1
if number == 24:
number_color=1
if number == 13:
number_color=1
if number == 0:
number_color=0
if number == 10:
number_color=1
if number == 29:
number_color=1
if number == 8:
number_color=1
if number == 31:
number_color=1
if number == 6:
number_color=1
if number == 33:
number_color=1
if number == 4:
number_color=1
if number == 35:
number_color=1
if number == 2:
number_color=1
if number == 9: #Starting red here so number_color shall equal 2
number_color=2
if number == 30:
number_color=2
if number == 7:
number_color=2
if number == 32:
number_color=2
if number == 5:
number_color=2
if number == 34:
number_color=2
if number == 3:
number_color=2
if number == 36:
number_color=2
if number == 1:
number_color=2
if number == 27:
number_color=2
if number == 25:
number_color=2
if number == 12:
number_color=2
if number == 19:
number_color=2
if number == 18:
number_color=2
if number == 21:
number_color=2
if number == 16:
number_color=2
if number == 23:
number_color=2
if number == 14:
number_color=2
win_or_lose()
def play():
while money>=1: #It will run code ( role() ) back to back f statement = true
bets()
play()
` https://pastebin.com/tNifKRKS
(我找不到如何格式化它,所以它就在那里:))