Skip to content

Commit

Permalink
Update BlackjackGame.py (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesh1507 authored Oct 16, 2024
1 parent a3b538a commit bd5d657
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions Blackjack/BlackjackGame.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def getScore(self):
self.score = 0
for card in self.cards:
self.score += self.scoreDictionary[card]
self.adjustAceValue()
return self.score

def adjustAceValue(self):
Expand Down Expand Up @@ -145,25 +146,17 @@ def playRound3(self):
print("My Money: " + str(player.money))

def removeLossers(self):
i = 0
for player in self.playerlist:
if player.money <= 0:
self.playerlist.pop(i)
i += 1
self.playerlist = [player for player in self.playerlist if player.money > 0]

def refreshPlayerCard(self):
for player in self.playerlist:
player.cards = []
dealer.cards = []
self.dealer.cards = []

def genDeck(self):
cardType = ['2','3','4','5','6','7','8','9','10','J','Q','K','A']
self.cardDeck = []
for card in cardType:
self.cardDeck.append(card)
self.cardDeck.append(card)
self.cardDeck.append(card)
self.cardDeck.append(card)
cardType = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
self.cardDeck = [card for card in cardType for _ in range(4)]
random.shuffle(self.cardDeck)

# Set betting limits
min_bet = 5
Expand Down Expand Up @@ -192,4 +185,4 @@ def genDeck(self):
game1.drawCardsRound2()
game1.playRound3()
game1.removeLossers()
gameRound += 1
gameRound += 1

0 comments on commit bd5d657

Please sign in to comment.