예제 #1
0
- single player.
- player can bet if balance > 0.
- dealer follows basic blackjack rules (will hit until >= 17 or bust).
- Ace is valued at 11 only.
- dealer wins if scores are even.
- all winning bets are paid out 2:1.
'''

import os
from deck import deck
from player import player
from dealer import dealer

deck = deck()
player = player('Player',100)
dealer = dealer('Dealer')
bet = 0
round_over = False
game_over = False
replay = 'n'

#loop that contains game
while not game_over:
    #clear output, reset deck,bet,round_over
    os.system('clear')
    deck.reset()
    bet = 0
    round_over = False
    #print player balance, check balance not 0.
    print("Player balance: {} ".format(player.balance))
    if player.balance == 0:
예제 #2
0
 def __init__(self):
     self.__player_list = []
     self.__dealer = dealer()
     self.__console = Console()
     self.__log = []
예제 #3
0
def start_table():
    w=winner() #===========================================
    players = []
    dealerObj = dealer()

    gameObj=game() #===========================================
    players=gameObj.selectPlayers(dealerObj)#===========================================

  #  level= input("Player 1 level (1-3) or person (0): ")
    #players.append(player(3, dealerObj))


    #flag to keep track of which round of the game is curently in progress
    #A.K.A. prflop, flop, river, turn etc.
    gameRound = 0
    #strictly for curiosity keep track of how many games have been played
    gameCount = 0

    #this is the player that holds the dealer chip
    #next person is the small blind
    dealerPlayerIndex = -1

    while(True):
        ## if start of new game
        if(gameRound == 0):
            #first check who won the previous round which will destribute the winnings to that player
            dealerObj.checkWinner(gameCount, players,w)#=================================================
            dealerPlayerIndex = (dealerPlayerIndex + 1) % len(players)
            gameCount += 1
            # deal the cards which will reset the pot the game and all other stuff.
            curentPlayerIndex = dealerObj.deal(players, dealerPlayerIndex)
            dealerObj.printBoard("Pre-flop round: ")
        if(gameRound == 1):
            curentPlayerIndex = dealerObj.flop(players, dealerPlayerIndex)
            dealerObj.printBoard("Flop round: ")
        if(gameRound == 2):
            curentPlayerIndex = dealerObj.turn(players, dealerPlayerIndex)
            dealerObj.printBoard("Turn round: ")
        if(gameRound == 3):
            curentPlayerIndex = dealerObj.river(players, dealerPlayerIndex)
            dealerObj.printBoard("River round: ")

        #Make sure each player updates their hand value
        for p in players:
            p.calculateHand()

        # start the betting loop
        betting_finished = False


        #check if betting is needed at all maybe only one player left unfolded
        if(dealerObj.bettingNeeded(players) == True):
            while(betting_finished == False):
                # promt player for action
                action = players[curentPlayerIndex].act(gameRound)
                print("Game action: " + str(action))
                curentPlayerIndex = dealerObj.handleAction(action, players, curentPlayerIndex)
                betting_finished = dealerObj.isBettingFinsihed(players, curentPlayerIndex)

            gameRound = (gameRound + 1) % 4

        else:
            #if all but one players folded skip to first round and rest the game
            gameRound = 0


    w.printStats() #=============================================

    print("starting new table...")
예제 #4
0
 def __init__(self):
     self.dealer = dealer()
예제 #5
0
 def __init__(self, pack_of_cards):
     self.mydeck = deck.deck(pack_of_cards)
     self.points = self.mydeck.get_score()
     self.p = player.player(self.mydeck)
     self.dealer = dealer.dealer(self.mydeck)