-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table.cpp
156 lines (125 loc) · 4.53 KB
/
Table.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
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
/**
* @file Table.cpp
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2021-02-13
*
* @copyright Copyright (c) 2021
*
*/
#include <cstdio>
#include <string>
#include <iostream>
#include <stdlib.h>
#include <vector>
#include "Deck.hpp"
#include "Table.hpp"
using namespace std;
// vector<int> getHandValue1(vector<class Card> hand){
// vector<int> values = {0,0};
// // int value = 0;
// for(auto i:hand){
// if(i.rank > 10){
// values[0] += 10;
// values[1] += 10;
// } else if(i.rank == 1){
// values[0] += 1;
// values[1] += 11;
// } else {
// values[0] += i.rank;
// values[1] += i.rank;
// }
// }
// return values;
// }
vector<string> createSpace(int height, int width){
vector<string> tempVector;
for(int i=0; i < height; i++){
string tempstr = "";
for(int j=0; j < width; j++){
tempstr += " ";
}
tempVector.push_back(tempstr);
}
return tempVector;
}
void printCombined(vector<vector<string>> vec){
for(int i=0; i< (int)vec[0].size(); i++){
for(auto j : vec){
cout << j[i];
}
cout << endl;
}
}
vector<vector<string>> combineCards(vector<class Card> hand){
vector<vector<string>> tempVec;
for(auto i: hand){
tempVec.push_back(i.cardDesign);
}
return tempVec;
}
void printBettingScreen(Player player){
system("clear");
cout << "|Balance: " << player.balance << endl;
cout << "|Enter your bet: ";
}
void printTable(Player dealer, Player player, vector<string> movesAvaliable, int winCondition){
system("clear");
vector<string> initspace = createSpace(CardHeight,10);
vector<string> cardSpace = createSpace(CardHeight, 5);
// Print Dealer hand
vector<vector<string>> dealerCombined = combineCards(dealer.hand);
if(dealer.hand.size() < 2){
// vector<string> hiddenCard = getHiddenCard();
dealerCombined.push_back(getHiddenCard());
}
printCombined(dealerCombined);
cout << "\n\n";
vector<vector<string>> playerCombined = combineCards(player.hand);
printCombined(playerCombined);
string Moves = "";
for(auto i: movesAvaliable){
if(i != movesAvaliable.back()){
Moves += i + ", ";
} else {
Moves += i;
}
}
switch(winCondition){
case win:
cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
cout << "|You WIN! Do you want to play again? (y/n) ";
break;
case lose:
cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
cout << "|You Lose! Do you want to play again? (y/n) ";
break;
case bust:
cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
cout << "|BUST!! Do you want to play again? (y/n) ";
break;
default:
cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
cout << "|Moves avaliable: " << Moves << "| ";
}
// if(!bust && !lower && !win){
// cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
// cout << "|Moves avaliable: " << Moves << "| ";
// } else if(bust){
// // vector<int> playerValue = getHandValue1(player.hand);
// // cout << "playerValue[0]: " << playerValue[0] << " playerValue[1]: " << playerValue[1] << endl;
// cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
// cout << "|BUST!! Do you want to play again? (y/n) ";
// } else if(lower){
// // vector<int> playerValue = getHandValue1(player.hand);
// // cout << "playerValue[0]: " << playerValue[0] << " playerValue[1]: " << playerValue[1] << endl;
// cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
// cout << "|You Lose! Do you want to play again? (y/n) ";
// } else if(win){
// // vector<int> playerValue = getHandValue1(player.hand);
// // cout << "playerValue[0]: " << playerValue[0] << " playerValue[1]: " << playerValue[1] << endl;
// cout << "\n\n|Current bet: " << player.bet << "||Balance: " << player.balance << "|" << endl;
// cout << "|You WIN! Do you want to play again? (y/n) ";
// }
}