repl.it
Python

No description

fork
loading
Files
  • main.py
main.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from random import shuffle

class TexasHoldem:
    #create deck
    def __init__(self):
      values = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']
      suites = ['Heart', 'Spade', 'Club', 'Diamond']
    self.deck = [j + " " + i for j in values for i in suites]

    #shuffle deck
    def shuffle(self):
        shuffle(self.deck)

    #deal for players
    def deal(self, n_players):
        count = 0
        #card 1 list (will be shuffled, delt 'around the table' as if a real stack)
        playercard1 = list()
        while count < n_players:
            card1 = self.deck[count]
            playercard1.append(card1)
            count += 1

        #remove cards from deck that were delt 
        for i in playercard1:
            self.deck.remove(i)
        count = 0
         #card 2 list 
        playercard2 = list() 
        while count < n_players:
             card2 = self.deck[count]
             playercard2.append(card2)
             count += 1

         #remove cards from deck delt for 2nd card
        for i in playercard2:
             self.deck.remove(i)

        #merge cards of playercard1 and playercard2 into set     
        self.playerhand = zip(playercard1, playercard2)

    #define the flop    
    def flop(self):
        #burn a card
        del self.deck[0]
        #lay down three
        self.flopcards = self.deck[0:3]
        #delete flop from deck
        for i in self.flopcards:
            self.deck.remove(i)

    #same as flop for turn and river        
    def turn(self):
        del self.deck[0]
        self.turncard = self.deck[0:1]

        for i in self.turncard:   
            self.deck.remove(i)

    def river(self):
        del self.deck[0]
        self.rivercard = self.deck[0:1]

        for i in self.rivercard:
            self.deck.remove(i)

#create instance of Cards class            
c = TexasHoldem()
#shuffle for this instance
c.shuffle()

#deal for n players
c.deal(9)

print ('Player Hands:')
for i in c.playerhand:
    print (i)

#flop
c.flop()
print ('Flop:')
print (c.flopcards)

#turn
c.turn()
print ('Turn:')
print (c.turncard)

#river
print ('River:')
c.river()
print (c.rivercard)