This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.cpp
89 lines (76 loc) · 2.15 KB
/
util.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
#include <algorithm>
#include <chrono> // std::chrono::microseconds
#include <cstdlib>
#include <iostream>
#include <string>
#include <thread> // std::this_thread::sleep_for;
#include "main.hpp"
std::string RoomToString(int RoomId) {
std::string roomStrings[] = {"KSI",
"KORYTARZ",
"SERWEROWNIA",
"WC",
"WINDA (PIĘTRO)",
"WINDA (PARTER)",
"WINDA (TYLNA)",
"GARAŻ",
"ZEWNĄTRZ",
"BIBLIOTEKA",
"SEKRETARIAT",
"FAIL"};
return roomStrings[RoomId];
}
Room fail(GameData& gameData) {
std::cout << "Ten pokój nie istnieje. Spadłeś w pustkę. Elo." << std::endl;
gameData.alive = false;
return ZEWNATRZ;
}
std::string lowercase(std::string str) {
std::string result = str;
std::transform(str.begin(), str.end(), result.begin(), ::tolower);
return result;
}
void wait_s(unsigned int secs) { // wstrzymuje wątek na secs sekund
std::cout.flush(); // może tu być? del comment jeśli tak
std::this_thread::sleep_for(std::chrono::seconds(secs));
}
void wait_ms(unsigned int millisecs) { // wstrzymuje wątek
std::cout.flush(); // na millisecs milisekund
std::this_thread::sleep_for(std::chrono::milliseconds(millisecs));
}
void print_text(std::string text) {
for (char i : text) {
std::cout << i;
wait_ms(20);
}
std::cout << std::endl;
}
int choice(int n) {
int response;
std::cout << "> ";
std::cin >> response;
std::cout << std::endl;
if (std::cin.good()) {
if (response > 0 && response <= n) {
return response;
}
return 0;
}
std::cin.clear();
std::cin.sync();
return 0;
}
bool yes(const std::string& s) {
std::cout << "> ";
std::string response;
std::cin >> response;
return strchr(s.c_str(), response[0]) != nullptr;
}
void clear_screen() {
#ifdef _WIN32
std::system("cls");
#endif
#ifdef unix
std::cout << "\033[2J";
#endif
}