-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeck.cpp
More file actions
75 lines (65 loc) · 1.31 KB
/
Copy pathdeck.cpp
File metadata and controls
75 lines (65 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "main.h"
#include "deck.h"
#include "card.h"
#include "player.h"
Deck::Deck(vector<Card> diffCards)
{
cards = diffCards;
}
void Deck::initialize()
{
vector<string> colors = {"R", "B", "G", "Y"};
for (int i=0; i < 13; i++) {
for (int j=0; j < 4; j++) {
Card newCard(colors[j], i);
cards.push_back(newCard);
cards.push_back(newCard);
}
}
for (int i= 13; i < 15; i++)
{
Card newCardSP("D", i);
for (int j=0; j < 4; j++) {
cards.push_back(newCardSP);
}
}
}
void Deck::shuffleDeck() {
random_device rd;
mt19937 g(rd());
shuffle(cards.begin(), cards.end(), g);
}
void Deck::add(Card c)
{
cards.push_back(c);
}
Card Deck::peek()
{
return cards[cards.size() - 1];
}
void Deck::pop()
{
cards.pop_back();
}
void Deck::toString()
{
for (int i = 0; i < cards.size(); i++)
{
cout << cards[i].toString();
}
}
void Deck::distributeCards(vector<Player> &players)
{
for(int i = 0; i < players.size(); i++ )
{
for (int j = 0; j < 7; j++)
{
players[i].addToHand(cards[cards.size() - 1]);
cards.pop_back();
}
}
}
vector<Card> Deck::getDeck()
{
return cards;
}