Increasing money when the dealer or player win the game - python-2.7

I am a beginner I am trying to add money if I wont to the money that I typed in the very start of the game if I won the money will be added to the input money that I had it adding but repeating its looping example I typed 500 then I won 200 price It will display 700 but if I won again and the price 300 it will show 800 and forgetting about what I won before
below is the code I will really appreciate your hep thank you
import random, sys
from random import shuffle
from _ast import Num
# define global variables for the cards
suits = ('Clubs', 'Spades', 'Hearts', 'Diamonds')
pip = ('Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King')
pipValues = {'Ace':11, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, '10':10, 'Jack':10, 'Queen':10, 'King':10}
playing = True
global score
score=0
class Card:
#When you create an instance of Card, you pass it a suit ("C", "D", "H", or "S") and a "pip" (2, 3, 4, 5, 6, 7, 8, 9, 10 J, Q, K, A).
#These values should be stored as instance variables for the new card object.
#I recommend you also have an instance variable "value" that stores the point value of the card.
#It should have an __str__ method that lets you print an individual card (such as "3S" for three of spades).
#Note that the __str__ method for Decks should take advantage of the __str__ method for Cards.
def __init__(self, suit, pip):
self.suit = suit
self.pip = pip
self.value = pipValues.get(pip)
def __str__(self):
return str(self.pip) + " of " + str(self.suit)
def __repr__(self):
return self.__str__()
class Player:
#When you create an instance of Player, it should have an instance variable "hand" that's set to an empty list,
#and an instance variable "handTotal" that's set to zero. These instance variables will be modified
#by Deck's "dealOne()" method.
#It should have an __str__ method that lets you print out a Player's hand.
def __init__(self, isDealer):
self.hand = []
self.isDealer = isDealer
self.name = "Dealer" if self.isDealer else "You"
self.other = "Dealer" if not self.isDealer else "You"
self.has = "has" if self.isDealer else "have"
def __str__(self):
return ", ".join(map(str, self.hand))
def __repr__(self):
return self.__str__()
def discardHand(self):
self.hand = []
#property
def handTotal(self):
while sum(card.value for card in self.hand) > 21 and \
any(card.pip == 'Ace' and card.value == 11 for card in self.hand):
for card in self.hand:
if card.pip == 'Ace' and card.value == 11:
card.value = 1
break
return sum(card.value for card in self.hand)
def blackjack(self):
print ("%s %s %s for a total of 21" %
(self.name, self.has, str(self)))
print ("%s %s a Blackjack! %s win%s!" %
(self.name, self.has, self.name, "s" if self.isDealer else ""))
print ("Thanks for playing. Come back again soon! ")
#chips=chips+(bet*500)
score+1
return message()
def bust(self):
print ("%s hold%s %s for a total of %s" %
(self.name, "s" if self.isDealer else "", str(self), str(self.handTotal)))
print ("%s Bust%s! %s Win%s!" %
(self.name, "s" if self.isDealer else "", self.other, "s" if not self.isDealer else ""))
print ("Thanks for Playing! Come Back Soon!")
# chips=chips-2
return message()
class Deck:
#When you create an instance of Deck, it should add 52 Card objects to an instance variable "cardList".
#It should have a shuffle() method that rearranges the cards in cardList. You can do this easily by importing the
#"random" package into Python, and using the random.shuffle() method. random.shuffle(myList) rearranges the
#elements of the list "myList" into a random order.
#It should have a dealOne() method that removes the first card from your deck's cardList, and appends it to the
#hand of a specified player.
#It should have an __str__ method that lets you print out the entire deck for debugging purposes.
freshDeck = []
for i in range(len(suits)):
for j in range(len(pip)):
freshDeck.append(Card(suits[i], pip[j]))
def __init__(self):
self.cardList = self.freshDeck[:]
def shuffle(self):
random. shuffle (self.cardList)
def dealOne(self, player):
if len(self.cardList) < 4:
print("Out of cards... shuffling a new deck...")
exit
#self.cardList = self.freshDeck[:]
#self.shuffle()
(player.hand).append(self.cardList[0])
del self.cardList[0]
#print(self.cardList)
shuffle(self.cardList)
return self.cardList
def __str__(self):
printString = ""
for i in range(len(self.cardList)):
if i % 13 == 0:
printString += "\n \t"
printString += str(self.cardList[i]) + " "
else:
printString += str(self.cardList[i]) + " "
printString += "\n"
return printString
def showHands(player, opponent):
print ('Dealer shows ' + str(opponent.hand[0]) + ' faceup')
print ('You show ' + str(player))
def turn(deck, player, other):
#First, check scores to see if either player has a blackjack:
if player.handTotal == 21:
return player.blackjack()
if other.handTotal == 21:
return other.blackjack()
#See if the dealer less 16
hitOrStand = 0
while hitOrStand != 2:
print (player.name + ' hold%s ' % ("s" if player.isDealer else "") + str(player) + ' for a total of ' + str(player.handTotal) + '\n')
if player.isDealer:
if player.handTotal < 16:
hitOrStand = 1
if player.handTotal >= other.handTotal:
hitOrStand = 2
else:
hitOrStand = input('Do you hit or stand? Enter "1" for hit and "2" for stand: ')
while hitOrStand != 1 and hitOrStand != 2:
try:
hitOrStand = int(hitOrStand)
break
except ValueError:
print ("Enter a valid integer \n")
hitOrStand = input('Do you hit hit or stand? Enter "1" for hit and "2" for stand: ')
print()
if hitOrStand == 1:
print('Card dealt: ' + str(deck.cardList[0]) + '\n')
deck.dealOne(player)
if player.handTotal == 21:
return player.blackjack()
if player.handTotal > 21:
return player.bust()
#if player.handTotal <16 :
#return player.bust()
if hitOrStand == 2:
if player.isDealer:
print ("Dealer stands at " + str(player.handTotal))
global price
price=bet*500*2
print (price )
print ("Dealer Wins!")
return message()
else:
print (player.name + ' stand at: ' + str(player.handTotal))
print()
print ("Now Dealer's Turn\n")
def message():
global playing
again = raw_input("Do you want to play again? (Y/N) : ")
if again.lower() == "n":
print("\n\n-------Thank you for playing!--------\n\n")
playing = False
return True
#who won
def betValidation():
global number
number=input("Enter amount: ")
number
if (number<5000):
print "Minimum amount is 5000!!! "
exit()
elif (number > 50000):
print "You Exceeding the Maximum Amount...."
exit()
elif (number==5000 , number<=50000):
if number%500==0:
print ""
else:
print "Invalid"
exit()
def main():
cardDeck = Deck()
global bet
bet1=betValidation()
while playing:
global chips
print "Score:",score
chips=number/500
print "You have", chips ,"chips!"
betchips=chips/2
global bet
bet=input("How much would you like to bet: ")
if(bet==0):
print "Invalid"
elif (bet>=betchips):
if bet%1==0:
player = Player(isDealer=False)
opponent = Player(isDealer=True)
player.discardHand()
opponent.discardHand()
#give each player 2 cards, alternating
cardDeck.dealOne(player)
cardDeck.dealOne(opponent)
cardDeck.dealOne(player)
cardDeck.dealOne(opponent)
#show 1 faceup card for each player
showHands(player,opponent)
#start playing
if turn(cardDeck,player, opponent):
continue
turn(cardDeck, opponent, player)
main()

