-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
165 lines (136 loc) · 3.49 KB
/
main.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
#include "Company.h"
#include "MasterState.h"
#include <ncurses.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
using std::vector;
MasterState *masterState;
int main(int argc, char *argv[]) {
int row, col;
srand(time(NULL));
masterState = new MasterState();
masterState->addMessage("Congratulations!");
masterState->addMessage("You are the proud CEO of a brand new company!");
masterState->addMessage("You must make the best software (and the most money) using what you have been given.");
// Advance time by 10 days just so something interesting might happen.
masterState->advanceTime(10);
int moneyLeft = masterState->getPlayerCompany()->getMoney();
initscr();
int currentDay = -1;
while(true) {
erase();
getmaxyx(stdscr, row, col);
// TODO: Fix this so that it goes to the far right.
attron(A_STANDOUT);
mvprintw(0, 0, " Day: %d Money: %d", masterState->getTime(), moneyLeft);
for (int i = 27; i < col; ++i) {
printw(" ");
}
attroff(A_STANDOUT);
vector<char *> *messages = masterState->getMessages();
for (int i = 0; i < messages->size(); ++i) {
int thisRow = row - messages->size() - 2 + i;
mvprintw(thisRow, 1, (*messages)[i]);
}
// Three blank spaces between options.
move(2, col - 20);
attron(A_STANDOUT);
printw(" COMMANDS ");
attroff(A_STANDOUT);
move(3, col - 20);
attron(A_STANDOUT);
printw(" A ");
attroff(A_STANDOUT);
char message[20];
printw(" Applicants");
sprintf(message, "[%d]", masterState->getPlayerCompany()->getKnownPeople()->size());
move(3, col - strlen(message));
printw(message);
move(4, col - 20);
attron(A_STANDOUT);
printw(" I ");
attroff(A_STANDOUT);
printw(" Interview");
move(5, col - 20);
attron(A_STANDOUT);
printw(" H ");
attroff(A_STANDOUT);
printw(" Hire");
move(6, col - 20);
attron(A_STANDOUT);
printw(" E ");
attroff(A_STANDOUT);
printw(" *Employees");
sprintf(message, "[%d]", masterState->getPlayerCompany()->getEmployees()->size());
move(6, col - strlen(message));
printw(message);
move(7, col - 20);
attron(A_STANDOUT);
printw(" S ");
attroff(A_STANDOUT);
printw(" Status");
move(8, col - 20);
attron(A_STANDOUT);
printw(" T ");
attroff(A_STANDOUT);
printw(" *Teams");
move(9, col - 20);
attron(A_STANDOUT);
printw(" P ");
attroff(A_STANDOUT);
printw(" *Projects");
sprintf(message, "[%d]", masterState->getPlayerCompany()->getProjects()->size());
move(9, col - strlen(message));
printw(message);
move(10, col - 20);
attron(A_STANDOUT);
printw(" W ");
attroff(A_STANDOUT);
printw(" *Wait");
move(11, col - 20);
attron(A_STANDOUT);
printw(" Q ");
attroff(A_STANDOUT);
printw(" Quit");
refresh();
curs_set(0);
noecho();
int input = getch();
if (masterState->getTime() != currentDay) {
masterState->clearMessages();
currentDay = masterState->getTime();
}
switch(input) {
case 'a':
masterState->clearMessages();
masterState->executeCommand("applicants");
break;
case 'e':
masterState->clearMessages();
masterState->executeCommand("employees");
break;
case 'h':
masterState->executeCommand("hire");
break;
case 'i':
masterState->executeCommand("interview");
break;
case 'p':
masterState->executeCommand("project");
break;
case 's':
masterState->clearMessages();
masterState->executeCommand("status");
break;
case 'q':
endwin();
return 0;
default:
break;
}
}
endwin();
return 0;
}