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):
|
def deal(self):
|
||||||
self.face = randint(1, 11)
|
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
|
return self.face
|
||||||
|
|
||||||
|
|||||||
35
dealer.py
35
dealer.py
@@ -2,18 +2,45 @@ import retro
|
|||||||
from card import Card
|
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 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.
|
#this code will be the agent refered to as dealer for now.
|
||||||
|
|
||||||
def deal_first:
|
|
||||||
dealer_hand=[]
|
dealer_hand=[]
|
||||||
player1_hand=[]
|
player1_hand=[]
|
||||||
|
|
||||||
|
def deal_first():
|
||||||
|
|
||||||
|
|
||||||
#deal two cards to the dealer one up and one down
|
#deal two cards to the dealer one up and one down
|
||||||
dealer_show = Card()
|
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_hand.append(dealer_show)
|
||||||
|
|
||||||
dealer_hidden = Card()
|
dealer_hidden = Card()
|
||||||
print("▮")
|
print("▮")
|
||||||
dealer_hand.append(dealer_hidden)
|
dealer_hand.append(dealer_hidden)
|
||||||
|
|
||||||
#deal two cards to the player (both showing since it's one player)
|
#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