I imagine your problem lies in the function blackjack() but you haven't posted that.

Related

How do I get my code to repeat itself if the desired input is not entered?

I just started python 2 weeks ago and I don't know how to make my code repeat itself when the input is something like "fox" when that is not one of the three options I'm accepting (horse, oxen, mule). Also if I want to total up the cost of 2 horse and say 3 mules by having it ask "do you want to buy any more animals", how would i do that? Any help would be very appreciated.
zoo = {}
def main():
print ("Animals available to purchase: " + "horse: 50, oxen: 35, mule: 20")
total_money = 1000
print ("You have " + str(total_money) + " to spend")
cost(total_money)
def animal_cost(total_money):
animal_type = raw_input("Please enter an animal:")
print ("Animal Type Entered: " + str(animal_type))
global animal_quantity
animal_quantity = int(raw_input("Please enter quantity of animals:"))
print ("Animal Quantity Entered: " + str(animal_quantity))
if animal_type in zoo:
zoo[animal_type] += animal_quantity
else: zoo[animal_type] = animal_quantity
while True:
if animal_type == 'horse':
return 50 * animal_quantity
if animal_type == 'oxen':
return 35 * animal_quantity
if animal_type == 'mule':
return 20 * animal_quantity
else:
cost(total_money)
def cost(total_money):
costing = animal_cost(total_money)
total_money -= costing
if total_money <= 0:
print ("No money left, resetting money to 1000.")
total_money = 1000
zoo.clear()
print ("Cost of Animals: " + str(costing))
print ("Remaining Balance:" + str(total_money))
choice = raw_input("Do you want to buy any more animals?(Y/N):")
if choice in('Y','y'):
cost(total_money)
elif choice in ('N','n'):
choice_2 = raw_input("Enter 'zoo' to see the animals you have purchased:")
if choice_2 in('zoo','Zoo'):
print zoo
choice_3 = raw_input("is everything correct?(Y/N):")
if choice_3 in ('Y','y'):
print ("Thank you for shopping!")
elif choice in ('N','n'):
print ("Restarting Transaction")
zoo.clear()
cost(total_money)
if __name__ == '__main__':
main()
You may try this enhanced version of your code:
zoo = {} # creating global dictionary for adding all animals into it.
# function to get animal cost
def animal_cost(total_money):
animal_type = raw_input("Please enter an animal:")
print ("Animal Type Entered: " + str(animal_type))
animal_quantity = int(raw_input("Please enter quantity of animals:"))
print ("Animal Quantity Entered: " + str(animal_quantity))
if animal_type in zoo:
zoo[animal_type] += animal_quantity
else: zoo[animal_type] = animal_quantity
if animal_type == 'horse':
return 50 * animal_quantity
if animal_type == 'oxen':
return 35 * animal_quantity
if animal_type == 'mule':
return 20 * animal_quantity
# getting total_money after animal purchase
def cost(total_money):
costing = animal_cost(total_money)
total_money = total_money - costing
if total_money <=0: # condition when money is less than or equal to 0.
print("No Money left, resetting money to 1000.")
total_money = 1000
print ("Cost of Animals:" + str(costing))
print ("Total Money Left:" + str(total_money))
# Recursion for buying more animals:
choice = raw_input("Do you want to buy any more animals?:")
if choice in ('Yes','y','Y','yes','YES'):
cost(total_money)
# you can use this commented elif condition if you want.
else: # elif choice in('no','No','n','N','NO'):
print("thankyou!!")
print("You have total animals: "+str(zoo))
# main function to initiate program
def main():
print ("Animals available to purchase: " + "horse, oxen, mule")
total_money = 1000
print ("You have " + str(total_money) + " to spend")
cost(total_money)
if __name__ == '__main__':
main()
This might help you out.
Have a look into this for last two lines

