-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.cpp
170 lines (137 loc) · 3.02 KB
/
System.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
#include <vector>
#include <string>
#include "System.h"
#include "MountPoint.h"
#include "Mecha.h"
#include "Accord_Combat_Playtest.cpp"
using namespace std;
System::System() {
name = "";
status = true;
efficacy = 100.0;
efficacy_cap = 200.0;
efficacy_cap_buffer = efficacy_cap;
power_expected = BASE_POWER_EXPECTED;
power_allocated = power_expected;
}System::System(string new_name) {
name = new_name;
status = true;
efficacy = 100.0;
efficacy_cap = 200.0;
efficacy_cap_buffer = efficacy_cap;
power_expected = BASE_POWER_EXPECTED;
power_allocated = power_expected;
}
System::System(string new_name, bool stat, float eff, float efc, int pex, int pal) {
name = new_name;
status = stat;
efficacy = eff;
efficacy_cap = efc;
efficacy_cap_buffer = efficacy_cap;
power_expected = pex;
power_allocated = pal;
}
string System::getName() {
return name;
}
void System::setName(string new_name) {
name = new_name;
}
bool System::getStatus() {
return status;
}
void System::setStatus(bool stat) {
status = stat;
}
float System::getEfficacy() {
return efficacy;
}
void System::setEfficacy(float eff) {
if (eff <= efficacy_cap) {
efficacy = eff;
}
else {
efficacy = efficacy_cap;
}
}
float System::getEfficacyCap() {
return efficacy_cap;
}
void System::setEfficacyCap(float efc) {
if (efc <= 200.0) {
efficacy_cap = efc;
}
else {
efficacy_cap = 200.0;
}
}
int System::getPowerExpected() {
return power_expected;
}
void System::setPowerExpected(int pex) {
power_expected = pex;
}
int System::getPowerAllocated() {
return power_allocated;
}
void System::setPowerAllocated(int pal) {
power_allocated = pal;
updateEfficacy();
}
vector<System*> System::getReliantSystems() {
return reliant_systems;
}
void System::addReliantSystem(System* rs) {
reliant_systems.push_back(rs);
}
vector<MountPoint*> System::getMountPoints() {
return mountpoints;
}
void System::addMountPoint(MountPoint* mnt) {
mountpoints.push_back(mnt);
mnt->addSystemUnreciprocated(this);
}
void System::addMountPointUnreciprocated(MountPoint* mnt) {
mountpoints.push_back(mnt);
}
void System::destroy() {
setStatus(false);
setEfficacyCap(0.0);
setPowerAllocated(0);
}
void System::disable() {
efficacy_cap_buffer = efficacy_cap;
setEfficacyCap(0.0);
setPowerAllocated(0);
}
void System::enable() {
setEfficacyCap(efficacy_cap_buffer);
}
void System::updateEfficacy() {
float power_ratio = power_allocated / power_expected;
efficacy = efficacy * power_ratio;
if (efficacy >= efficacy_cap) {
efficacy = efficacy_cap;
}
}
void System::updateEfficacyCap() {
int mnt_destroyed;
int mnt_total;
mnt_destroyed = 0;
mnt_total = mountpoints.size();
for (MountPoint* mnt : mountpoints) {
if (!mnt->getStatus()) {
mnt_destroyed++;
}
}
if (mnt_destroyed == mnt_total) {
destroy();
}
efficacy_cap = efficacy_cap - ((efficacy_cap / mnt_total) * mnt_destroyed);
float power_ratio;
power_ratio = power_allocated / power_expected;
if (power_ratio >= MAXIMUM_THRESHOLD) {
efficacy_cap = efficacy_cap - power_ratio;
}
updateEfficacy();
}