#๐Ÿ”’ Blackjack OOP

41 messages ยท Page 1 of 1 (latest)

versed remnant
#

Hello, here's my implementation of python. I would like to receive some feedback on my code, which is my first try on a slightly complex project. In particular I'm not too satisfied with the check_hand() method, I was thinking about changing it to a value property. I am aware not everything is done, for instance pair splitting. Thanks!

https://github.com/Allonaldo/Blackjack

GitHub

Blackjack implemented in Python using an object oriented approach - Allonaldo/Blackjack

blazing kestrelBOT
#

@versed remnant

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

gilded garnet
#

also, is that repository fully up to date?

#

it has from card import Card, Deck, Player, Dealer but there is no card.py

#
(3.13.5) luna@msi-arch ~/Downloads/Blackjack (main) $ tree
.
โ”œโ”€โ”€ blackjack.py
โ”œโ”€โ”€ game_objects.py
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ __pycache__
โ”‚   โ”œโ”€โ”€ card.cpython-310.pyc
โ”‚   โ”œโ”€โ”€ card.cpython-312.pyc
โ”‚   โ”œโ”€โ”€ game.cpython-312.pyc
โ”‚   โ”œโ”€โ”€ test_card.cpython-312.pyc
โ”‚   โ””โ”€โ”€ test_check_hand.cpython-312.pyc
โ”œโ”€โ”€ test_card.py
โ””โ”€โ”€ test_check_hand.py
gilded garnet
versed remnant
versed remnant
gilded garnet
gilded garnet
#

make sure you've added it with git add

#

committed with git commit -m "message"

#

and then pushed

plush blaze
#

its inside game_objects.py, not card.py

versed remnant
#

jup I added it with git add .

gilded garnet
#

then it shouldn't be from card import ...

#

it should be from game_objects import ...

#

your tests will fail in their current state

plush blaze
#

im not the one who wrote it

gilded garnet
#

I didn't reply to your message did I?

versed remnant
#

I updated it, the version on github is up to date

gilded garnet
#

one more pull and i'll take another look

#

It does look pretty decent, your Dealer().pay() method doesn't use the same type every time but I guess that's fine

#

overall doesn't look bad

gilded garnet
gilded garnet
#

main.py

from GameObjects import ...

def play():
    ...

if __name__ == "__main__":
  play()
versed remnant
#

What do you think about the check_hand() method in the Player class? I was considering modifiying the class such that if the value property is accessed it is calculated automatically

gilded garnet
#

i think just add @property above it tbh

versed remnant
gilded garnet
versed remnant
#

like that?

gilded garnet
#

uh yeah that could work

#

probably

versed remnant
#

alright, thanks for your help!

gilded garnet
#

you're welcome

blazing kestrelBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.