I am trying to figure out how to create a card game with 5 players in it. The mission of the game is to collect 7 cards of the same suit you choose. You can sail you ship if you have 7 cards of the same suit. The card numbers are unrelated in this game. You need to pass one unnecessary card to your neighboring player, like a clockwise turn by all players. So others so in the same way at the same time. You can see your 7 card sets.
output looks like this:
(a)H5 (b)DK (c)S2....
Which one to replace? a
Hint: player0 passed H5 to player 1
Hint: player1 passed S6 to player 2
....
If you input ? you can see the cards of other players.
So far i created structs
1 2 3 4 5 6 7 8 9 10 11
struct Card {
char suit;
int number;
}
struct Player {
vector<Card> player;
}
struct Game {
vector<Card>deck;
vector<Player>players;
}
I am not sure if i am doing it correctly. Should I create Game struct or use main function for that. I am new to C++, this is too confusing to me. Can you give me a hint how I can start? Thanks
I've created a struct with all the values you need for one player, and then show, there are 5 players. I fill just one hand with random numbers and print them to screen. Also manually filled the suits for the cards. You'll fill them yourself as you deal the cards in your game. Hope this gets you started on your game..
#include <iostream>
#include <Windows.h>
using std::cout;
using std::cin;
using std::endl;
struct Player {
char suit[7]; // For the seven cards in the hand. Suit & number
int number[7];
} Players[5]; // Five players
int main()
{
for (int a = 0; a < 7; a++)
Players[1].number[a] = rand() % 13;
Players[1].suit[0] = 'S';
Players[1].suit[1] = 'C';
Players[1].suit[2] = 'H';
Players[1].suit[3] = 'H';
Players[1].suit[4] = 'C';
Players[1].suit[5] = 'C';
Players[1].suit[6] = 'D';
for (int a = 0; a < 7; a++)
cout << "Player [1] has a " << Players[1].number[a] << " of " << Players[1].suit[a] << " for card #" <<a+1 << endl;
return 0;
}
I'm a little confused by this game. What gets done with the rest of the deck? Seven cards times five players equals only thirty-five out of fifty-two cards. Where do the rest of the deck come into play?