generated from mwc/project_game
@Chris
I need some help organizing my functions, methods and classes. I have a card class that returns a card value I have a dealer file that has a function that deals the first two cards I'm still a little lost on how this works into the Game class and how to organize the play. I want to: 1. deal two cards to each dealer and player 2. hide one of the dealers cards 3. present the user with their cards and let them choose * hit me OR * stay. 4. If they hit, deal another card to them and calculate if they went over 21. If they went over 21 end the game with BUST Dealer WINS!. If they didn't go over 21, calculate their score and allow the dealer their turn. 5. If they stay, calculate their score and let the dealer have their turn. 6. Dealer - checks their cards and compares them to the player. Then chooses to hit or stay. Print choice to screen. If they hit, show the card to the player.
This commit is contained in:
BIN
__pycache__/card.cpython-311.pyc
Normal file
BIN
__pycache__/card.cpython-311.pyc
Normal file
Binary file not shown.
15
card.py
Normal file
15
card.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#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.
|
||||
from random import randint
|
||||
|
||||
class Card:
|
||||
def __init__(self):
|
||||
self.deal()
|
||||
|
||||
def __str__(self):
|
||||
return str(self.face)
|
||||
|
||||
def deal(self):
|
||||
self.face = randint(1, 11)
|
||||
return self.face
|
||||
|
||||
3
cardgame.py
Normal file
3
cardgame.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import retro
|
||||
#main code used to start the game.
|
||||
state = {}
|
||||
2
deal.py
Normal file
2
deal.py
Normal file
@@ -0,0 +1,2 @@
|
||||
import retro
|
||||
#code will be used to deal out cards for each player playing depending on the game played.
|
||||
19
dealer.py
Normal file
19
dealer.py
Normal file
@@ -0,0 +1,19 @@
|
||||
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.
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
3
draw.py
Normal file
3
draw.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import retro
|
||||
#this code will allow the player to draw cards from the deck of cards.
|
||||
|
||||
8
proposal.md
Normal file
8
proposal.md
Normal file
@@ -0,0 +1,8 @@
|
||||
group: indivually
|
||||
game name: quick card games
|
||||
vision for the game and reason for making it:A card game can take a bit to set up sometimes and it isn't always easy to carry a deck of cards around.If it was digital them them you wouldnt need to carry a deck of cards around and worry about losing them.
|
||||
visual appearence:The game will appear similiar to a group of people playing on a table with a deck cards(the draw pile),a dealt amount of cards that vary depending on the game chosen and a table with the cards on it.
|
||||
how the player will interact with the game:The player will choose a card game with a estimated amount of time that the game takes to finish(if possible).Once chosen you can decide to either play with a second player or against the ai so it can be played by yourself.You will then be dealed a set amount of cards depending on the game chosen.You will then select the card to play or draw from the deck.
|
||||
core mechanics:depending on the game chosen your actions will vary but the 2 that are important are selecting your card to play and drawing from the deck.Some games you will play to eithier get the least amount of cards while others will be to have a number within a set range.
|
||||
first goal to achieve:The first step in developing the code is to define the value of each card to make the cards drawn random.
|
||||
challenges:The challenge is going to be creating a code for Ai to allow a single person to play without needing another person to play the game.Another one would be to create a method to prevent another person from being able to see someone else cards.
|
||||
2
shuffle.py
Normal file
2
shuffle.py
Normal file
@@ -0,0 +1,2 @@
|
||||
import retro
|
||||
#code used to shuffle the cards in a deck to keep each game different and not as predictable.
|
||||
Reference in New Issue
Block a user