-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeck.cpp
More file actions
33 lines (28 loc) · 822 Bytes
/
Copy pathDeck.cpp
File metadata and controls
33 lines (28 loc) · 822 Bytes
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
#include "Deck.h"
Deck::Deck() {
// create orange cards
for (int i=1; i <= 10; i++) {
Card NewCard(i, Card::orange);
deck.push_back(NewCard);
}
// create purple cards
for (int i=1; i <= 10; i++) {
Card NewCard(i, Card::purple);
deck.push_back(NewCard);
}
}
void Deck::shuffle() {
// shuffles the deck in a truly random way
unsigned timeseed = std::chrono::system_clock::now().time_since_epoch().count();
std::shuffle(deck.begin(), deck.end(), std::default_random_engine(timeseed));
}
Card Deck::drawCard() {
// take the first card from the deck
Card card = deck[0];
// remove the first card from the deck
deck.erase(deck.begin());
return card;
}
int Deck::getDeckSize() {
return deck.size();
}