Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blaise-93/blackjack-py
Blackjack game written in python where a player and a dealer can actually play their game till someone wins.
https://github.com/blaise-93/blackjack-py
Last synced: about 1 month ago
JSON representation
Blackjack game written in python where a player and a dealer can actually play their game till someone wins.
- Host: GitHub
- URL: https://github.com/blaise-93/blackjack-py
- Owner: Blaise-93
- Created: 2023-10-18T21:49:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-22T13:19:26.000Z (about 1 year ago)
- Last Synced: 2023-10-23T13:32:37.018Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
Awesome Lists containing this project
README
# Blackjack Game
A blackjack game written in python which you can play and determine whether you win or lose.
Here, we have 52 cards and all cards can be exhausted between the player and the dealer, provided
that we have a winner. The players can actually terminate the game halfway and a winner might still
be emerged depending on the card each of the player is currtently holding.
The `check_winner` method of `Game class` actually does that for us with while loop functionality in
our scripts. If there is no winner, the game will continue till by prompting you to select
Hit or Stand till we have a winner. For example, when the two
players are holding a blackjack, of course, it is a tie. The game goes on. :D#### Code snippet of what happens behind the scene:
```python`
def check_winner(self, dealer_hand, player_hand, game_over=False):
if not game_over:
if player_hand.get_value() > 21:
print("You bursted, dealer win! ☕")
return Trueelif dealer_hand.get_value() > 21:
print("Dealer bursted. You win! ❤️")
return Trueelif dealer_hand.is_blackjack() and \
player_hand.is_blackjack():
print("Both players have blackjack! Tie ")
return Trueelif player_hand.is_blackjack():
print("You have a blackjack. You win! ❤️")
return Trueelif dealer_hand.is_blackjack():
print("Dealer have a blackjack. Dealer Wins. You are bursted, dude! ")
return Trueelse:
if player_hand.get_value() > dealer_hand.get_value():
print('You win! ❤️')elif player_hand.get_value() == dealer_hand.get_value():
print("It's a Tie")else:
print('Dealer win! ')return True
return False``
-- Pictorial Reprensentation of the game in your terminal:
![blackjack-py](https://github.com/Blaise-93/blackjack-py/assets/58372011/b14d2035-055c-4e4a-9e16-29f9d42cee44)To play this amazing game all you need to do is to clone this in your terminal:
```shell
[email protected]:Blaise-93/blackjack-py.git
```- and then you can play the game.
Thanks for checking out, goodluck!