-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
122 lines (115 loc) · 3.94 KB
/
main.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
115
116
117
118
119
120
121
#include <vector>
#include <string>
#include <ncurses.h>
#include "game.h"
int main(int argc, char *argv[]) {
initscr(); // Ncurses initializations
clear(); // clear screen
noecho(); // suppress the automatic echoing of typed characters
cbreak(); // disable the buffering of typed characters
keypad(stdscr, TRUE); // to capture special keystrokes like arrow keys
curs_set(0);
std::unique_ptr<Game> g;
char cmd;
mvprintw(0, 0, "%s", "Welcome to the game of Chamber Crawler 3000+!");
mvprintw(1, 0, "%s", "To start, please select your character:");
mvprintw(2, 0, "%s", "h: Human 140 HP, 20 Atk, 20 Def, +50% score");
mvprintw(3, 0, "%s", "e: Elves 140 HP, 30 Atk, 10 Def, negative potions have positive effect");
mvprintw(4, 0, "%s", "d: Dwarf 100 HP, 20 Atk, 30 Def, gold is doubled in value");
mvprintw(5, 0, "%s", "o: Orc 180 HP, 30 Atk, 25 Def, gold is worth half value");
while(1) {
cmd = getch();
if(cmd == 'h' || cmd == 'e' || cmd == 'd' || cmd == 'o') {
if(argc > 1) { // optional command line argument that speficies the layout
if (std::string(argv[1]) == "-layout") {
g = std::make_unique<Game>(cmd, true, argv[2]);
} else if (std::string(argv[1]) == "-map" ){
g = std::make_unique<Game>(cmd, argv[2]);
}
} else {
g = std::make_unique<Game>(cmd);
}
break;
} else if (cmd == 'q'){
clear();
endwin();
return 0;
} else {
mvprintw(6, 0, "%s", "Invalid! Please reselect your character.");
}
}
while(1){
int state = g->takeCommand();
if (state == 5) {
clear();
mvprintw(0, 0, "%s", "To restart, please select your character:");
mvprintw(1, 0, "%s", "h: Human 140 HP, 20 Atk, 20 Def, +50% score");
mvprintw(2, 0, "%s", "e: Elves 140 HP, 30 Atk, 10 Def, negative potions have positive effect");
mvprintw(3, 0, "%s", "d: Dwarf 100 HP, 20 Atk, 30 Def, gold is doubled in value");
mvprintw(4, 0, "%s", "o: Orc 180 HP, 30 Atk, 25 Def, gold is worth half value");
while(1) {
cmd = getch();
if (cmd == 'h' || cmd == 'e' || cmd == 'd' || cmd == 'o') {
if(argc > 1) { // optional command line argument that speficies the layout
if (std::string(argv[1]) == "-layout") {
g = std::make_unique<Game>(cmd, true, argv[2]);
} else if (std::string(argv[1]) == "-map" ){
g = std::make_unique<Game>(cmd, argv[2]);
}
} else {
g = std::make_unique<Game>(cmd);
}
break;
} else if (cmd == 'q'){
clear();
endwin();
return 0;
} else {
mvprintw(5, 0, "%s", "Invalid! Please reselect your character.");
}
}
continue;
} else if (state == 4) {
clear();
endwin();
break;
} else if (state == 1) {
mvprintw(3, 0, "%s", "Do you want to start again? [y/n]");
cmd = getch();
if (cmd == 'Y' || cmd == 'y') {
clear();
mvprintw(0, 0, "%s", "To restart, please select your character:");
mvprintw(1, 0, "%s", "h: Human 140 HP, 20 Atk, 20 Def, +50% score");
mvprintw(2, 0, "%s", "e: Elves 140 HP, 30 Atk, 10 Def, negative potions have positive effect");
mvprintw(3, 0, "%s", "d: Dwarf 100 HP, 20 Atk, 30 Def, gold is doubled in value");
mvprintw(4, 0, "%s", "o: Orc 180 HP, 30 Atk, 25 Def, gold is worth half value");
while(1) {
cmd = getch();
if (cmd == 'h' || cmd == 'e' || cmd == 'd' || cmd == 'o') {
if(argc > 1) { // optional command line argument that speficies the layout
if (std::string(argv[1]) == "-layout") {
g = std::make_unique<Game>(cmd, true, argv[2]);
} else if (std::string(argv[1]) == "-map" ){
g = std::make_unique<Game>(cmd, argv[2]);
}
} else {
g = std::make_unique<Game>(cmd);
}
break;
} else if (cmd == 'q'){
clear();
endwin();
return 0;
} else {
mvprintw(5, 0, "%s", "Invalid! Please reselect your character.");
}
}
continue;
}
else if (cmd == 'N' || cmd == 'n' || cmd == 'q') break;
}
}
clear();
endwin();
return 0;
}