This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (64 loc) · 2.28 KB
/
Copy pathmain.cpp
File metadata and controls
85 lines (64 loc) · 2.28 KB
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
#include <iostream>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <queue>
#include "Colonist.h"
#include <fstream>
#include <iterator>
#include <string>
#include <unistd.h>
using namespace std;
int main(int argc, char* argv[])
{
int n = atoi(argv[1]);
int d = 1;
int Air = 100;
int Food = 100;
int Water = 100;
int Base_HP = 100;
Colonist *colonists = new Colonist[n];
colonists[0].occupation("Maintenance worker");
colonists[1].occupation("Hydroponics caretaker");
colonists[2].occupation("Envivorment control operator");
cout << "# Generated Colonists : " << endl;
for (int i = 0; i < n; ++i)
{
cout << colonists[i].description() << endl;
}
while(1)
{
cout << " ############################ " << "Day : " << d << " ############################### " << endl;
cout << endl << " Air : " << Air << " Water: " << Water << " Food: " << Food << " HP : "<< Base_HP << endl;
for(int i = 0 ; i < n ; i++)
{
if(colonists[i].hunger() < 40) Food -= colonists[i].Eat();
else if(colonists[i].energy() < 50 ) colonists[i].Sleep();
else if(colonists[i].occupation() == "Hydroponics caretaker" ) Food += colonists[i].Work();
else if(colonists[i].occupation() == "Maintenance worker" && Base_HP < 90 ) Base_HP += colonists[i].Work();
else if(colonists[i].occupation() == "Envivorment control operator" )
{
int temp =colonists[i].Work();
Air += temp;
Water += temp;
}
}
Air -= 16;
Water -= 15;
Base_HP -= 10;
cout << endl << " ###################################################################################### " << endl;
cout << endl << " Air : " << Air << " Water: " << Water << " Food: " << Food << " HP : "<< Base_HP << endl;
if( Air <= 0 || Water <= 0 || Food <= 0 || Base_HP <= 0)
{
cout << "Colonists didn't make it...";
if(Air <= 0) cout << " We've ran out of Air ";
else if(Water <= 0) cout << "We've ran out of Water ";
else if(Food <= 0) cout << "We've ran out of Food " ;
else if(Base_HP <= 0) cout << "Our base has fallen apart due to Maintenance workers' laziness... " << endl;
exit(0);
}
sleep(1);
d += 1;
}
delete [] colonists;
}