[Code is working]How to shorten my code? Rock =/= rock?

I'm trying to make a simple 2 player game on python 2.7 .
The program will determine the result of a rock, paper, scissors game, given Player 1 and Player 2’s choices. The program will print out the result, score by each player and the total number of game played.
My question is:
The code doesn't work when "Rock" is the input.It works when "rock" is the input. Same goes to paper and scissors. How can I make it work?
1.The code doesn't work when "Rock" is the input.It works when "rock" is the input. Same goes to paper and scissors. How can I make it work?
From:
player_1 = str(input(">>Player 1? "))
player_2 = str(input(">>Player 2? "))
Add:
player_1 = str(input(">>Player 1? ")).lower()
player_2 = str(input(">>Player 2? ")).lower()
2.Both player must input their choices before the program can be terminated. That means when player 1's input "-1", the program doesn't terminate immediately. It will proceed to ask player 2 for input before it get terminated. How can I make the program terminate itself immediately when player 1's input is "-1"?
From:
player_1 = str(input(">>Player 1? "))
player_2 = str(input(">>Player 2? "))
Add:
player_1 = str(input(">>Player 1? "))
if (player_1=='-1'):
print 'End of game'
break
player_2 = str(input(">>Player 2? "))
3.My code is very long, any suggestions or tips on shortening it without sacrificing any of the function?
use function definitions. Sample:
if (player_1=='-1' or player_2=='-1'):
print 'End of game'
break
elif dif in [-1, 2]:
print ('Player 1 wins.')
score1 = score1 + 1
showScore()
elif dif in [1, -2]:
print('Player 2 wins.')
score2 = score2 + 1
showScore()
else:
print('Tie')
showScore()
continue
def showScore():
print '==================='
print 'Score:'
print 'Player 1: ' + `score1`
print 'Player 2: ' + `score2`
print 'Total game played: ' + `times`
print ''
Here's a good read
For starters, I converted your program to Python 3. It's better in every way. For one thing, it has a normal definition for input.
In general, if you have N of something, where N is greater than 1, it's better to use an array. If you see repetition, move the data into an array and call a function. When N is 2, you won't necessarily shorten the code (my version is longer than yours) but you'll avoid treating the players differently because they both pass through the same logic.
Put the main logic in a function, too, and reserve the "main" code for dealing with startup & command-line stuff.
When you see a string of elifs, that's also a use data instead indicator. In my victor function, I iterate over tuples of winning combinations. You might consider how to use a dict instead.
import sys, os
def print_results( msg, times, scores ):
print( (msg) )
print( '===================' )
print( 'Score:' )
print( 'Player 1: %d' % scores[0] )
print( 'Player 2: %d' % scores[1] )
print( 'Total game played: %d' % times )
print( '' )
def victor( inputs ):
results = ( ('rock', 'scissors'), ('scissors', 'paper'), ('paper', 'rock') );
for (a, b) in results:
if a == inputs[0] and b == inputs[1]:
return 1
if b == inputs[0] and a == inputs[1]:
return 2
return 0
def play(times, scores):
inputs = ['', '']
for (i, choice) in enumerate(inputs):
prompt = '>>Player %d? ' % (i + 1)
choice = input(prompt).lower()
if choice == '-1':
return False
inputs[i] = choice
result = victor(inputs)
if result == 0:
print_results('Tie', times, scores)
else:
scores[result - 1] += 1
print_results('Player %d wins' % result, times, scores)
times += 1
return True
print('''Welcome to play Rock, Paper, Scissors game. Enter -1 to end''')
scores = [0, 0]
times = 0
while play(times, scores):
pass
if scores[0] == scores[1]:
player = 'Tie'
else:
if scores[0] > scores[1]:
i = 1
else:
i = 2
player = 'Player %d' % i
print( '*******************' )
print( 'Winner: %s' % player )
print( '*******************' )

