-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
314 lines (305 loc) · 7.02 KB
/
Player.cpp
File metadata and controls
314 lines (305 loc) · 7.02 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#include "Player.h"
Player::Player(string name, int score)
{
this->Name = name;
this->Score = score;
}
string Player::GetName()
{
return this->Name;
}
int Player::GetScore()
{
return this->Score;
}
void Player::MeldCards(vector<size_t> places)
{
for (size_t i = 0; i < places.size(); i++)
{
this->Meld.PushBack(this->Hand.GetCard(places[i]));
this->Hand.RemoveFromDeck(places[i]);
}
}
Deck& Player::GetMeld()
{
return this->Meld;
}
Card& Player::DiscardCard(size_t place)
{
Card& temp = this->Hand.GetCard(place);
this->Hand.RemoveFromDeck(place);
return temp;
}
void Player::MakeTurn(Deck& deck, Deck& Discard)
{
}
//void Player::CalculateScore()
//{
// for (unsigned int i = 0; i < Meld.aDeck.size(); i++)
// {
// string cardRank = MeldedCards[i].substr(0, MeldedCards[i].find('-'));
//
// int value = atoi(cardRank.c_str());
//
// if (value < Rank(8) + RANK_OFFSET)
// Score += TWO_THROUGH_NINE_PTS;
// else if (value >= Rank(8) + RANK_OFFSET && value <= Rank(11) + RANK_OFFSET)
// Score += TEN_THROUGH_KING_PTS;
// else
// Score += ACE_POINTS;
// }
//
// for (unsigned int i = 0; i < Hand.size(); i++)
// {
// string cardRank = Hand[i].substr(0, Hand[i].find('-'));
//
// int value = atoi(cardRank.c_str());
//
// if (value < Rank(8) + RANK_OFFSET)
// Score -= TWO_THROUGH_NINE_PTS;
// else if (value >= Rank(8) + RANK_OFFSET && value <= Rank(11) + RANK_OFFSET)
// Score -= TEN_THROUGH_KING_PTS;
// else
// Score -= ACE_POINTS;
// }
//}
//
//int Player::GetHandSize() const
//{
// return Hand.size();
//}
//
//string Player::GetHandValue(const int& number) const
//{
// return Hand[number];
//}
//
//void Player::InsertIntoHand(const string& card)
//{
// Hand.push_back(card);
//}
//
//void Player::DisplayHand() const
//{
// cout << "Your hand:\n";
// for (unsigned int i = 0; i < Hand.size(); i++)
// cout << Hand[i] << " ";
// cout << "\n";
//}
//
//int Player::WhatDeckToPickFrom(const Deck &deck) const
//{
// int choice;
// cout << "Would you like to pick up from the pick up pile? ";
// cin >> choice;
//
// // They want to use cards from the pick up pile to meld
// if (choice == YES)
// {
// int firstLocationFromDeck;
//
// cout << "\nWhat is the bottom card location you wish to pick up from the deck? ";
// cin >> firstLocationFromDeck;
//
// while (firstLocationFromDeck < 0 || firstLocationFromDeck >= deck.GetPickFromPileSize())
// {
// cout << "Invalid location. Try again: ";
// cin >> firstLocationFromDeck;
// }
//
// return firstLocationFromDeck; // Must return the location that they want to initially pick from
// }
// else
// {
// // They want to pick from the deck
// return PICK_FROM_DECK;
// }
//}
//
//int Player::WhatCardToDiscard() const
//{
// int cardToDiscard;
//
// cout << "Which card would you like to discard? ";
// cin >> cardToDiscard;
//
// while (cardToDiscard < EMPTY || cardToDiscard >= GetHandSize())
// {
// cout << "That's an invalid indice. Try again! ";
// cin >> cardToDiscard;
// }
//
// return cardToDiscard;
//}
//
//void Player::OrganizeHand()
//{
// sort(Hand.begin(), Hand.end());
//}
//
//string Player::ReturnCard(const int& number) const
//{
// return Hand[number];
//}
//
//void Player::PopCard(const int& number)
//{
// Hand.erase(Hand.begin() + number);
//}
//
//void Player::DisplayMeldedCards() const
//{
// cout << "Your melded cards: \n";
// for (unsigned int i = 0; i < MeldedCards.size(); i++)
// {
// cout << MeldedCards[i];
// if (i < MeldedCards.size() - 1)
// cout << " ";
// }
// cout << "\n\n";
//}
//
//void Player::PopulateMeldedCards(const vector<int>& CardSpotsIWillMeld)
//{
// // Want to populate
// for (unsigned int i = 0; i < CardSpotsIWillMeld.size(); i++)
// {
// int locale = CardSpotsIWillMeld[i];
// string card = ReturnCard(locale);
// MeldedCards.push_back(card);
// PopCard(locale);
// }
// // Then sorts the melded cards!
// sort(MeldedCards.begin(), MeldedCards.end());
//}
//
//vector<int> Player::SecondTimeMeld() const
//{
// // Then must determine if they can meld cards after picking up or not
// int answer;
// cout << "\nWould you like to meld? ";
// cin >> answer;
//
// vector<int> cardsToMeld;
//
// if (answer == YES)
// cardsToMeld = RetrieveMeldSpots();
//
// return cardsToMeld;
//}
//
//void Player::ClearHandAndMeldedCards()
//{
// Hand.clear();
// MeldedCards.clear();
//}
//
//vector<int> Player::CardsToMeld() const
//{
// vector<int> cardsIWillMeld;
// cout << "\n";
// DisplayHand();
//
// cardsIWillMeld = RetrieveMeldSpots();
//
// return cardsIWillMeld;
//}
//
//void Player::GamePlay(Cards& deck, const vector<string>& compsMeldedCards, const string& compsName)
//{
// cout << "Your turn!\n\n";
//
// cout << "Current pick up pile:\n"; // X represents the top of the deck
// deck.DisplayAvailableCards(); // Show the player's what they are working with
//
// OrganizeHand();
// DisplayHand();
// cout << "\n";
// // Show the player the melded cards
// DisplayMeldedCards();
//
// cout << compsName << "'s melded cards: \n";
// for (unsigned int i = 0; i < compsMeldedCards.size(); i++)
// cout << compsMeldedCards[i] << " ";
// cout << "\n\n";
//
// // First must choose cards to pick up
// int choice = WhatDeckToPickFrom(deck);
//
// if (choice != PICK_FROM_DECK) // Picking from the pick up pile
// {
// InsertFromPickFromPile(deck, choice);
//
// OrganizeHand();
//
// // Populate the players newly melded cards
// PopulateMeldedCards(CardsToMeld());
//
// cout << "\n";
// DisplayMeldedCards();
// }
// else { // Picking up from the top of the deck
// InsertIntoHand(deck.TopDeckCard());
// deck.PopOffCard();
//
// // Only need to ask them to meld if they didn't want to the first time
// // This populates the users melded cards with a vector of cards that they are allowed to meld
// if (GetHandSize() > EMPTY)
// {
// cout << "\n";
// OrganizeHand();
// DisplayHand();
// PopulateMeldedCards(SecondTimeMeld());
// }
// }
//
// cout << "\n";
//
// // Finally, must discard a card
// if (GetHandSize() > EMPTY)
// {
// OrganizeHand();
// DisplayHand();
// cout << "\n";
// DiscardCard(deck, WhatCardToDiscard());
// }
//
// cout << "\n";
//}
//
//void Player::InsertFromPickFromPile(Cards& deck, const int& choice)
//{
// for (int i = deck.GetPickFromPileSize() - NEXT; i >= choice; i--)
// {
// InsertIntoHand(deck.GetPickFromPileCard(i)); // Insert the card into their hand
// deck.PopPickFromPileCard(); // Remove that card from the pile
// }
//}
//
//void Player::DiscardCard(Cards& deck, const int& cardSpot)
//{
// deck.InsertIntoPickFromPile(ReturnCard(cardSpot)); // First insert the card into the pick from pile
// PopCard(cardSpot); // Then pop the card out of the user's hand
//}
//
//vector<string> Player::ReturnVectorOfMyMeldedCards() const
//{
// return MeldedCards;
//}
//
//vector<int> Player::RetrieveMeldSpots() const
//{
// vector<int> cardsToMeld;
// int location = EMPTY;
//
// cout << "\nWhich cards from your hand do you want to meld?\n";
//
// while (location != TERMINATE_NUMBER)
// {
// cin >> location;
// if (location != TERMINATE_NUMBER)
// cardsToMeld.push_back(location);
// }
//
// return cardsToMeld;
//}