-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameObservers.cpp
201 lines (175 loc) · 4.87 KB
/
GameObservers.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
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
#include "GameObservers.h"
#include<iostream>
using namespace std;
void Phase::notify(int playerNb, vector<string>* actionsOfPLayer) {
actionsPlayerTook[playerNb] = *actionsOfPLayer;
}
void Phase::display() {
cout << endl;
cout << endl;
cout << "******* USING HAKI OF OBSERVATION, THIS IS WHAT HAPPENNED SO FAR IN THIS TURN **************";
for (std::pair<int, vector<string>> element : actionsPlayerTook) {
cout << endl;
cout << "@Player " << element.first << " :" << endl;
for (int x = 0; x < element.second.size(); x++) {
cout << element.second[x] << endl;
}
}
//array for each player how many cities they have
//int citiesInBoard[3];
cout << "******* TOO MUCH HAKI WAS USE , LETS REST A LITTLE BIT **************";
}
void Phase::reset() {
actionsPlayerTook.clear();
}
void View::notify(string country, string colorPlayer) {
allCountryStats[country] = colorPlayer;
updateContinent();
}
void View::displayCountryStats() {
int counters[5] = {0,0,0,0,0};
int total=allCountries.size();
cout << endl;
cout << "******** LETS TAKE A LOOK OF WHICH COUNTRY IS OWNED BY WHO!!"<<endl;
for (std::pair<string, string> element : allCountryStats) {
cout << " - "<<element.first<<" OWNED BY : "<<element.second << endl;
if (element.second == "red")
{
counters[0]++;
}
else if (element.second == "blue")
{
counters[1]++;
}
else if (element.second == "yellow")
{
counters[2]++;
}
else if (element.second == "green")
{
counters[3]++;
}
else if (element.second == "white")
{
counters[4]++;
}
}
for (int i = 0; i < allplayers.size(); i++)
{
cout << "Player " << allplayers[i]->getColor() << " has the following flow chart ";
for (int j = 0; j < counters[i]; j++)
{
cout << "+";
}
for (int j = 0; j < total; j++)
{
cout << "-";
}
cout << endl;
}
}
void View::displayContinentStats() {
int counters[5] = { 0,0,0,0,0 };
int total = allContinent.size();
cout << endl;
cout << "******** LETS TAKE A LOOK OF WHICH CONTINENT IS OWNED BY WHO!!" << endl;
for (std::pair<string, string> element : allContinentStats) {
cout << " - " << element.first << " OWNED BY : " << element.second << endl;
if (element.second == "red")
{
counters[0]++;
}
else if (element.second == "blue")
{
counters[1]++;
}
else if (element.second == "yellow")
{
counters[2]++;
}
else if (element.second == "green")
{
counters[3]++;
}
else if (element.second == "white")
{
counters[4]++;
}
}
for (int i = 0; i < allplayers.size(); i++)
{
cout << "Player " << allplayers[i]->getColor() << " has the following flow chart ";
for (int j = 0; j < counters[i]; j++)
{
cout << "+";
}
for (int j = 0; j < total; j++)
{
cout << "-";
}
cout << endl;
}
}
void View::displayStats() {
cout << endl;
cout << "********* LETS USE THE BYAKUGAN TO SEE ALL THE STATS *********" << endl;
for (int x = 0; x < allplayers.size(); x++) {
allplayers[x]->displayInfo();
}
displayCountryStats();
displayContinentStats();
cout << "********* TOO MUCH BYAKUGAN WAS USED, LETS REST A LITTLE BIT *********" << endl;
}
void View::updateContinent() {
for (pair<string, string> element : allCountryStats) {
allContinentStats[allCountries[element.first]->getContinentName()] = allContinent[allCountries[element.first]->getContinentName()]->setOwnedColor();
}
}
void View::setAllPlayers(vector<Player*> allplayers) {
this->allplayers = allplayers;
}
void View::setallContinent(unordered_map<string, Continent*> allContinents) {
this->allContinent = allContinents;
}
void View::setallCountry(unordered_map<string, Country*> allCountries) {
this->allCountries = allCountries;
}
void View::notifyPlayerPoints(int player, int point) {
playerPoint[player] = point;
}
void View::notifyWinner(int player) {
playerWinner = player;
}
void View::displayWin() {
cout << endl;
cout << "___________________________________________________________________________" << endl;
cout << "| Payer # | Cards | Victory Points | Coins | Color |" << endl;
for (pair<int, int> element : playerPoint) {
for (Player* elementplayer : allplayers) {
if (*elementplayer->getId() == element.first) {
cout << "|_____" << element.first << "_____|____" << elementplayer->getHand()->getHand().size() << "____|_________"<<element.second<<"_________|____"<<*elementplayer->getCoins()<<"____|_____"<< elementplayer->getColor()<< endl;
}
}
}
int valueWin = 0;
int playerint = 0;
int isWin = 1;
for (pair<int, int> element : playerPoint) {
if (element.second > valueWin) {
valueWin = element.second;
playerint = element.first;
isWin = 1;
}
else if(element.second == valueWin){
isWin = 0;
}
}
if (isWin == 1) {
cout << endl;
cout << "THE WINNNER ISSSS ...... PLAYER " << playerint << " WITH " << valueWin << " POINTS" << endl;
}
else {
cout << endl;
cout << "THERE IS NO WINNER, THE RESULT IS DRAW!!!" << endl;
}
}