@shipload/sdk 2.0.0-rc10 → 2.0.0-rc12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ export type task = ServerContract.Types.task
21
21
  export type cargo_item = ServerContract.Types.cargo_item
22
22
  export type warehouse_row = ServerContract.Types.warehouse_row
23
23
  export type container_row = ServerContract.Types.container_row
24
- export type extractor_stats = ServerContract.Types.extractor_stats
24
+ export type gatherer_stats = ServerContract.Types.gatherer_stats
25
25
 
26
26
  export type location_static = ServerContract.Types.location_static
27
27
  export type location_epoch = ServerContract.Types.location_epoch
@@ -50,7 +50,8 @@ export {
50
50
  getSystemName,
51
51
  hasSystem,
52
52
  getLocationType,
53
- isExtractableLocation,
53
+ getLocationTypeName,
54
+ isGatherableLocation,
54
55
  deriveLocationStatic,
55
56
  deriveLocationEpoch,
56
57
  deriveLocation,
@@ -65,7 +66,6 @@ export {
65
66
  getLocationCandidates,
66
67
  getDepthThreshold,
67
68
  getResourceTier,
68
- depthScaleFactor,
69
69
  DEPTH_THRESHOLD_T1,
70
70
  DEPTH_THRESHOLD_T2,
71
71
  DEPTH_THRESHOLD_T3,
@@ -83,6 +83,9 @@ export {
83
83
 
84
84
  export type {StratumInfo, ResourceStats} from './derivation'
85
85
 
86
+ export {RESERVE_TIERS, TIER_ROLL_MAX, rollTier, rollWithinTier} from './derivation'
87
+ export type {ReserveTier, TierRange} from './derivation'
88
+
86
89
  export {getStatDefinitions, getStatName, resolveStats} from './derivation'
87
90
  export type {StatDefinition, NamedStats} from './derivation'
88
91
 
@@ -134,7 +137,12 @@ export type {HasCargo} from './entities/inventory-accessor'
134
137
  export * as cargoUtils from './entities/cargo-utils'
135
138
  export type {CargoData} from './entities/cargo-utils'
136
139
 
137
- export {projectEntity, projectEntityAt, createProjectedEntity} from './scheduling/projection'
140
+ export {
141
+ createProjectedEntity,
142
+ projectEntity,
143
+ projectEntityAt,
144
+ validateSchedule,
145
+ } from './scheduling/projection'
138
146
  export type {Projectable, ProjectedEntity} from './scheduling/projection'
139
147
 
140
148
  export * from './types/capabilities'
@@ -192,12 +200,12 @@ export {
192
200
  ITEM_GENERATOR_T1,
193
201
  ITEM_SHIP_T1_PACKED,
194
202
  ITEM_WAREHOUSE_T1_PACKED,
195
- ITEM_DRILL_SHAFT,
196
- ITEM_EXTRACTION_PROBE,
203
+ ITEM_MATTER_CONDUIT,
204
+ ITEM_SURVEY_PROBE,
197
205
  ITEM_CARGO_ARM,
198
206
  ITEM_TOOL_BIT,
199
207
  ITEM_REACTION_CHAMBER,
200
- ITEM_EXTRACTOR_T1,
208
+ ITEM_GATHERER_T1,
201
209
  ITEM_LOADER_T1,
202
210
  ITEM_MANUFACTURING_T1,
203
211
  ITEM_STORAGE_T1,
@@ -229,8 +237,9 @@ export {
229
237
  blendCrossGroup,
230
238
  categoryItemMass,
231
239
  computeInputMass,
240
+ computeCraftedOutputSeed,
232
241
  } from './derivation/crafting'
233
- export type {StackInput, CategoryStacks} from './derivation/crafting'
242
+ export type {StackInput, CategoryStacks, RecipeSlotInput} from './derivation/crafting'
234
243
 
235
244
  export {computeContainerCapabilities, computeContainerT2Capabilities} from './entities/container'
236
245
 
@@ -238,7 +247,7 @@ export {
238
247
  computeShipHullCapabilities,
239
248
  computeEngineCapabilities,
240
249
  computeGeneratorCapabilities,
241
- computeExtractorCapabilities,
250
+ computeGathererCapabilities,
242
251
  computeHaulerCapabilities,
243
252
  computeLoaderCapabilities,
244
253
  computeManufacturingCapabilities,
@@ -285,10 +294,10 @@ export {
285
294
  computeEngineDrain,
286
295
  computeGeneratorCap,
287
296
  computeGeneratorRech,
288
- computeExtractorRate,
289
- computeExtractorDrain,
290
- computeExtractorDepth,
291
- computeExtractorDrill,
297
+ computeGathererYield,
298
+ computeGathererDrain,
299
+ computeGathererDepth,
300
+ computeGathererSpeed,
292
301
  computeLoaderMass,
293
302
  computeLoaderThrust,
294
303
  computeCrafterSpeed,
@@ -97,9 +97,12 @@ export class ActionsManager extends BaseManager {
97
97
  })
98
98
  }
99
99
 
100
- extract(shipId: UInt64Type): Action {
101
- return this.server.action('extract', {
102
- ship_id: UInt64.from(shipId),
100
+ gather(shipId: UInt64Type, stratum: number, quantity: number): Action {
101
+ return this.server.action('gather', {
102
+ entity_type: EntityType.SHIP,
103
+ id: UInt64.from(shipId),
104
+ stratum: UInt16.from(stratum),
105
+ quantity: UInt32.from(quantity),
103
106
  })
104
107
  }
105
108
 
@@ -1,9 +1,14 @@
1
1
  import {UInt16, UInt16Type} from '@wharfkit/antelope'
2
2
  import {Item} from '../types'
3
3
  import itemsData from '../data/items.json'
4
+ import {computeInputMass} from '../derivation/crafting'
5
+ import {getComponentById, getEntityRecipeByItemId, getModuleRecipeByItemId} from '../data/recipes'
4
6
 
5
- const items: Item[] = itemsData.map((g) =>
6
- Item.from({
7
+ const itemsById: Map<number, Item> = new Map()
8
+ const synthesizedCache: Map<number, Item> = new Map()
9
+
10
+ for (const g of itemsData) {
11
+ const item = Item.from({
7
12
  id: g.id,
8
13
  name: g.name,
9
14
  description: g.description,
@@ -12,19 +17,73 @@ const items: Item[] = itemsData.map((g) =>
12
17
  tier: g.tier,
13
18
  color: g.color,
14
19
  })
15
- )
20
+ itemsById.set(item.id.toNumber(), item)
21
+ }
22
+
23
+ export const itemIds = Array.from(itemsById.values(), (i) => i.id)
24
+
25
+ interface RecipeSource {
26
+ name: string
27
+ description: string
28
+ mass: number
29
+ color: string
30
+ }
31
+
32
+ function synthesizeItem(id: number, source: RecipeSource): Item {
33
+ return Item.from({
34
+ id,
35
+ name: source.name,
36
+ description: source.description,
37
+ mass: source.mass,
38
+ category: 'metal',
39
+ tier: 't1',
40
+ color: source.color,
41
+ })
42
+ }
43
+
44
+ function synthesizeFromRecipes(id: number): Item | undefined {
45
+ const component = getComponentById(id)
46
+ if (component) return synthesizeItem(id, component)
16
47
 
17
- export const itemIds = items.map((i) => i.id)
48
+ const entityRecipe = getEntityRecipeByItemId(id)
49
+ if (entityRecipe) {
50
+ return synthesizeItem(id, {
51
+ ...entityRecipe,
52
+ mass: computeInputMass(entityRecipe.id, 'entity'),
53
+ })
54
+ }
55
+
56
+ const moduleRecipe = getModuleRecipeByItemId(id)
57
+ if (moduleRecipe) {
58
+ return synthesizeItem(id, {
59
+ ...moduleRecipe,
60
+ mass: computeInputMass(moduleRecipe.id, 'module'),
61
+ })
62
+ }
63
+
64
+ return undefined
65
+ }
18
66
 
19
67
  export function getItem(itemId: UInt16Type): Item {
20
- const id = UInt16.from(itemId)
21
- const item = items.find((i) => i.id.equals(id))
22
- if (!item) {
23
- throw new Error(`Item with id ${id} not found`)
68
+ const id = UInt16.from(itemId).toNumber()
69
+ const existing = itemsById.get(id) ?? synthesizedCache.get(id)
70
+ if (existing) return existing
71
+
72
+ const synthesized = synthesizeFromRecipes(id)
73
+ if (synthesized) {
74
+ synthesizedCache.set(id, synthesized)
75
+ return synthesized
24
76
  }
25
- return item
77
+
78
+ throw new Error(`Item with id ${id} not found`)
26
79
  }
27
80
 
28
81
  export function getItems(): Item[] {
29
- return items
82
+ return Array.from(itemsById.values())
83
+ }
84
+
85
+ export function registerItem(item: Item): void {
86
+ const id = item.id.toNumber()
87
+ itemsById.set(id, item)
88
+ synthesizedCache.delete(id)
30
89
  }
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  getModuleCapabilityType,
3
3
  ITEM_ENGINE_T1,
4
- ITEM_EXTRACTOR_T1,
4
+ ITEM_GATHERER_T1,
5
5
  ITEM_GENERATOR_T1,
6
6
  ITEM_LOADER_T1,
7
7
  ITEM_MANUFACTURING_T1,
8
8
  ITEM_STORAGE_T1,
9
9
  MODULE_CRAFTER,
10
10
  MODULE_ENGINE,
11
- MODULE_EXTRACTOR,
11
+ MODULE_GATHERER,
12
12
  MODULE_GENERATOR,
13
13
  MODULE_LOADER,
14
14
  MODULE_STORAGE,
@@ -44,10 +44,10 @@ export const computeEngineThrust = (vol: number): number => 400 + idiv(vol * 3,
44
44
  export const computeEngineDrain = (thm: number): number => Math.max(30, 50 - idiv(thm, 70))
45
45
  export const computeGeneratorCap = (res: number): number => 300 + idiv(res, 6)
46
46
  export const computeGeneratorRech = (clr: number): number => 5 + idiv(clr * 15, 1000)
47
- export const computeExtractorRate = (str: number): number => 200 + str
48
- export const computeExtractorDrain = (con: number): number => Math.max(10, 50 - idiv(con, 20))
49
- export const computeExtractorDepth = (tol: number): number => 200 + idiv(tol * 3, 2)
50
- export const computeExtractorDrill = (ref: number): number => 100 + idiv(ref * 4, 5)
47
+ export const computeGathererYield = (str: number): number => 200 + str
48
+ export const computeGathererDrain = (con: number): number => Math.max(10, 50 - idiv(con, 20))
49
+ export const computeGathererDepth = (tol: number): number => 200 + idiv(tol * 3, 2)
50
+ export const computeGathererSpeed = (ref: number): number => 100 + idiv(ref * 4, 5)
51
51
  export const computeLoaderMass = (duc: number): number => Math.max(200, 2000 - duc * 2)
52
52
  export const computeLoaderThrust = (pla: number): number => 1 + idiv(pla, 500)
53
53
  export const computeCrafterSpeed = (rea: number): number => 100 + idiv(rea * 4, 5)
@@ -74,8 +74,8 @@ export function moduleDisplayName(itemId: number): string {
74
74
  return 'Engine T1'
75
75
  case ITEM_GENERATOR_T1:
76
76
  return 'Generator T1'
77
- case ITEM_EXTRACTOR_T1:
78
- return 'Extractor T1'
77
+ case ITEM_GATHERER_T1:
78
+ return 'Gatherer T1'
79
79
  case ITEM_LOADER_T1:
80
80
  return 'Loader T1'
81
81
  case ITEM_MANUFACTURING_T1:
@@ -110,14 +110,14 @@ export function formatModuleLine(slot: number, itemId: number, seed: bigint): st
110
110
  out += ` Capacity ${computeGeneratorCap(res)} Recharge ${computeGeneratorRech(clr)}`
111
111
  break
112
112
  }
113
- case MODULE_EXTRACTOR: {
113
+ case MODULE_GATHERER: {
114
114
  const str = decodeStat(seed, 0)
115
115
  const tol = decodeStat(seed, 1)
116
116
  const con = decodeStat(seed, 3)
117
117
  const ref = decodeStat(seed, 4)
118
- out += ` Rate ${computeExtractorRate(str)} Depth ${computeExtractorDepth(
118
+ out += ` Yield ${computeGathererYield(str)} Depth ${computeGathererDepth(
119
119
  tol
120
- )} Drill ${computeExtractorDrill(ref)} Drain ${computeExtractorDrain(con)}`
120
+ )} Speed ${computeGathererSpeed(ref)} Drain ${computeGathererDrain(con)}`
121
121
  break
122
122
  }
123
123
  case MODULE_LOADER: {
@@ -8,7 +8,7 @@ import {
8
8
  isModuleItem,
9
9
  MODULE_CRAFTER,
10
10
  MODULE_ENGINE,
11
- MODULE_EXTRACTOR,
11
+ MODULE_GATHERER,
12
12
  MODULE_GENERATOR,
13
13
  MODULE_LOADER,
14
14
  MODULE_STORAGE,
@@ -18,7 +18,7 @@ import {deriveResourceStats} from '../derivation/stratum'
18
18
  import {getStatDefinitions} from '../derivation/stats'
19
19
  import {
20
20
  computeEngineCapabilities,
21
- computeExtractorCapabilities,
21
+ computeGathererCapabilities,
22
22
  computeGeneratorCapabilities,
23
23
  computeLoaderCapabilities,
24
24
  computeManufacturingCapabilities,
@@ -163,15 +163,15 @@ function computeCapabilityGroup(
163
163
  ],
164
164
  }
165
165
  }
166
- case MODULE_EXTRACTOR: {
167
- const caps = computeExtractorCapabilities(stats)
166
+ case MODULE_GATHERER: {
167
+ const caps = computeGathererCapabilities(stats)
168
168
  return {
169
- capability: 'Extractor',
169
+ capability: 'Gatherer',
170
170
  attributes: [
171
- {label: 'Rate', value: caps.rate},
171
+ {label: 'Yield', value: caps.yield},
172
172
  {label: 'Drain', value: caps.drain},
173
173
  {label: 'Depth', value: caps.depth},
174
- {label: 'Drill', value: caps.drill},
174
+ {label: 'Speed', value: caps.speed},
175
175
  ],
176
176
  }
177
177
  }
@@ -8,21 +8,30 @@ import {
8
8
  EntityCapabilities,
9
9
  EntityState,
10
10
  } from '../types/capabilities'
11
+ import {ENTITY_CAPACITY_EXCEEDED} from '../errors'
11
12
  import {distanceBetweenCoordinates, lerp} from '../travel/travel'
12
- import {calcCargoItemMass, calcCargoMass} from '../capabilities/storage'
13
+ import {
14
+ calcStacksMass,
15
+ cargoItemToStack,
16
+ CargoStack,
17
+ mergeStacks,
18
+ removeFromStacks,
19
+ stackToCargoItem,
20
+ } from '../capabilities/storage'
13
21
  import * as schedule from './schedule'
14
22
  import {ScheduleData} from './schedule'
15
23
 
16
24
  export interface ProjectedEntity {
17
25
  location: Coordinates
18
26
  energy: UInt16
19
- cargoMass: UInt64
27
+ cargo: CargoStack[]
20
28
  shipMass: UInt32
21
29
  capacity?: UInt64
22
30
  engines?: ServerContract.Types.movement_stats
23
31
  loaders?: ServerContract.Types.loader_stats
24
32
  generator?: ServerContract.Types.energy_stats
25
33
  hauler?: ServerContract.Types.hauler_stats
34
+ readonly cargoMass: UInt64
26
35
  readonly totalMass: UInt64
27
36
 
28
37
  hasMovement(): boolean
@@ -52,7 +61,6 @@ function getHullMass(entity: Projectable): UInt32 {
52
61
  }
53
62
 
54
63
  export function createProjectedEntity(entity: Projectable): ProjectedEntity {
55
- const cargoMass = calcCargoMass(entity)
56
64
  const shipMass = getHullMass(entity)
57
65
  const loaders = entity.loaders
58
66
  const engines = entity.engines
@@ -60,10 +68,12 @@ export function createProjectedEntity(entity: Projectable): ProjectedEntity {
60
68
  const hauler = entity.hauler
61
69
  const capacity = entity.capacity
62
70
 
71
+ const cargo: CargoStack[] = entity.cargo.map(cargoItemToStack)
72
+
63
73
  const projected: ProjectedEntity = {
64
74
  location: Coordinates.from(entity.coordinates),
65
75
  energy: UInt16.from(entity.energy ?? 0),
66
- cargoMass,
76
+ cargo,
67
77
  shipMass,
68
78
  capacity: capacity ? UInt64.from(capacity) : undefined,
69
79
  engines,
@@ -71,6 +81,10 @@ export function createProjectedEntity(entity: Projectable): ProjectedEntity {
71
81
  hauler,
72
82
  loaders,
73
83
 
84
+ get cargoMass() {
85
+ return calcStacksMass(this.cargo)
86
+ },
87
+
74
88
  get totalMass() {
75
89
  let mass = UInt64.from(this.shipMass).adding(this.cargoMass)
76
90
  if (this.loaders) {
@@ -107,7 +121,7 @@ export function createProjectedEntity(entity: Projectable): ProjectedEntity {
107
121
  location: ServerContract.Types.coordinates.from(this.location),
108
122
  energy: this.energy,
109
123
  cargomass: UInt32.from(this.cargoMass),
110
- cargo: entity.cargo,
124
+ cargo: this.cargo.map(stackToCargoItem),
111
125
  }
112
126
  },
113
127
  }
@@ -162,18 +176,23 @@ function applyFlightTask(
162
176
  }
163
177
  }
164
178
 
165
- function applyLoadTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
179
+ function addCargoItem(projected: ProjectedEntity, item: ServerContract.Types.cargo_item): void {
180
+ projected.cargo = mergeStacks(projected.cargo, cargoItemToStack(item))
181
+ }
182
+
183
+ function removeCargoItem(projected: ProjectedEntity, item: ServerContract.Types.cargo_item): void {
184
+ projected.cargo = removeFromStacks(projected.cargo, cargoItemToStack(item))
185
+ }
186
+
187
+ function applyAddCargoTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
166
188
  for (const item of task.cargo) {
167
- projected.cargoMass = projected.cargoMass.adding(calcCargoItemMass(item))
189
+ addCargoItem(projected, item)
168
190
  }
169
191
  }
170
192
 
171
- function applyUnloadTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
193
+ function applyRemoveCargoTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
172
194
  for (const item of task.cargo) {
173
- const cargoMass = calcCargoItemMass(item)
174
- projected.cargoMass = projected.cargoMass.gt(cargoMass)
175
- ? projected.cargoMass.subtracting(cargoMass)
176
- : UInt64.from(0)
195
+ removeCargoItem(projected, item)
177
196
  }
178
197
  }
179
198
 
@@ -185,81 +204,80 @@ function applyEnergyCost(projected: ProjectedEntity, task: ServerContract.Types.
185
204
  : UInt16.from(0)
186
205
  }
187
206
 
188
- function applyExtractTask(
207
+ function applyGatherTask(
189
208
  projected: ProjectedEntity,
190
209
  task: ServerContract.Types.task,
191
210
  options: {complete: boolean}
192
211
  ): void {
193
212
  if (!options.complete) return
194
-
195
213
  applyEnergyCost(projected, task)
196
-
197
- for (const item of task.cargo) {
198
- projected.cargoMass = projected.cargoMass.adding(calcCargoItemMass(item))
199
- }
214
+ applyAddCargoTask(projected, task)
200
215
  }
201
216
 
202
217
  function applyCraftTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
203
218
  applyEnergyCost(projected, task)
219
+ if (task.cargo.length === 0) return
204
220
 
205
- if (task.cargo.length > 0) {
206
- for (let i = 0; i < task.cargo.length - 1; i++) {
207
- const inputMass = calcCargoItemMass(task.cargo[i])
208
- projected.cargoMass = projected.cargoMass.gt(inputMass)
209
- ? projected.cargoMass.subtracting(inputMass)
210
- : UInt64.from(0)
211
- }
212
- const output = task.cargo[task.cargo.length - 1]
213
- projected.cargoMass = projected.cargoMass.adding(calcCargoItemMass(output))
221
+ for (let i = 0; i < task.cargo.length - 1; i++) {
222
+ removeCargoItem(projected, task.cargo[i])
214
223
  }
224
+ addCargoItem(projected, task.cargo[task.cargo.length - 1])
215
225
  }
216
226
 
217
227
  function applyDeployTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
218
228
  applyEnergyCost(projected, task)
219
-
220
229
  if (task.cargo.length > 0) {
221
- const mass = calcCargoItemMass(task.cargo[0])
222
- projected.cargoMass = projected.cargoMass.gt(mass)
223
- ? projected.cargoMass.subtracting(mass)
224
- : UInt64.from(0)
230
+ removeCargoItem(projected, task.cargo[0])
231
+ }
232
+ }
233
+
234
+ function applyTask(projected: ProjectedEntity, task: ServerContract.Types.task): void {
235
+ switch (task.type.toNumber()) {
236
+ case TaskType.RECHARGE:
237
+ applyRechargeTask(projected, task, {complete: true})
238
+ break
239
+ case TaskType.TRAVEL:
240
+ applyFlightTask(projected, task, {complete: true})
241
+ break
242
+ case TaskType.LOAD:
243
+ case TaskType.UNWRAP:
244
+ applyAddCargoTask(projected, task)
245
+ break
246
+ case TaskType.UNLOAD:
247
+ case TaskType.WRAP:
248
+ applyRemoveCargoTask(projected, task)
249
+ break
250
+ case TaskType.GATHER:
251
+ applyGatherTask(projected, task, {complete: true})
252
+ break
253
+ case TaskType.CRAFT:
254
+ applyCraftTask(projected, task)
255
+ break
256
+ case TaskType.DEPLOY:
257
+ applyDeployTask(projected, task)
258
+ break
225
259
  }
226
260
  }
227
261
 
228
262
  export function projectEntity(entity: Projectable): ProjectedEntity {
229
263
  const projected = createProjectedEntity(entity)
230
-
231
- if (!entity.schedule) {
232
- return projected
264
+ if (!entity.schedule || entity.schedule.tasks.length === 0) return projected
265
+ for (const task of entity.schedule.tasks) {
266
+ applyTask(projected, task)
233
267
  }
268
+ return projected
269
+ }
234
270
 
271
+ export function validateSchedule(entity: Projectable): void {
272
+ if (!entity.schedule || entity.schedule.tasks.length === 0) return
273
+
274
+ const projected = createProjectedEntity(entity)
235
275
  for (const task of entity.schedule.tasks) {
236
- switch (task.type.toNumber()) {
237
- case TaskType.RECHARGE:
238
- applyRechargeTask(projected, task, {complete: true})
239
- break
240
- case TaskType.TRAVEL:
241
- applyFlightTask(projected, task, {complete: true})
242
- break
243
- case TaskType.LOAD:
244
- applyLoadTask(projected, task)
245
- break
246
- case TaskType.UNLOAD:
247
- applyUnloadTask(projected, task)
248
- break
249
- case TaskType.EXTRACT:
250
- applyExtractTask(projected, task, {complete: true})
251
- break
252
- case TaskType.CRAFT:
253
- applyCraftTask(projected, task)
254
- break
255
- case TaskType.DEPLOY:
256
- case TaskType.DEPLOY_SHIP:
257
- applyDeployTask(projected, task)
258
- break
276
+ applyTask(projected, task)
277
+ if (projected.capacity && projected.cargoMass.gt(projected.capacity)) {
278
+ throw new Error(ENTITY_CAPACITY_EXCEEDED)
259
279
  }
260
280
  }
261
-
262
- return projected
263
281
  }
264
282
 
265
283
  export function projectEntityAt(entity: Projectable, now: Date): ProjectedEntity {
@@ -290,30 +308,21 @@ export function projectEntityAt(entity: Projectable, now: Date): ProjectedEntity
290
308
  applyFlightTask(projected, task, {complete: taskComplete, progress})
291
309
  break
292
310
  case TaskType.LOAD:
293
- if (taskComplete) {
294
- applyLoadTask(projected, task)
295
- }
311
+ case TaskType.UNWRAP:
312
+ if (taskComplete) applyAddCargoTask(projected, task)
296
313
  break
297
314
  case TaskType.UNLOAD:
298
- if (taskComplete) {
299
- applyUnloadTask(projected, task)
300
- }
315
+ case TaskType.WRAP:
316
+ if (taskComplete) applyRemoveCargoTask(projected, task)
301
317
  break
302
- case TaskType.EXTRACT:
303
- if (taskComplete) {
304
- applyExtractTask(projected, task, {complete: true})
305
- }
318
+ case TaskType.GATHER:
319
+ if (taskComplete) applyGatherTask(projected, task, {complete: true})
306
320
  break
307
321
  case TaskType.CRAFT:
308
- if (taskComplete) {
309
- applyCraftTask(projected, task)
310
- }
322
+ if (taskComplete) applyCraftTask(projected, task)
311
323
  break
312
324
  case TaskType.DEPLOY:
313
- case TaskType.DEPLOY_SHIP:
314
- if (taskComplete) {
315
- applyDeployTask(projected, task)
316
- }
325
+ if (taskComplete) applyDeployTask(projected, task)
317
326
  break
318
327
  }
319
328
  }
@@ -174,6 +174,6 @@ export function isUnloading(entity: ScheduleData, now: Date): boolean {
174
174
  return isTaskType(entity, TaskType.UNLOAD, now)
175
175
  }
176
176
 
177
- export function isExtracting(entity: ScheduleData, now: Date): boolean {
178
- return isTaskType(entity, TaskType.EXTRACT, now)
177
+ export function isGathering(entity: ScheduleData, now: Date): boolean {
178
+ return isTaskType(entity, TaskType.GATHER, now)
179
179
  }
@@ -20,8 +20,8 @@ export interface LoaderCapability {
20
20
  loaders: ServerContract.Types.loader_stats
21
21
  }
22
22
 
23
- export interface ExtractorCapability {
24
- extractor: ServerContract.Types.extractor_stats
23
+ export interface GathererCapability {
24
+ gatherer: ServerContract.Types.gatherer_stats
25
25
  }
26
26
 
27
27
  export interface MassCapability {
@@ -38,7 +38,7 @@ export interface EntityCapabilities {
38
38
  engines?: ServerContract.Types.movement_stats
39
39
  generator?: ServerContract.Types.energy_stats
40
40
  loaders?: ServerContract.Types.loader_stats
41
- extractor?: ServerContract.Types.extractor_stats
41
+ gatherer?: ServerContract.Types.gatherer_stats
42
42
  crafter?: ServerContract.Types.crafter_stats
43
43
  }
44
44
 
@@ -62,8 +62,8 @@ export function capsHasLoaders(caps: EntityCapabilities): boolean {
62
62
  return caps.loaders !== undefined
63
63
  }
64
64
 
65
- export function capsHasExtractor(caps: EntityCapabilities): boolean {
66
- return caps.extractor !== undefined
65
+ export function capsHasGatherer(caps: EntityCapabilities): boolean {
66
+ return caps.gatherer !== undefined
67
67
  }
68
68
 
69
69
  export function capsHasMass(caps: EntityCapabilities): boolean {
@@ -25,7 +25,7 @@ export type ShipEntity = Entity &
25
25
  Partial<LoaderCapability> &
26
26
  MassCapability &
27
27
  ScheduleCapability & {
28
- extractor?: ServerContract.Types.extractor_stats
28
+ gatherer?: ServerContract.Types.gatherer_stats
29
29
  }
30
30
 
31
31
  export type WarehouseEntity = Entity &
package/src/types.ts CHANGED
@@ -49,11 +49,12 @@ export enum TaskType {
49
49
  RECHARGE = 2,
50
50
  LOAD = 3,
51
51
  UNLOAD = 4,
52
- EXTRACT = 5,
52
+ GATHER = 5,
53
53
  WARP = 6,
54
54
  CRAFT = 7,
55
55
  DEPLOY = 8,
56
- DEPLOY_SHIP = 9,
56
+ WRAP = 9,
57
+ UNWRAP = 10,
57
58
  }
58
59
 
59
60
  export enum LocationType {
@@ -30,10 +30,23 @@ export function getLocationType(
30
30
  return LocationType.NEBULA
31
31
  }
32
32
 
33
- export function isExtractableLocation(locationType: LocationType): boolean {
33
+ export function isGatherableLocation(locationType: LocationType): boolean {
34
34
  return locationType !== LocationType.EMPTY
35
35
  }
36
36
 
37
+ export function getLocationTypeName(type: LocationType): string {
38
+ switch (type) {
39
+ case LocationType.EMPTY:
40
+ return 'Empty'
41
+ case LocationType.PLANET:
42
+ return 'Planet'
43
+ case LocationType.ASTEROID:
44
+ return 'Asteroid'
45
+ case LocationType.NEBULA:
46
+ return 'Nebula'
47
+ }
48
+ }
49
+
37
50
  function uint16(hash: Checksum512, offset: number): number {
38
51
  return (hash.array[offset] << 8) | hash.array[offset + 1]
39
52
  }