Why doesn't the menu in this Python program function?

I have looked over this code 100 times and I feel like it may be something small that I am missing. Program will allow you to login, and display the menu but after entering your selection it continuously displays the menu again.
import sys
def main():
login = 'yes'
choice = 0
hours = [0] * 7
wages = 0
totalHours = 0
totalWages = 0
print
login = raw_input('Do you want to login?')
while not (login == 'yes' or login == 'no'):
print
print 'Please enter a yes or no'
while login == 'yes':
print
userId = raw_input ('Enter user name:')
passWord = raw_input('Enter password:')
while passWord != userId:
print 'Incorrect Password, please try again.'
passWord = raw_input('Enter password:')
while passWord == userId:
print 'Login Success!'
print
print 'Enter 1 to view upcoming schedule'
print 'Enter 2 to view previous schedule'
print 'Enter 3 to calculate wages due'
print 'Enter 4 to verify clock in/out times'
print
choice = raw_input('Enter 1 to 4 from menu.')
def readFromNext(nextWeek):
inFile = open('nextweek.txt', 'r')
str1 = inFile.read()
print str1
str2 = inFile.read()
print str2
print
inFile.close()
def readFromLast(lastWeek):
inFile = open('lastweek.txt', 'r')
str1 = inFile.read()
print str1
str2 = inFile.read()
print str2
print
inFile.close()
def getHours(hours):
counter = 0
while counter < 7:
hours[counter] = input('Enter hours worked per day')
counter = countr + 1
return hours
def getTotalHours(hours, totalHours):
counter = 0
while counter < 7:
totalHours = totalHours + hours[counter]
counter = counter + 1
return totalHours
def getWages(wages):
wages = input('Enter your hourly wage.')
return wages
def getTotalWages(totalHours, wages):
totalWages = totalHours * wages
print 'Your total pay due is:' , totalWages
return totalWages
def readFromClock(clockHours):
inFile = open('clockhours.txt', 'r')
str1 = inFile.read()
print str1
str2 = inFile.read()
print str2
print
inFile.close()
while choice != '5':
if choice == '1':
readFromNext(nextWeek)
print 'Upcoming schedules'
if choice == '2':
readFromLast(lastWeek)
print 'Previous schedules'
if choice == '3':
hours = getHours(hours)
totalHours = getTotalHours(hours, totalHours)
wages = getWages(wages)
totalWages = gettotalWages(totalHours, wages)
print 'Paycheck calculator'
if choice == '4':
readFromClock(clockHours)
print 'Clock in/out times'
main()
What do you expect it to do? You have added many functions but they appear to be unused. You end up printing the menu over and over again because you are in the loop
while passWord == userId:
...
You have to do something with the choice variable and break out of that loop if you want anything else to happen.
For example:
choice = raw_input('Enter 1 to 4 from menu.')
if choice == 1:
readFromNext(nextWeek)
elif choice == 2:
readFromLast(lastWeek)
elif choice == 3:
getTotalWages(totalHours, wages)
elif choice == 4:
getHours(hours)
Obviously you will need to figure out which function maps to which user input, but currently you are not doing anything with the user's choice, merely asking them to choose over and over again with no control over the termination of the loop.
You are not changing the value of login in your while not loop.
login = 'default'
while not (login == 'yes' or login == 'no'):
print 'Please enter a yes or no'
login = raw_input('Do you want to login?')
... for example. The way you currently have it is never going to end:
while not (login == 'yes' or login == 'no'):
print
print 'Please enter a yes or no'
This is conceptually identical as:
while True:
if login == 'yes' or login == 'no':
break
print
print 'Please enter a yes or no'
So if the login is never changed, it will never end.

