-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandReader.cpp
194 lines (171 loc) · 4.38 KB
/
CommandReader.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
#include "CommandReader.h"
#include <iostream>
#include <SFML/Graphics.hpp>
CommandReader::CommandReader() {
this->width = 10;
this->step = NOTHING;
this->info = nullptr;
this->height = 10;
this->difficulty = EASY;
new ErrorObserver(this);
this->input_commands = new FileInput("assigments.txt");
input_commands->SetCommands();
}
void CommandReader::SetSize() {
std::cout << "Do you want to set a field size?\n";
std::cout << "Y - Yes\n";
std::cout << "N - No\n";
char res;
std::cin >> res;
if (res != 'Y' and res != 'y') {
this->width = 10;
this->height = 10;
return;
}
InputHeight();
InputWidth();
}
//void CommandReader::SetDifficulty() {
// std::cout << "Choose game difficalty?\n";
// std::cout << "Easy - 1\n";
// std::cout << "Hard - 2\n";
// char res;
// std::cin >> res;
// if (res == 1) {
// this->difficulty = EASY;
// return;
// }
// else if (res == 2) {
// this->difficulty = HARD;
// return;
// }
// else this->difficulty = EASY;
//}
void CommandReader::InputHeight() {
std::cout << "Input field's height: ";
std::cin >> height;
if (height <= 0) {
Message message(ERROR, "incorrect height input", this->info);
Notify(message);
std::cout << "Incorrect height. Try again: ";
InputHeight();
}
}
void CommandReader::InputWidth() {
std::cout << "Input field's width: ";
std::cin >> width;
if (width <= 0) {
Message message(ERROR, "incorrect width input", this->info);
Notify(message);
std::cout << "Incorrect width. Try again: ";
InputWidth();
}
}
//void CommandReader::InputStep(sf::RenderWindow* window) {
// //std::cout << "Tap on move buttons" << std::endl;
// window->pollEvent(step);
//}
int CommandReader::GetHeight() {
return height;
}
int CommandReader::GetWidth() {
return width;
}
//sf::Event CommandReader::GetStep() {
// return step;
//}
ASSIGMENTS CommandReader::GetStep() {
return step;
}
void CommandReader::SetOutput() {
char res;
std::cout << "Input output way: \n";
std::cout << "1: File\n";
std::cout << "2: CMD\n";
std::cout << "3: Both\n";
std::cin >> res;
switch (res) {
case '1':
this->outputs.push_back(OUTPUT::FILEOUT);
break;
case '2':
this->outputs.push_back(OUTPUT::CMD);
break;
case '3':
this->outputs.push_back(OUTPUT::FILEOUT);
this->outputs.push_back(OUTPUT::CMD);
break;
default:
this->outputs.push_back(OUTPUT::FILEOUT);
this->outputs.push_back(OUTPUT::CMD);
break;
}
}
void CommandReader::SetLevels() {
char res;
std::cout << "Input logging leveles: \n";
std::cout << "1: Game\n";
std::cout << "2: Status\n";
std::cout << "3: Errors\n";
std::cout << "4: All\n";
std::cin >> res;
switch (res) {
case '1':
this->levels.push_back(LEVEL::GAME);
break;
case '2':
this->levels.push_back(LEVEL::STATUS);
break;
case '3':
this->levels.push_back(LEVEL::ERROR);
break;
case '4':
this->levels.push_back(LEVEL::GAME);
this->levels.push_back(LEVEL::STATUS);
this->levels.push_back(LEVEL::ERROR);
break;
default:
this->levels.push_back(LEVEL::GAME);
this->levels.push_back(LEVEL::STATUS);
this->levels.push_back(LEVEL::ERROR);
break;
}
}
std::vector <OUTPUT> CommandReader::GetOutputs() {
return this->outputs;
}
std::vector <LEVEL> CommandReader::GetLevels() {
return this->levels;
}
void CommandReader::SetDifficulty() {
char res;
std::cout << "Set difficulty: \n";
std::cout << "1: easy\n";
std::cout << "2: hard\n";
std::cin >> res;
switch (res) {
case '1':
this->difficulty = EASY;
break;
case '2':
this->difficulty = HARD;
break;
default:
this->difficulty = EASY;
break;
}
}
DIFFICULTY CommandReader::GetDifficulty() {
return this->difficulty;
}
//bool CommandReader::GetContinue() {
// std::cout << "Do you want to load last save and continue?" << std::endl;
// std::cout << "Y - Yes\n";
// std::cout << "N - No\n";
// char res;
// std::cin >> res;
// if (res != 'Y' and res != 'y')
// return false;
// else
// return true;
//}