I need to make a blackjack game which matches the real life version. However I feel really overwhelmed and lost. So far I've started the menu, which isn't working as I don't know what condition to put in the while. But even when that is working I don't know where to go from here. I know I need to create the cards and set the deck up which I was going to do using enums but I just feel lost. I want to keep it as basic as I can.
Create an object to represent a single card.
Create an instance of that object. Make it represent a single card.
Create 52 of those objects. Make each represent a different card.
Also, you appear to be trying to define a function, Introduction(), inside another function definition, main(). You cannot do this. You cannot define functions inside other functions.
Line 2: You need to include <cstdio> in order to use cout.
Line 9: You can't nest functions.
Line 12: A few problems. 1) choice is not declared,. 2) You have noting to compare choice to. 3) You might want to use a do/while loop rather than a while loop since you don't get the value of choice until line 20.
Lines 14-20: Aren't these lines really your menu and belong in GameMenu()?
Line 30: You don't have a way of exiting the game here.
Are you writing this in C or C++. If you're writing in C++, you might start to think about the objects you will need in your game. A Deck which contains cards, two or more Players, etc.
Ok, I think you need to approach the functionality first, before any titles, menus or fancy features.
First step would be to create a function that creates an array of a set of cards, by combining the suits with the values creating all possibilities. Each possibility is then added to an array (vector)
#include <vector>
#include <string>
......
vector<vector<string>> createDeckOfCards()
{
vector<string> suits = { "C","D","H","S" }; //Suits in deck: Clubs, Diamonds, Hearts, Spades
vector<string> values = { "A","2","3","4","5","6","7","8","9","10","J","Q","K" }; //Values for cards in deck
vector<vector<string>> deckOfCards; // Array to hold deck
for (int suit = 0; suit < suits.size(); ++suit) //go through all the suits
{
for (int value = 0; value < values.size(); ++value) //go through all the values
{
deckOfCards.push_back({ values[value],suits[suit] }); //combine suit and values then add to deck of cards array
}
}
return deckOfCards; //return array once finished
}
You're next step would be to produce a function that gets your newly created deck of cards as an input, then shuffles them, returning the now shuffled deck.
After these 2 functions, you now have a deck of cards that are shuffled, which you can now assign the player 2 chosen cards.
Since they are shuffled, you can assign them the first item in the deck of cards array, then remove it so it cannot be chosen twice.
Something like this.
1 2
cardsInHand.push_back(deckOfCards[0]); //add first card to players cards in hand
deckOfCards.erase(deckOfCards.begin()); //remove chosen item (first card) from deck of cards
The rest of the program now relies on if functions, inputs and loops to allow the player to continue until the end of the game, at which they can then continue with a new reshuffled deck of cards or exit the game.
couple of overly simple whys:
...
vector<int> suit(Face_max);
for(int i = 0; i<Face_max; i++)
...
remember that blackjack specifically is an annoying game that tends to have multiple decks mixed together, so its possible to draw 8 copies of the 2 of spades in a row for example. On the flipside, infinite shoe approach isnt a bad game: just randomly generate each and every card on the fly, don't need any decks/shoes/whatevers that way.
if input == hit
total += roll_a_card()
as long as your random algorithm is good, it should not do anything too crazy.