@shipload/sdk 2.0.0-rc10 → 2.0.0-rc11

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ITEM_ENGINE_T1,
3
- ITEM_EXTRACTOR_T1,
3
+ ITEM_GATHERER_T1,
4
4
  ITEM_GENERATOR_T1,
5
5
  ITEM_HAULER_T1,
6
6
  ITEM_LOADER_T1,
@@ -9,7 +9,7 @@ import {
9
9
  MODULE_ANY,
10
10
  MODULE_CRAFTER,
11
11
  MODULE_ENGINE,
12
- MODULE_EXTRACTOR,
12
+ MODULE_GATHERER,
13
13
  MODULE_GENERATOR,
14
14
  MODULE_HAULER,
15
15
  MODULE_LOADER,
@@ -20,15 +20,15 @@ import type {ResourceCategory} from '../types'
20
20
  export {
21
21
  ITEM_ENGINE_T1,
22
22
  ITEM_GENERATOR_T1,
23
- ITEM_EXTRACTOR_T1,
23
+ ITEM_GATHERER_T1,
24
24
  ITEM_LOADER_T1,
25
25
  ITEM_MANUFACTURING_T1,
26
26
  ITEM_STORAGE_T1,
27
27
  ITEM_HAULER_T1,
28
28
  }
29
29
 
30
- export const ITEM_DRILL_SHAFT = 10005
31
- export const ITEM_EXTRACTION_PROBE = 10006
30
+ export const ITEM_MATTER_CONDUIT = 10005
31
+ export const ITEM_SURVEY_PROBE = 10006
32
32
  export const ITEM_CARGO_ARM = 10007
33
33
  export const ITEM_TOOL_BIT = 10008
34
34
  export const ITEM_REACTION_CHAMBER = 10009
@@ -158,9 +158,9 @@ export const components: ComponentDefinition[] = [
158
158
  usedIn: [{type: 'module', name: 'Generator'}],
159
159
  },
160
160
  {
161
- id: ITEM_DRILL_SHAFT,
162
- name: 'Drill Shaft',
163
- description: 'Heavy-duty metal shaft used in extraction equipment.',
161
+ id: ITEM_MATTER_CONDUIT,
162
+ name: 'Matter Conduit',
163
+ description: 'Heavy-duty metal shaft used in gathering equipment.',
164
164
  color: '#7B8D9E',
165
165
  mass: 50000,
166
166
  stats: [
@@ -168,11 +168,11 @@ export const components: ComponentDefinition[] = [
168
168
  {key: 'tolerance', source: 'metal'},
169
169
  ],
170
170
  recipe: [{category: 'metal' as ResourceCategory, quantity: 15}],
171
- usedIn: [{type: 'module', name: 'Extractor'}],
171
+ usedIn: [{type: 'module', name: 'Gatherer'}],
172
172
  },
173
173
  {
174
- id: ITEM_EXTRACTION_PROBE,
175
- name: 'Extraction Probe',
174
+ id: ITEM_SURVEY_PROBE,
175
+ name: 'Survey Probe',
176
176
  description: 'Precious metal sensor array for deep resource detection.',
177
177
  color: '#D4A843',
178
178
  mass: 30000,
@@ -181,7 +181,7 @@ export const components: ComponentDefinition[] = [
181
181
  {key: 'reflectivity', source: 'precious'},
182
182
  ],
183
183
  recipe: [{category: 'precious' as ResourceCategory, quantity: 10}],
184
- usedIn: [{type: 'module', name: 'Extractor'}],
184
+ usedIn: [{type: 'module', name: 'Gatherer'}],
185
185
  },
186
186
  {
187
187
  id: ITEM_CARGO_ARM,
@@ -395,32 +395,32 @@ export const moduleRecipes: ModuleRecipe[] = [
395
395
  ],
396
396
  },
397
397
  {
398
- id: 'extractor-t1',
399
- name: 'Extractor',
400
- description: 'Basic extraction system. Drills and probes for raw resources.',
398
+ id: 'gatherer-t1',
399
+ name: 'Gatherer',
400
+ description: 'Basic gathering system. Probes and conduits for raw resources.',
401
401
  color: '#7B8D9E',
402
- itemId: ITEM_EXTRACTOR_T1,
403
- moduleType: MODULE_EXTRACTOR,
402
+ itemId: ITEM_GATHERER_T1,
403
+ moduleType: MODULE_GATHERER,
404
404
  recipe: [
405
- {itemId: ITEM_DRILL_SHAFT, quantity: 4},
406
- {itemId: ITEM_EXTRACTION_PROBE, quantity: 3},
405
+ {itemId: ITEM_MATTER_CONDUIT, quantity: 4},
406
+ {itemId: ITEM_SURVEY_PROBE, quantity: 3},
407
407
  ],
408
408
  stats: [
409
- {key: 'strength', sourceComponentId: ITEM_DRILL_SHAFT, sourceStatKey: 'strength'},
410
- {key: 'tolerance', sourceComponentId: ITEM_DRILL_SHAFT, sourceStatKey: 'tolerance'},
409
+ {key: 'strength', sourceComponentId: ITEM_MATTER_CONDUIT, sourceStatKey: 'strength'},
410
+ {key: 'tolerance', sourceComponentId: ITEM_MATTER_CONDUIT, sourceStatKey: 'tolerance'},
411
411
  {
412
412
  key: 'reflectivity',
413
- sourceComponentId: ITEM_EXTRACTION_PROBE,
413
+ sourceComponentId: ITEM_SURVEY_PROBE,
414
414
  sourceStatKey: 'reflectivity',
415
415
  },
416
416
  {
417
417
  key: 'conductivity',
418
- sourceComponentId: ITEM_EXTRACTION_PROBE,
418
+ sourceComponentId: ITEM_SURVEY_PROBE,
419
419
  sourceStatKey: 'conductivity',
420
420
  },
421
421
  {
422
- key: 'reflectivity_drill',
423
- sourceComponentId: ITEM_EXTRACTION_PROBE,
422
+ key: 'reflectivity_speed',
423
+ sourceComponentId: ITEM_SURVEY_PROBE,
424
424
  sourceStatKey: 'reflectivity',
425
425
  },
426
426
  ],
@@ -94,25 +94,31 @@ export function deriveStratum(
94
94
 
95
95
  export function deriveResourceStats(seed: bigint): ResourceStats {
96
96
  const seedBytes = new Uint8Array(8)
97
- for (let i = 7; i >= 0; i--) {
97
+ for (let i = 0; i < 8; i++) {
98
98
  seedBytes[i] = Number(seed & 0xffn)
99
99
  seed >>= 8n
100
100
  }
101
101
  const hashResult = Checksum256.hash(Bytes.from(seedBytes))
102
102
  const hashBytes = hashResult.array
103
103
 
104
- const extractU16 = (offset: number): number => (hashBytes[offset] << 8) | hashBytes[offset + 1]
104
+ const extractU32 = (offset: number): number =>
105
+ (hashBytes[offset] * 0x1000000 +
106
+ (hashBytes[offset + 1] << 16) +
107
+ (hashBytes[offset + 2] << 8) +
108
+ hashBytes[offset + 3]) >>> 0
105
109
 
106
110
  const weibull = (raw: number): number => {
107
- const u = raw / 65536
111
+ const u = raw / 4294967296
108
112
  let x = 0.27 * Math.sqrt(-Math.log(1 - u))
109
113
  if (x > 1) x = 1
110
- return Math.floor(x * 999) + 1
114
+ let val = Math.floor(x * 999) + 1
115
+ if (val > 999) val = 999
116
+ return val
111
117
  }
112
118
 
113
119
  return {
114
- stat1: weibull(extractU16(0)),
115
- stat2: weibull(extractU16(2)),
116
- stat3: weibull(extractU16(4)),
120
+ stat1: weibull(extractU32(0)),
121
+ stat2: weibull(extractU32(4)),
122
+ stat3: weibull(extractU32(8)),
117
123
  }
118
124
  }
@@ -1,6 +1,6 @@
1
1
  import {Checksum256, Checksum256Type, UInt16Type, UInt64} from '@wharfkit/antelope'
2
2
  import {Coordinates, CoordinatesType, Distance, LocationType} from '../types'
3
- import {getLocationType, hasSystem, isExtractableLocation} from '../utils/system'
3
+ import {getLocationType, hasSystem, isGatherableLocation} from '../utils/system'
4
4
  import {findNearbyPlanets} from '../travel/travel'
5
5
 
6
6
  export class Location {
@@ -30,8 +30,8 @@ export class Location {
30
30
  return getLocationType(gameSeed, this.coordinates)
31
31
  }
32
32
 
33
- isExtractableAt(gameSeed: Checksum256Type): boolean {
34
- return isExtractableLocation(this.getLocationTypeAt(gameSeed))
33
+ isGatherableAt(gameSeed: Checksum256Type): boolean {
34
+ return isGatherableLocation(this.getLocationTypeAt(gameSeed))
35
35
  }
36
36
 
37
37
  findNearby(gameSeed: Checksum256Type, maxDistance: UInt16Type = 20): Distance[] {
@@ -3,7 +3,7 @@ import {
3
3
  getModuleCapabilityType,
4
4
  MODULE_CRAFTER,
5
5
  MODULE_ENGINE,
6
- MODULE_EXTRACTOR,
6
+ MODULE_GATHERER,
7
7
  MODULE_GENERATOR,
8
8
  MODULE_HAULER,
9
9
  MODULE_LOADER,
@@ -52,11 +52,11 @@ export function computeGeneratorCapabilities(stats: Record<string, number>): {
52
52
  }
53
53
  }
54
54
 
55
- export function computeExtractorCapabilities(stats: Record<string, number>): {
56
- rate: number
55
+ export function computeGathererCapabilities(stats: Record<string, number>): {
56
+ yield: number
57
57
  drain: number
58
58
  depth: number
59
- drill: number
59
+ speed: number
60
60
  } {
61
61
  const str = stats.strength ?? 500
62
62
  const con = stats.conductivity ?? 500
@@ -64,10 +64,10 @@ export function computeExtractorCapabilities(stats: Record<string, number>): {
64
64
  const tol = stats.tolerance ?? 500
65
65
 
66
66
  return {
67
- rate: 200 + str,
67
+ yield: 200 + str,
68
68
  drain: Math.max(10, 50 - Math.floor(con / 20)),
69
69
  depth: 200 + Math.floor((tol * 3) / 2),
70
- drill: 100 + Math.floor((ref * 4) / 5),
70
+ speed: 100 + Math.floor((ref * 4) / 5),
71
71
  }
72
72
  }
73
73
 
@@ -153,7 +153,7 @@ export function computeWarehouseHullCapabilities(stats: Record<string, number>):
153
153
  export interface ShipCapabilities {
154
154
  engines?: {thrust: number; drain: number}
155
155
  generator?: {capacity: number; recharge: number}
156
- extractor?: {rate: number; drain: number; depth: number; drill: number}
156
+ gatherer?: {yield: number; drain: number; depth: number; speed: number}
157
157
  hauler?: {capacity: number; efficiency: number; drain: number}
158
158
  loaders?: {mass: number; thrust: number; quantity: number}
159
159
  crafter?: {speed: number; drain: number}
@@ -190,22 +190,22 @@ export function computeShipCapabilities(
190
190
  ship.generator = {capacity: totalCapacity, recharge: totalRecharge}
191
191
  }
192
192
 
193
- const extractorModules = modules.filter(
194
- (m) => getModuleCapabilityType(m.itemId) === MODULE_EXTRACTOR
193
+ const gathererModules = modules.filter(
194
+ (m) => getModuleCapabilityType(m.itemId) === MODULE_GATHERER
195
195
  )
196
- if (extractorModules.length > 0) {
197
- let totalRate = 0
196
+ if (gathererModules.length > 0) {
197
+ let totalYield = 0
198
198
  let totalDrain = 0
199
199
  let totalDepth = 0
200
- let totalDrill = 0
201
- for (const m of extractorModules) {
202
- const caps = computeExtractorCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
203
- totalRate += caps.rate
200
+ let totalSpeed = 0
201
+ for (const m of gathererModules) {
202
+ const caps = computeGathererCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
203
+ totalYield += caps.yield
204
204
  totalDrain += caps.drain
205
205
  totalDepth += caps.depth
206
- totalDrill += caps.drill
206
+ totalSpeed += caps.speed
207
207
  }
208
- ship.extractor = {rate: totalRate, drain: totalDrain, depth: totalDepth, drill: totalDrill}
208
+ ship.gatherer = {yield: totalYield, drain: totalDrain, depth: totalDepth, speed: totalSpeed}
209
209
  }
210
210
 
211
211
  const haulerModules = modules.filter((m) => getModuleCapabilityType(m.itemId) === MODULE_HAULER)
@@ -104,8 +104,8 @@ export class Ship extends ServerContract.Types.entity_info {
104
104
  return schedule.isUnloading(this, now)
105
105
  }
106
106
 
107
- isExtracting(now: Date): boolean {
108
- return schedule.isExtracting(this, now)
107
+ isGathering(now: Date): boolean {
108
+ return schedule.isGathering(this, now)
109
109
  }
110
110
 
111
111
  get hasEngines(): boolean {
@@ -116,8 +116,8 @@ export class Ship extends ServerContract.Types.entity_info {
116
116
  return this.generator !== undefined
117
117
  }
118
118
 
119
- get hasExtractor(): boolean {
120
- return this.extractor !== undefined
119
+ get hasGatherer(): boolean {
120
+ return this.gatherer !== undefined
121
121
  }
122
122
 
123
123
  get hasWarp(): boolean {
@@ -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,
@@ -192,12 +193,12 @@ export {
192
193
  ITEM_GENERATOR_T1,
193
194
  ITEM_SHIP_T1_PACKED,
194
195
  ITEM_WAREHOUSE_T1_PACKED,
195
- ITEM_DRILL_SHAFT,
196
- ITEM_EXTRACTION_PROBE,
196
+ ITEM_MATTER_CONDUIT,
197
+ ITEM_SURVEY_PROBE,
197
198
  ITEM_CARGO_ARM,
198
199
  ITEM_TOOL_BIT,
199
200
  ITEM_REACTION_CHAMBER,
200
- ITEM_EXTRACTOR_T1,
201
+ ITEM_GATHERER_T1,
201
202
  ITEM_LOADER_T1,
202
203
  ITEM_MANUFACTURING_T1,
203
204
  ITEM_STORAGE_T1,
@@ -238,7 +239,7 @@ export {
238
239
  computeShipHullCapabilities,
239
240
  computeEngineCapabilities,
240
241
  computeGeneratorCapabilities,
241
- computeExtractorCapabilities,
242
+ computeGathererCapabilities,
242
243
  computeHaulerCapabilities,
243
244
  computeLoaderCapabilities,
244
245
  computeManufacturingCapabilities,
@@ -285,10 +286,10 @@ export {
285
286
  computeEngineDrain,
286
287
  computeGeneratorCap,
287
288
  computeGeneratorRech,
288
- computeExtractorRate,
289
- computeExtractorDrain,
290
- computeExtractorDepth,
291
- computeExtractorDrill,
289
+ computeGathererYield,
290
+ computeGathererDrain,
291
+ computeGathererDepth,
292
+ computeGathererSpeed,
292
293
  computeLoaderMass,
293
294
  computeLoaderThrust,
294
295
  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,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
  }
@@ -185,7 +185,7 @@ function applyEnergyCost(projected: ProjectedEntity, task: ServerContract.Types.
185
185
  : UInt16.from(0)
186
186
  }
187
187
 
188
- function applyExtractTask(
188
+ function applyGatherTask(
189
189
  projected: ProjectedEntity,
190
190
  task: ServerContract.Types.task,
191
191
  options: {complete: boolean}
@@ -246,8 +246,8 @@ export function projectEntity(entity: Projectable): ProjectedEntity {
246
246
  case TaskType.UNLOAD:
247
247
  applyUnloadTask(projected, task)
248
248
  break
249
- case TaskType.EXTRACT:
250
- applyExtractTask(projected, task, {complete: true})
249
+ case TaskType.GATHER:
250
+ applyGatherTask(projected, task, {complete: true})
251
251
  break
252
252
  case TaskType.CRAFT:
253
253
  applyCraftTask(projected, task)
@@ -299,9 +299,9 @@ export function projectEntityAt(entity: Projectable, now: Date): ProjectedEntity
299
299
  applyUnloadTask(projected, task)
300
300
  }
301
301
  break
302
- case TaskType.EXTRACT:
302
+ case TaskType.GATHER:
303
303
  if (taskComplete) {
304
- applyExtractTask(projected, task, {complete: true})
304
+ applyGatherTask(projected, task, {complete: true})
305
305
  }
306
306
  break
307
307
  case TaskType.CRAFT:
@@ -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,7 +49,7 @@ 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,
@@ -30,10 +30,19 @@ 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: return 'Empty'
40
+ case LocationType.PLANET: return 'Planet'
41
+ case LocationType.ASTEROID: return 'Asteroid'
42
+ case LocationType.NEBULA: return 'Nebula'
43
+ }
44
+ }
45
+
37
46
  function uint16(hash: Checksum512, offset: number): number {
38
47
  return (hash.array[offset] << 8) | hash.array[offset + 1]
39
48
  }
@@ -1,36 +0,0 @@
1
- import {UInt16, UInt32} from '@wharfkit/antelope'
2
- import {ServerContract} from '../contracts'
3
- import {PRECISION} from '../types'
4
-
5
- const EXTRACTION_TIME_SCALE = 100
6
- const DEPTH_PENALTY_DIVISOR = 5000
7
- const DRILL_TIME_SCALE = 300
8
-
9
- export function calc_extraction_duration(
10
- extractor: ServerContract.Types.extractor_stats,
11
- itemMass: number,
12
- quantity: number,
13
- stratum: number,
14
- richness: number
15
- ): UInt32 {
16
- const rate = extractor.rate.toNumber()
17
- const drill = extractor.drill.toNumber()
18
-
19
- if (rate === 0 || drill === 0 || richness === 0) return UInt32.from(0)
20
-
21
- const massFactor = Math.sqrt(itemMass)
22
- const depthPenalty = 1 + stratum / DEPTH_PENALTY_DIVISOR
23
- const richnessMul = richness / 1000
24
- const extractionTime =
25
- (quantity * massFactor * EXTRACTION_TIME_SCALE * depthPenalty) / (rate * richnessMul)
26
- const drillTime = DRILL_TIME_SCALE * Math.log(1 + stratum / drill)
27
- return UInt32.from(Math.floor(extractionTime + drillTime))
28
- }
29
-
30
- export function calc_extraction_energy(
31
- extractor: ServerContract.Types.extractor_stats,
32
- duration: number
33
- ): UInt16 {
34
- const energy = Math.floor((duration * extractor.drain.toNumber()) / PRECISION)
35
- return UInt16.from(energy)
36
- }