generated from mwc/project_game
made some updates to card and dealer to deal with face cards
This commit is contained in:
Binary file not shown.
4
card.py
4
card.py
@@ -11,5 +11,9 @@ class Card:
|
||||
|
||||
def deal(self):
|
||||
self.face = randint(1, 11)
|
||||
#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
|
||||
|
||||
|
||||
37
dealer.py
37
dealer.py
@@ -2,18 +2,45 @@ import retro
|
||||
from card import Card
|
||||
#this code will be for creating a player to play against or to deal cards and to ask about your next action to continue the game.
|
||||
#this code will be the agent refered to as dealer for now.
|
||||
dealer_hand=[]
|
||||
player1_hand=[]
|
||||
|
||||
def deal_first():
|
||||
|
||||
def deal_first:
|
||||
dealer_hand=[]
|
||||
player1_hand=[]
|
||||
|
||||
#deal two cards to the dealer one up and one down
|
||||
dealer_show = Card()
|
||||
print("dealer shown card:"+ dealer_show)
|
||||
while is_card_valid(dealer_show) == False:
|
||||
dealer_show = Card()
|
||||
if dealer_show == 1:
|
||||
print("dealer shown card:"+ "Ace")
|
||||
if dealer_show == 10:
|
||||
print("dealer shown card:"+ "Jack")
|
||||
#continue code here to show the correct face based on what was drawn
|
||||
|
||||
print("dealer shown card:"+ str(dealer_show))
|
||||
|
||||
dealer_hand.append(dealer_show)
|
||||
|
||||
dealer_hidden = Card()
|
||||
print("▮")
|
||||
dealer_hand.append(dealer_hidden)
|
||||
|
||||
#deal two cards to the player (both showing since it's one player)
|
||||
|
||||
|
||||
def is_card_valid(card):
|
||||
cards_dealt = []
|
||||
|
||||
|
||||
for card_face in cards_dealt:
|
||||
if card_face == card:
|
||||
return False
|
||||
else:
|
||||
cards_dealt.append(card)
|
||||
return True
|
||||
|
||||
deal_first()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user