This commit is contained in:
jandrews
2026-01-13 12:57:09 -05:00
parent 5399ffd008
commit 39695c2d92
4 changed files with 131 additions and 13 deletions

Binary file not shown.

View File

@@ -1,5 +1,5 @@
#module defines the value of the card. #module defines the value of the card. 1-13 display and value are defined outside of this class.
#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.
from random import randint from random import randint
class Card: class Card:
@@ -11,9 +11,6 @@ class Card:
def deal(self): def deal(self):
self.face = randint(1, 13) 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 return self.face

124
dealer.py
View File

@@ -35,13 +35,125 @@ def deal_first():
def is_card_valid(card): def is_card_valid(card):
cards_dealt = [] cards_dealt = []
counts = card_count(cards_dealt)
for card_face in cards_dealt: if card == 1:
if card_face == card: if card_ones.value <= 3:
return False cards_dealt.append = [card]
else:
cards_dealt.append(card)
return True 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() deal_first()

View File

@@ -1,7 +1,7 @@
[project] [project]
name = "project-game" name = "blackjack"
version = "0.1.0" version = "0.1.0"
description = "" description = "draw cards or "hit" and see if you have a more points than the dealer hand. "
authors = [ authors = [
{name = "Chris Proctor",email = "chris@chrisproctor.net"} {name = "Chris Proctor",email = "chris@chrisproctor.net"}
] ]
@@ -12,6 +12,14 @@ dependencies = [
"retro-games (>=1.1.0,<2.0.0)" "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] [build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"] requires = ["poetry-core>=2.0.0,<3.0.0"]
@@ -19,3 +27,4 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
package-mode = false package-mode = false