-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuilding.js
More file actions
297 lines (285 loc) · 10.8 KB
/
building.js
File metadata and controls
297 lines (285 loc) · 10.8 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
import Inventory from './inventory.js';
import Process from './process.js';
const IDS = {
EMPTY_LOT: 0,
WAREHOUSE: 1,
EXTRACTOR: 2,
REFINERY: 3,
BIOREACTOR: 4,
FACTORY: 5,
SHIPYARD: 6,
SPACEPORT: 7,
MARKETPLACE: 8,
HABITAT: 9,
TANK_FARM: 10
};
const CATEGORIES = {
STORAGE: 1,
EXTRACTION: 2,
REFINING: 3,
AGRICULTURE: 4,
MANUFACTURING: 5,
SHIPBUILDING: 6,
TRANSPORT: 7,
TRADE: 8,
HOUSING: 9
};
/**
* Constants
*/
const TYPES = {
[IDS.EMPTY_LOT]: {
i: IDS.EMPTY_LOT,
name: 'Empty Lot',
category: 0,
processType: 0,
siteSlot: 0,
siteType: 0,
description: `An empty expanse of regolith in microgravity, blasted by cosmic rays and
stellar wind and slowly tilled by micrometeorite impacts for billions of years.`
},
[IDS.WAREHOUSE]: {
i: IDS.WAREHOUSE,
name: 'Warehouse',
category: CATEGORIES.STORAGE,
processType: Process.IDS.WAREHOUSE_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.WAREHOUSE_SITE,
description: `The Warehouse provides inventory space to store products: raw
materials, refined materials, crops, manufactured goods, or assemblies.`
},
[IDS.EXTRACTOR]: {
i: IDS.EXTRACTOR,
name: 'Extractor',
category: CATEGORIES.EXTRACTION,
processType: Process.IDS.EXTRACTOR_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.EXTRACTOR_SITE,
description: `The Extractor is responsible for extracting raw materials from an
asteroid. Extractors cannot operate without a core sample pointing to a mineable
deposit of a raw material. They consist of a large, mobile drilling rig and a fixed
section that separates the ores and packages them for shipping. Extractors are best
operated by Miners.`
},
[IDS.REFINERY]: {
i: IDS.REFINERY,
name: 'Refinery',
category: CATEGORIES.REFINING,
processType: Process.IDS.REFINERY_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.REFINERY_SITE,
description: `The Refinery allows for the refining of products into refined
materials. Refineries utilize chemical reactions or state changes to
accomplish their work. They are built around a very large, thermally controlled
centrifuge which simulates gravity for the many processes that require it.
Refineries are best operated by Engineers and Scientists.`
},
[IDS.BIOREACTOR]: {
i: IDS.BIOREACTOR,
name: 'Bioreactor',
category: CATEGORIES.AGRICULTURE,
processType: Process.IDS.BIOREACTOR_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.BIOREACTOR_SITE,
description: `The Bioreactor, or as the Adalians lovingly call it, the Farm, is a
specialized building designed to provide a growing space for a variety of organic
products. Bioreactors feature transparent growing tunnels containing microgravity soil
beds for agricultural plants brought from Earth, as well as water tubes built into the
tunnel walls for bio-engineered algae and bacteria. Production of crops in
Bioreactors necessarily occurs in batches. They are best operated by Scientists.`
},
[IDS.FACTORY]: {
i: IDS.FACTORY,
name: 'Factory',
category: CATEGORIES.MANUFACTURING,
processType: Process.IDS.FACTORY_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.FACTORY_SITE,
description: `The Factory produces manufactured goods. It contains a number of flexible
assembly stations, through which mobile robotic arms move to perform work.
Factories are best operated by Engineers.`
},
[IDS.SHIPYARD]: {
i: IDS.SHIPYARD,
name: 'Shipyard',
category: CATEGORIES.SHIPBUILDING,
processType: Process.IDS.SHIPYARD_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.SHIPYARD_SITE,
description: `The Shipyard is a specialized type of factory that can manufacture
assemblies, the most specialized and complex type of products. These are typically used
in the construction of ships and buildings. Shipyards additionally feature large
mobile gantries which allow for the construction of ship hulls, and the final integration
of modules onto those hulls to create ships. Those two types of work can be performed
in parallel, unlike with other buildings. Shipyards are best operated by Engineers. `
},
[IDS.SPACEPORT]: {
i: IDS.SPACEPORT,
name: 'Spaceport',
category: CATEGORIES.TRANSPORT,
processType: Process.IDS.SPACEPORT_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.SPACEPORT_SITE,
description: `The Spaceport allows for the docking of all ship classes on an asteroid's
surface, not just those capable of performing all-terrain landings like
the Light Transport. Spaceports are constructed as a large well leading to underground
ship parking areas, and are therefore limited in space. The more ships they store,
the slower docking and undocking becomes. Ships docked in a Spaceport can load and unload
their cargoes and propellant, and can host Crews doing work.`
},
[IDS.MARKETPLACE]: {
i: IDS.MARKETPLACE,
name: 'Marketplace',
category: CATEGORIES.TRADE,
processType: Process.IDS.MARKETPLACE_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.MARKETPLACE_SITE,
description: `The Marketplace serves as the central point of the Adalian economy. Once
they are built on an asteroid they allow for the exchange of all local
raw materials, refined materials, crops, manufactured goods, and assemblies.
Marketplaces feature large spinning rings which provide artificial gravity for traders
who work there on a temporary basis, much like a conference center. They support both
limit and market orders, for both buying and selling, and allow a limited number of
products which may be traded, and which their owner can configure, along with fees.
When trades are matched, those fees accrue to the owner. Marketplaces are best managed
by Merchants.`
},
[IDS.HABITAT]: {
i: IDS.HABITAT,
name: 'Habitat',
category: CATEGORIES.HOUSING,
processType: Process.IDS.HABITAT_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.HABITAT_SITE,
description: `The Habitat is the city of Adalia. Habitats are constructed of large,
well-appointed spinning rings to provide artificial gravity, and the inner edge of
those rings is populated by many Habitation Modules, which are used for homes and public
buildings. In addition to allowing the stationing of Crews, they are the only location
which allows new Crewmates to be recruited, from the pool of work-ready young adults
who grew up at that Habitat. Habitats do not have unlimited space, and once they are more
than half full, the productivity boost which they grant to Crews stationed there begins
to drop due to overcrowding, until it is completely gone at full capacity.`
},
[IDS.TANK_FARM]: {
i: IDS.TANK_FARM,
name: 'Tank Farm',
category: CATEGORIES.STORAGE,
processType: Process.IDS.TANK_FARM_CONSTRUCTION,
siteSlot: 1,
siteType: Inventory.IDS.TANK_FARM_SITE,
description: `The Tank Farm provides inventory space to store bulky gases and liquids in large
tanks. It also provides some small storage space for select other solid products.`
}
};
const CATEGORY_TYPES = {
[CATEGORIES.STORAGE]: {
name: 'Storage',
},
[CATEGORIES.EXTRACTION]: {
name: 'Extraction',
},
[CATEGORIES.REFINING]: {
name: 'Refining',
},
[CATEGORIES.AGRICULTURE]: {
name: 'Agriculture',
},
[CATEGORIES.MANUFACTURING]: {
name: 'Manufacturing',
},
[CATEGORIES.SHIPBUILDING]: {
name: 'Shipbuilding',
},
[CATEGORIES.TRANSPORT]: {
name: 'Transport',
},
[CATEGORIES.TRADE]: {
name: 'Trade',
},
[CATEGORIES.HOUSING]: {
name: 'Housing',
},
}
// NOTE: constructionTime is in-game seconds
const CONSTRUCTION_TYPES = {
[IDS.WAREHOUSE]: {
constructionTime: Process.TYPES[Process.IDS.WAREHOUSE_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.WAREHOUSE_CONSTRUCTION].inputs
},
[IDS.EXTRACTOR]: {
constructionTime: Process.TYPES[Process.IDS.EXTRACTOR_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.EXTRACTOR_CONSTRUCTION].inputs
},
[IDS.REFINERY]: {
constructionTime: Process.TYPES[Process.IDS.REFINERY_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.REFINERY_CONSTRUCTION].inputs
},
[IDS.BIOREACTOR]: {
constructionTime: Process.TYPES[Process.IDS.BIOREACTOR_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.BIOREACTOR_CONSTRUCTION].inputs
},
[IDS.FACTORY]: {
constructionTime: Process.TYPES[Process.IDS.FACTORY_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.FACTORY_CONSTRUCTION].inputs
},
[IDS.SHIPYARD]: {
constructionTime: Process.TYPES[Process.IDS.SHIPYARD_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.SHIPYARD_CONSTRUCTION].inputs
},
[IDS.SPACEPORT]: {
constructionTime: Process.TYPES[Process.IDS.SPACEPORT_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.SPACEPORT_CONSTRUCTION].inputs
},
[IDS.MARKETPLACE]: {
constructionTime: Process.TYPES[Process.IDS.MARKETPLACE_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.MARKETPLACE_CONSTRUCTION].inputs
},
[IDS.HABITAT]: {
constructionTime: Process.TYPES[Process.IDS.HABITAT_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.HABITAT_CONSTRUCTION].inputs
},
[IDS.TANK_FARM]: {
constructionTime: Process.TYPES[Process.IDS.TANK_FARM_CONSTRUCTION].setupTime,
requirements: Process.TYPES[Process.IDS.TANK_FARM_CONSTRUCTION].inputs
}
};
const CONSTRUCTION_STATUSES = {
UNPLANNED: 0,
PLANNED: 1,
UNDER_CONSTRUCTION: 2,
OPERATIONAL: 3
};
const CONSTRUCTION_STATUS_LABELS = {
[CONSTRUCTION_STATUSES.UNPLANNED]: 'Unplanned',
[CONSTRUCTION_STATUSES.PLANNED]: 'Planned',
[CONSTRUCTION_STATUSES.UNDER_CONSTRUCTION]: 'Under Construction',
[CONSTRUCTION_STATUSES.OPERATIONAL]: 'Operational'
};
const DECONSTRUCTION_PENALTY = 0.10;
const getType = (type) => TYPES[type] ? { ...TYPES[type] } : null;
const getConstructionType = (type) => CONSTRUCTION_TYPES[type] ? { ...CONSTRUCTION_TYPES[type] } : null;
/**
* @param {integer} buildingType A constructable capable type
* @param {float} totalBonus The crew bonus to apply to the construction time
* @returns The construction time required in seconds
*/
const getConstructionTime = (buildingType, totalBonus = 1) => {
if (CONSTRUCTION_TYPES[buildingType]) {
return Math.ceil(CONSTRUCTION_TYPES[buildingType].constructionTime / totalBonus);
} else {
throw new Error('Building type is invalid or not constructable');
}
};
export default {
TYPES,
CATEGORIES,
CATEGORY_TYPES,
CONSTRUCTION_TYPES,
CONSTRUCTION_STATUSES,
CONSTRUCTION_STATUS_LABELS,
DECONSTRUCTION_PENALTY,
IDS,
getConstructionTime,
getConstructionType,
getType
};