diff --git a/__pycache__/card.cpython-311.pyc b/__pycache__/card.cpython-311.pyc index 37a300d..c1d319f 100644 Binary files a/__pycache__/card.cpython-311.pyc and b/__pycache__/card.cpython-311.pyc differ diff --git a/card.py b/card.py index ca8b914..161b6a3 100644 --- a/card.py +++ b/card.py @@ -1,5 +1,5 @@ -#module defines the value of the card. -#the cards in blackjack have a range in value from 1-10 with a face card being worth 10 and an ace being worth 1 or 11 depending on what you choose it to be worth. +#module defines the value of the card. 1-13 display and value are defined outside of this class. + from random import randint class Card: @@ -11,9 +11,6 @@ class Card: def deal(self): self.face = randint(1, 13) - #I think here we should return 1-13 to include ace and face cards. - #This will make checking if 4 of a kind have been dealt easier. - #THEN when it comes to scoring we can use the value to calculate face cards as 10 points. return self.face diff --git a/dealer.py b/dealer.py index 75a846f..cd443c3 100644 --- a/dealer.py +++ b/dealer.py @@ -35,13 +35,125 @@ def deal_first(): def is_card_valid(card): cards_dealt = [] - - for card_face in cards_dealt: - if card_face == card: - return False - else: - cards_dealt.append(card) + counts = card_count(cards_dealt) + if card == 1: + if card_ones.value <= 3: + cards_dealt.append = [card] return True + return False + if card == 2: + if card_twos.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 3: + if card_threes.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 4: + if card_fours.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 5: + if card_fives.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 6: + if card_sixes.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 7: + if card_sevens.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 8: + if card_eights.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 9: + if card_nines.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 10: + if card_tens.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 11: + if card_jacks.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 12: + if card_queens.value <= 3: + cards_dealt.append = [card] + return True + return False + if card == 13: + if card_kings.value <= 3: + cards_dealt.append = [card] + return True + return False + + + +def card_count(cards_dealt): + + cards_ones = 0 + cards_twos = 0 + cards_threes = 0 + cards_fours = 0 + cards_fives = 0 + cards_sixes = 0 + cards_sevens = 0 + cards_eights = 0 + cards_nines = 0 + cards_tens = 0 + cards_aces = 0 + cards_jacks = 0 + cards_queens = 0 + cards_kings = 0 + + for face in self.face(): + if face == 1: + cards_ones+=1 + if face == 2: + cards_twos+=1 + if face == 3: + cards_threes+=1 + if face == 4: + cards_fours+=1 + if face == 5: + cards_fives+=1 + if face == 6: + cards_sixes+=1 + if face == 7: + cards_sevens+=1 + if face == 8: + cards_eights+=1 + if face == 9: + cards_nines+=1 + if face == 10: + cards_tens+=1 + if face == 11: + cards_jacks+=1 + if face == 12: + cards_queens+=1 + if face == 13: + cards_kings+=1 + + + + + + deal_first() diff --git a/pyproject.toml b/pyproject.toml index 7ce89ea..8bf0d1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] -name = "project-game" +name = "blackjack" version = "0.1.0" -description = "" +description = "draw cards or "hit" and see if you have a more points than the dealer hand. " authors = [ {name = "Chris Proctor",email = "chris@chrisproctor.net"} ] @@ -12,6 +12,14 @@ dependencies = [ "retro-games (>=1.1.0,<2.0.0)" ] +[project.scripts] +play = "game:play" + +[tool.retro] +author = "jacob" +description = "draw cards or "hit" and see if you have more points than the dealer hand." +instructions = "draw cards and make sure not to have more than 21 points or a lower total amount of points than the dealer."hit" when you are cofident with your cards to see if you win the round" +result_file = "result.json" [build-system] requires = ["poetry-core>=2.0.0,<3.0.0"] @@ -19,3 +27,4 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] package-mode = false +