-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.cc
114 lines (89 loc) · 2.25 KB
/
display.cc
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
#include "display.h"
#include "cell.h"
#include "subject.h"
#include "info.h"
using namespace std;
std::vector<std::vector<char>> set(int r, int c) {
std::vector<std::vector<char>> theDisplay;
for (int i = 0; i < r; ++i) {
std::vector<char> row;
for (int j = 0; j < c; ++j) {
row.emplace_back(' ');
}
theDisplay.emplace_back(row);
}
return theDisplay;
}
TextDisplay::TextDisplay(int r, int c)
: theDisplay{set(r, c)}, r{r}, c{c} {}
void TextDisplay::notify(Subject & whoNotified) {
int row = whoNotified.getInfo().row;
int col = whoNotified.getInfo().col;
State c = whoNotified.getInfo().thing;
if (c == State::Vampire) {
theDisplay[row][col] = 'V';
}
if (c == State::Werewolf) {
theDisplay[row][col] = 'W';
}
if (c == State::Goblin) {
theDisplay[row][col] = 'N';
}
if (c == State::Merchant) {
theDisplay[row][col] = 'M';
}
if (c == State::Dragon) {
theDisplay[row][col] = 'D';
}
if (c == State::Phoenix) {
theDisplay[row][col] = 'X';
}
if (c == State::Troll) {
theDisplay[row][col] = 'T';
}
if (c == State::Character) {
theDisplay[row][col] = '@';
}
if (c == State::RH || c == State::BA || c == State::BD || c == State::PH || c == State::WA || c == State::WD) {
theDisplay[row][col] = 'P';
}
if (c == State::Normal || c == State::Horde || c == State::Mhorde || c == State::Dhorde) {
theDisplay[row][col] = 'G';
}
if (c == State::BS) {
theDisplay[row][col] = 'B';
}
if (c == State::Stair) {
theDisplay[row][col] = '\\';
}
if (c == State::Door ) {
theDisplay[row][col] = '+';
}
if(c == State::HWall) {
theDisplay[row][col] = '-';
}
if (c == State::VWall) {
theDisplay[row][col] = '|';
}
if(c == State::Hallway) {
theDisplay[row][col] = '#';
}
if(c == State::Empty) {
theDisplay[row][col] = '.';
}
if(c == State::None) {
theDisplay[row][col] = ' ';
}
if(c == State::Compass) {
theDisplay[row][col] = 'C';
}
}
std::ostream& operator<<(std::ostream& out, const TextDisplay& td) {
for (int i = 0; i < td.r; ++i) {
for (int j = 0; j < td.c; ++j) {
out << td.theDisplay[i][j];
}
out << std::endl;
}
return out;
}