Repository navigation
Expand file tree
/
Copy pathClackJack.cpp
More file actions
122 lines (84 loc) · 2.41 KB
/
Copy pathClackJack.cpp
File metadata and controls
122 lines (84 loc) · 2.41 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include <iostream>
#include "C-Turtle/CTurtle.hpp"
#include <unordered_map>
#include <memory>
#include <random>
namespace turtCard = cturtle;
std::random_device rd;
std::mt19937 gen(rd());
struct Card {
std::string suit;
std::string value;
std::shared_ptr<cturtle::Turtle> turtCard;
};
class Player {
public:
std::vector<Card> hand;
};
class Deck{
private:
std::vector<Card> cardList;
std::vector<Card> discardList;
public:
Deck(cturtle::TurtleScreen& screen) {
for (int i = 0; i < 52; i++) {
std::string suit;
std::string value;
if (i < 13) {
suit = "Hearts";
value = std::to_string(i + 1);
}
else if (i < 26) {
suit = "Diamonds";
value = std::to_string(i - 12);
}
else if (i < 39) {
suit = "Clubs";
value = std::to_string(i - 25);
}
else {
suit = "Spades";
value = std::to_string(i - 38);
}
Card card = {suit, value, std::make_shared<cturtle::Turtle> (screen)};
cardList.push_back(card);
}
}
Card getCard() {
int deckSize = cardList.size();
std::uniform_int_distribution<> dis(0, deckSize - 1);
int randomIndex = dis(gen);
Card grabbedCard = cardList[randomIndex];
discardList.push_back(grabbedCard);
cardList.erase(cardList.begin() + randomIndex);
return grabbedCard;
}
};
class Button {
private:
std::string label;
std::shared_ptr<cturtle::Turtle> turtButton;
}
class ClackJack {
private:
Deck deck;
Player player;
Player dealer;
public:
void startGame() {
bool Gamerule = true;
player.hand.push_back(deck.getCard());
dealer.hand.push_back(deck.getCard());
player.hand.push_back(deck.getCard());
dealer.hand.push_back(deck.getCard());
while (Gamerule) {
}
}
};
int main() {
cturtle::TurtleScreen screen;
scr
Deck deck(screen);
screen.exitonclick();
return 0;
}