Questions about python inheritance and argument lists

First off I am getting this error
File "E:\New folder (7)\maingame.py", line 64, in play print self.introduction AttributeError: 'game' object has no attribute 'introduction'
I am not to sure as to what it means because I am pulling the self.introduction from the previous class..
I am also getting an
File "E:\New folder (7)\maingame.py", line 96, in <module>
game.play()
TypeError: play() takes exactly 2 arguments (1 given)
error, but can't for the life of me find what argument it is looking for, I simply want it to work.
from random import random
class place(object):
def __init__(self, title, description, events):
self.title = title
self.description = description
self.events = events
class event(object):
def __init__(self, probability, message, healthChange):
self.probability = probability
self.message = message
self.healthChange = healthChange
def process(self):
if random() < self.probability:
print self.message
return self.healthChange
return 0
class textadventure():
def __init__(self):
super(textadventure, self).__init__()
self.introduction = """
Welcome player, you are a lone traveler in space whom has set out to find glories beyond measure.
Unfortunately for you the dread pirate Roberts has attacked. You must defeat him.
"""
commandDeck = place('Command Deck', "You are now in the command center, here you can drive the ship and fire its weapons.",(
event(0.7, "The pirate ship fires at you! You take damage to your engines!", -10),
event(0.2, "One of the pirates manages to beam onto your ship! He shoots you before beaming away!",0),
))
engineRoom = place('Engine Room', "You are now in the main engine room here you can repair damage to the ship",(
event(0.7, "The pirate ship fires at you! You take damage to your engines!", -10),
))
restQuarters = place('Resting Quarters', "Here you can take a rest and heal your self",(
event(1.0, 'You are able to patch up your wounds and get back to the battle',0),
event(0.5, "The pirate ship fires at you! You take damage to your engines!", -10),
))
commandDeck.transitions = (engineRoom, restQuarters),
engineRoom.transitions = (commandDeck, restQuarters),
restQuarters.transitions = (commandDeck, engineRoom),
self.location = commandDeck
pirateHp = 50
class game(object, textadventure):
def __init__(self):
super(game, self).__init__()
self.health = 100
def location(self):
if self.location == commandDeck:
choice = raw_input('would you like to fire on the enemy ship?')
if choice == 'yes':
print 'You have hit the pirates!'
pirateHp -= 10
else: choice == 'no'
elif self.location == engineRoom:
choice = raw_input('Would you like to repair the engines?')
if choice == "yes":
event(1, "You repair what you can of the engines.", 10)
def __init__(self):
self.health = 100
def play(self, textadventure):
print textadventure.introduction
while True:
print (self.location.description)
for event in self.location.events:
self.health += event.process()
if self.health <= 0:
print ("Your ship has been destroyed!")
pause
exit(1)
print ('Your ships health is at %d percent' % self.health)
self._transition()
def _transition(self):
transitions = self.location.transitions
print ('you can go to: ')
for (index, transition) in enumerate(transitions):
print (index + 1, transition.title)
choice = int(raw_input('Choose one '))
if choice == 0:
exit(0)
else:
self.location = transitions[choice - 1]
def pirateShip(Object):
if pirateHp == 0:
print "You have defeated the pirates! Congradualations!"
pause
exit(1)
game = game()
game.play(game)
'game' object has no attribute 'introduction'
You should call the init of your super class when initializing game. In your current code, textadventure.init is never called which is why introduction is never added to textadventure.
Game should also not inherit from object (it does that through textadventure).
class game(textadventure):
def __init__(self):
super(game, self).__init__()
self.health = 100
def play(self):
print self.introduction
Should do the trick.
TypeError: play() takes exactly 2 arguments (1 given)
You never use your textadventure argument in play. Removing this should get things working.

