-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard_Deck.cpp
85 lines (60 loc) · 1.61 KB
/
Card_Deck.cpp
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
76
77
78
79
80
81
82
83
84
85
#include "Card_Deck.h"
#include <iostream>
Card_Deck::Card_Deck() {
int index = 0;
// random
std::srand(time(0));
for (int cardValue = 1; cardValue <= 13; cardValue++) {
for (int newCard = 0; newCard < 4; newCard++) {
// If the value is 1, then it is an ace
if (cardValue == 1) {
this -> cards[index].cardIsAce = true;
}
// For any other card greater than a 10, their values are 10.
if (cardValue < 10) {
this -> cards[index].cardValue = cardValue;
}
else {
this -> cards[index].cardValue = 10;
}
index++;
}
}
this -> shuffleTheCards;
}
int Card_Deck::cardsDealt()
{
return 0;
}
void Card_Deck::shuffleTheCards() {
int random1;
int random2;
Cards temp;
for (int i = 0; i < deckLength / 2; i++) {
// Get 2 random card indexes
random1 = std::rand() % deckLength;
random2 = std::rand() % deckLength;
// Now swap the cards
temp = this -> cards[random1];
this -> cards[random1] = this -> cards[random2];
this -> cards[random2] = temp;
}
}
Cards Card_Deck::getCards(int player)
{
return Cards();
}
Cards Card_Deck::getCards(int player) {
this -> iter++;
// If player == 0, then the dealer is getting dealt his hand
if (player == 0) {
// You will only show the dealers card every other time
if (iter % 2 == 0) {
std::cout << "Dealer " << "You were dealt an " << this -> cards[iter].cardValue << std::endl;
}
else {
std::cout << player << "You were deal an " << this -> cards[iter].cardValue << std::endl;
}
return this -> cards[iter];
}
}