-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.cpp
123 lines (96 loc) · 2.59 KB
/
display.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
#include "display.h"
TextDisplay::TextDisplay(){
}
TextDisplay::~TextDisplay(){
}
void TextDisplay::printBoard(vector <Board*> players, int highScore) {
int gap = 5;
cout << string(players.size() * (11 + gap) - gap, '-') << endl;
cout << "High Score: " << highScore << endl;
cout << string(players.size() * (11 + gap) - gap, '-') << endl;
for (Board* b1 : players) {
cout << "Player: " << b1->playerNumber;
cout << string(gap, ' ');
}
cout << endl;
for (Board* b1 : players) {
cout << string(11, '-');
cout << string(gap, ' ');
}
cout << endl;
for (Board* b1 : players) {
cout << "Level: " << b1->getCurrentLevel()->currentLevel;
cout << string(gap, ' ');
}
cout << endl;
for (Board* b1 : players) {
cout << "Score:" << string(5 - to_string(b1->getScore()).length(), ' ') << b1->getScore();
cout << string(gap, ' ');
}
cout << endl;
for (Board* b1 : players) {
cout << string(11, '-');
cout << string(gap, ' ');
}
cout << endl;
for (int i = 0; i < 18; i += 1) {
for (Board* b1 : players) {
for (int j = 0; j < 11; j += 1) {
if (i >= b1->getGapTop() && i - b1->getGapTop() < 4 && j >= b1->getGapLeft() && j - b1->getGapLeft() < 4) {
if (b1->getCurrentBlock()->units[i - b1->getGapTop()][j - b1->getGapLeft()]->isInit()) {
cout << b1->getCurrentBlock()->units[i - b1->getGapTop()][j - b1->getGapLeft()]->getBlockString();
}
else if (b1->isBlind() && j >= 2 && j <= 8 && i <= 18 - 3 && i >= 18 - 12) {
cout << "?";
}
else if (b1->getTheBoard()[i][j]->isInit()) {
cout << b1->getTheBoard()[i][j]->getBlockString();
}
else {
cout << " ";
}
}
else if (b1->isBlind() && j >= 2 && j <= 8 && i <= 18 - 3 && i >= 18 - 12) {
cout << "?";
}
else if (b1->getTheBoard()[i][j]->isInit()) {
cout << b1->getTheBoard()[i][j]->getBlockString();
}
else {
cout << " ";
}
}
cout << string(gap, ' ');;
}
cout << endl;
}
for (Board* b1 : players) {
cout << string(11, '-');
cout << string(gap, ' ');
}
cout << endl;
for (Board* b1 : players) {
cout << "Next: ";
cout << string(gap, ' ');
}
cout << endl;
for (int i = 2; i < 4; i += 1) {
for (Board* b : players) {
if (b->getNextBlock() != nullptr) {
for (int j = 0; j < 4; j += 1) {
if (b->getNextBlock()->units[i][j]->isInit()) {
cout << b->getNextBlock()->units[i][j]->getBlockString();
}
else {
cout << " ";
}
}
cout << string(7, ' ') << string(gap, ' ');
}
else {
cout << string(11, ' ') << string(gap, ' ');
}
}
cout << endl;
}
}