Roulette program will not recognize correct guess. Why?

The following is the roulette portion of a casino game I'm putting together, but I can't seem to get it to work correctly. It won't recognize when the player chooses the correct number, and I'm hoping someone can tell me why. Obviously, a few other parts have not been completed, but I'm just trying to get the basics running. Also, I'm pretty new at this, so feel free to critique anything else! Thanks.
from random import randint
from time import sleep
funds = 50
### Straight Up number bet = 35:1
### Odd/Even payout = 1:1
class RouletteTable(object):
def __init__(self, wallet):
self.wallet = wallet
def spin(self, bets):
print "Spinning..."
sleep(2)
print "The winner is..."
sleep(1)
winner = 25 #randint(0, 36) #FOR TESTING
print "Number ", winner
if winner in bets == True:
bets = True
return bets
else:
print "You bet on: ", bets
print "Better luck next time."
bets = False
return bets
def game(self):
while self.wallet >= 0:
print "\n\nWelcome to Roulette."
print "Test your luck, and place your bets!"
print "Current funds: $", self.wallet
print "\n(1)Place bet or (2)Exit"
choice = raw_input("> ")
if choice == "1":
bets = []
print '''\n\n\n
__________
[ 0 ]
[ 1][ 2][ 3]
[ 4][ 5][ 6]
[ 7][ 8][ 9]
[10][11][12]
[13][14][15]
[16][17][18]
[19][20][21]
[22][23][24]
[25][26][27]
[28][29][30]
[31][32][33]
[34][35][36]
[ODD] [EVEN]
'''
print "How much will you bet (per number)?"
bet_amount = int(raw_input("> $"))
print "Type a number to bet on, and press Enter."
print "When finished choosing, just press Enter."
while True:
print "Funds: $", self.wallet
print "Current Bets: ", bets
number_choice = raw_input("> ")
if number_choice != "":
bets.append(int(number_choice))
self.wallet -= bet_amount
else:
# start spin
self.spin(bets)
# payout for bets
if bets == True:
print "You win $", bet_amount*35
self.wallet += bet_amount*35
break
if choice == "2":
return self.wallet
break
if self.wallet == 0:
print "You're out of money!\n"
roulette = RouletteTable(funds)
funds = roulette.game()
Your main error was this:
# start spin
self.spin(bets)
# payout for bets
It should read:
#start spin
bets = self.spin(bets)
# payount bets
the modified code below does it correctly. Overwriting bets with a different type isn't good style, I'd suggest using a different variable. Also win in bets doesn't need to explicitly compared to True (unless for clarification during learning).
Hope that helps, if you have further questions, just comment ;-)
from random import randint
from time import sleep
funds = 50
### Straight Up number bet = 35:1
### Odd/Even payout = 1:1
class RouletteTable(object):
def __init__(self, wallet):
self.wallet = wallet
def spin(self, bets):
print "Spinning..."
sleep(2)
print "The winner is..."
sleep(1)
winner = 25 #randint(0, 36) #FOR TESTING
print "Number ", winner
if winner in bets:
return True
else:
print "You bet on: ", bets
print "Better luck next time."
return False
def game(self):
while self.wallet >= 0:
print "\n\nWelcome to Roulette."
print "Test your luck, and place your bets!"
print "Current funds: $", self.wallet
print "\n(1)Place bet or (2)Exit"
choice = raw_input("> ")
if choice == "1":
bets = []
print '''\n\n\n
__________
[ 0 ]
[ 1][ 2][ 3]
[ 4][ 5][ 6]
[ 7][ 8][ 9]
[10][11][12]
[13][14][15]
[16][17][18]
[19][20][21]
[22][23][24]
[25][26][27]
[28][29][30]
[31][32][33]
[34][35][36]
[ODD] [EVEN]
'''
print "How much will you bet (per number)?"
bet_amount = int(raw_input("> $"))
print "Type a number to bet on, and press Enter."
print "When finished choosing, just press Enter."
while True:
print "Funds: $", self.wallet
print "Current Bets: ", bets
number_choice = raw_input("> ")
if number_choice != "":
bets.append(int(number_choice))
self.wallet -= bet_amount
else:
# start spin
did_win = self.spin(bets)
# payout for bets
if did_win == True:
ammount = bet_amount*35
self.wallet += ammount
print "You win $", ammount
break
if choice == "2":
return self.wallet
break
if self.wallet == 0:
print "You're out of money!\n"
roulette = RouletteTable(funds)
funds = roulette.game()