@shipload/sdk 1.0.0-next.0 → 1.0.0-next.10

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.
Files changed (51) hide show
  1. package/lib/shipload.d.ts +512 -320
  2. package/lib/shipload.js +1960 -1060
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +1920 -1056
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +8 -3
  7. package/src/capabilities/modules.ts +3 -0
  8. package/src/capabilities/storage.ts +1 -1
  9. package/src/contracts/platform.ts +13 -1
  10. package/src/contracts/server.ts +227 -282
  11. package/src/data/capabilities.ts +5 -330
  12. package/src/data/capability-formulas.ts +70 -0
  13. package/src/data/catalog.ts +0 -5
  14. package/src/data/colors.ts +2 -16
  15. package/src/data/entities.json +33 -10
  16. package/src/data/item-ids.ts +3 -1
  17. package/src/data/items.json +258 -0
  18. package/src/data/metadata.ts +57 -1
  19. package/src/data/recipes-runtime.ts +1 -0
  20. package/src/data/recipes.json +82 -11
  21. package/src/derivation/capability-mappings.ts +122 -0
  22. package/src/derivation/index.ts +1 -0
  23. package/src/derivation/resources.ts +116 -37
  24. package/src/derivation/stats.ts +1 -2
  25. package/src/entities/container.ts +25 -10
  26. package/src/entities/extractor.ts +144 -0
  27. package/src/entities/gamestate.ts +0 -9
  28. package/src/entities/makers.ts +71 -20
  29. package/src/entities/ship-deploy.ts +114 -56
  30. package/src/entities/ship.ts +17 -0
  31. package/src/entities/slot-multiplier.ts +21 -0
  32. package/src/entities/warehouse.ts +20 -3
  33. package/src/index-module.ts +67 -26
  34. package/src/managers/actions.ts +53 -80
  35. package/src/managers/entities.ts +31 -17
  36. package/src/managers/locations.ts +2 -20
  37. package/src/nft/atomicdata.ts +125 -0
  38. package/src/nft/description.ts +41 -7
  39. package/src/nft/index.ts +1 -0
  40. package/src/resolution/resolve-item.ts +17 -9
  41. package/src/scheduling/accessor.ts +4 -0
  42. package/src/scheduling/projection.ts +8 -0
  43. package/src/scheduling/schedule.ts +15 -1
  44. package/src/scheduling/task-cargo.ts +47 -0
  45. package/src/subscriptions/connection.ts +50 -2
  46. package/src/subscriptions/manager.ts +81 -2
  47. package/src/travel/travel.ts +61 -2
  48. package/src/types/entity-traits.ts +64 -1
  49. package/src/types.ts +11 -1
  50. package/src/utils/cargo.ts +27 -0
  51. package/src/utils/system.ts +25 -24
@@ -11,11 +11,11 @@ import {
11
11
  type UInt64Type,
12
12
  } from '@wharfkit/antelope'
13
13
  import {BaseManager} from './base'
14
- import {type CoordinatesType, EntityType, type EntityTypeName} from '../types'
14
+ import type {CoordinatesType} from '../types'
15
15
  import {ServerContract} from '../contracts'
16
16
 
17
17
  export type EntityRefInput = {
18
- entityType: EntityTypeName
18
+ entityType: NameType
19
19
  entityId: UInt64Type
20
20
  }
21
21
 
@@ -25,7 +25,6 @@ export class ActionsManager extends BaseManager {
25
25
  const y = Int64.from(destination.y)
26
26
 
27
27
  return this.server.action('travel', {
28
- entity_type: EntityType.SHIP,
29
28
  id: UInt64.from(shipId),
30
29
  x,
31
30
  y,
@@ -51,13 +50,8 @@ export class ActionsManager extends BaseManager {
51
50
  })
52
51
  }
53
52
 
54
- resolve(
55
- entityId: UInt64Type,
56
- entityType: EntityTypeName = EntityType.SHIP,
57
- count?: UInt64Type
58
- ): Action {
53
+ resolve(entityId: UInt64Type, count?: UInt64Type): Action {
59
54
  const params: ServerContract.ActionParams.resolve = {
60
- entity_type: entityType,
61
55
  id: UInt64.from(entityId),
62
56
  }
63
57
  if (count !== undefined) {
@@ -66,42 +60,34 @@ export class ActionsManager extends BaseManager {
66
60
  return this.server.action('resolve', params)
67
61
  }
68
62
 
69
- cancel(
70
- entityId: UInt64Type,
71
- count: UInt64Type,
72
- entityType: EntityTypeName = EntityType.SHIP
73
- ): Action {
63
+ cancel(entityId: UInt64Type, count: UInt64Type): Action {
74
64
  return this.server.action('cancel', {
75
- entity_type: entityType,
76
65
  id: UInt64.from(entityId),
77
66
  count: UInt64.from(count),
78
67
  })
79
68
  }
80
69
 
81
- recharge(entityId: UInt64Type, entityType: EntityTypeName = EntityType.SHIP): Action {
70
+ recharge(entityId: UInt64Type): Action {
82
71
  return this.server.action('recharge', {
83
- entity_type: entityType,
84
72
  id: UInt64.from(entityId),
85
73
  })
86
74
  }
87
75
 
76
+ refrshentity(entityId: UInt64Type): Action {
77
+ return this.server.action('refrshentity', {
78
+ entity_id: UInt64.from(entityId),
79
+ })
80
+ }
81
+
88
82
  transfer(
89
- sourceType: EntityTypeName,
90
83
  sourceId: UInt64Type,
91
- destType: EntityTypeName,
92
84
  destId: UInt64Type,
93
- itemId: UInt64Type,
94
- stats: UInt64Type,
95
- quantity: UInt64Type
85
+ items: ServerContract.ActionParams.Type.cargo_item[]
96
86
  ): Action {
97
87
  return this.server.action('transfer', {
98
- source_type: sourceType,
99
88
  source_id: UInt64.from(sourceId),
100
- dest_type: destType,
101
89
  dest_id: UInt64.from(destId),
102
- item_id: UInt16.from(itemId),
103
- stats: UInt64.from(stats),
104
- quantity: UInt32.from(quantity),
90
+ items,
105
91
  })
106
92
  }
107
93
 
@@ -119,35 +105,24 @@ export class ActionsManager extends BaseManager {
119
105
  }
120
106
 
121
107
  gather(
122
- source: EntityRefInput,
123
- destination: EntityRefInput,
108
+ sourceId: UInt64Type,
109
+ destinationId: UInt64Type,
124
110
  stratum: UInt16Type,
125
111
  quantity: UInt32Type
126
112
  ): Action {
127
113
  return this.server.action('gather', {
128
- source: ServerContract.Types.entity_ref.from({
129
- entity_type: source.entityType,
130
- entity_id: UInt64.from(source.entityId),
131
- }),
132
- destination: ServerContract.Types.entity_ref.from({
133
- entity_type: destination.entityType,
134
- entity_id: UInt64.from(destination.entityId),
135
- }),
114
+ source_id: UInt64.from(sourceId),
115
+ destination_id: UInt64.from(destinationId),
136
116
  stratum: UInt16.from(stratum),
137
117
  quantity: UInt32.from(quantity),
138
118
  })
139
119
  }
140
120
 
141
- warp(
142
- entityId: UInt64Type,
143
- destination: CoordinatesType,
144
- entityType: EntityTypeName = EntityType.SHIP
145
- ): Action {
121
+ warp(entityId: UInt64Type, destination: CoordinatesType): Action {
146
122
  const x = Int64.from(destination.x)
147
123
  const y = Int64.from(destination.y)
148
124
 
149
125
  return this.server.action('warp', {
150
- entity_type: entityType,
151
126
  id: UInt64.from(entityId),
152
127
  x,
153
128
  y,
@@ -155,92 +130,90 @@ export class ActionsManager extends BaseManager {
155
130
  }
156
131
 
157
132
  craft(
158
- entityType: EntityTypeName,
159
133
  entityId: UInt64Type,
160
134
  recipeId: number,
161
135
  quantity: number,
162
136
  inputs: ServerContract.ActionParams.Type.cargo_item[]
163
137
  ): Action {
164
- const cargoInputs = inputs.map((i) => ServerContract.Types.cargo_item.from(i))
165
138
  return this.server.action('craft', {
166
- entity_type: entityType,
167
139
  id: UInt64.from(entityId),
168
140
  recipe_id: UInt16.from(recipeId),
169
141
  quantity: UInt32.from(quantity),
170
- inputs: cargoInputs,
142
+ inputs,
171
143
  })
172
144
  }
173
145
 
174
- blend(
175
- entityType: EntityTypeName,
176
- entityId: UInt64Type,
177
- inputs: ServerContract.ActionParams.Type.cargo_item[]
178
- ): Action {
179
- const cargoInputs = inputs.map((i) => ServerContract.Types.cargo_item.from(i))
146
+ blend(entityId: UInt64Type, inputs: ServerContract.ActionParams.Type.cargo_item[]): Action {
180
147
  return this.server.action('blend', {
181
- entity_type: entityType,
182
148
  id: UInt64.from(entityId),
183
- inputs: cargoInputs,
149
+ inputs,
184
150
  })
185
151
  }
186
152
 
187
- deploy(
188
- entityType: EntityTypeName,
189
- entityId: UInt64Type,
190
- packedItemId: number,
191
- stats: bigint
192
- ): Action {
153
+ deploy(entityId: UInt64Type, ref: ServerContract.ActionParams.Type.cargo_ref): Action {
193
154
  return this.server.action('deploy', {
194
- entity_type: entityType,
195
155
  id: UInt64.from(entityId),
196
- packed_item_id: UInt16.from(packedItemId),
197
- stats: UInt64.from(stats),
156
+ ref,
198
157
  })
199
158
  }
200
159
 
201
160
  addmodule(
202
- entityType: EntityTypeName,
203
161
  entityId: UInt64Type,
204
162
  moduleIndex: number,
205
- moduleCargoId: UInt64Type,
206
- targetCargoId: UInt64Type = UInt64.from(0)
163
+ moduleRef: ServerContract.ActionParams.Type.cargo_ref,
164
+ targetRef: ServerContract.ActionParams.Type.cargo_ref | null = null
207
165
  ): Action {
208
166
  return this.server.action('addmodule', {
209
- entity_type: entityType,
210
167
  entity_id: UInt64.from(entityId),
211
168
  module_index: moduleIndex,
212
- module_cargo_id: UInt64.from(moduleCargoId),
213
- target_cargo_id: UInt64.from(targetCargoId),
169
+ module_ref: moduleRef,
170
+ target_ref: targetRef ?? undefined,
214
171
  })
215
172
  }
216
173
 
217
174
  rmmodule(
218
- entityType: EntityTypeName,
219
175
  entityId: UInt64Type,
220
176
  moduleIndex: number,
221
- targetCargoId: UInt64Type = UInt64.from(0)
177
+ targetRef: ServerContract.ActionParams.Type.cargo_ref | null = null
222
178
  ): Action {
223
179
  return this.server.action('rmmodule', {
224
- entity_type: entityType,
225
180
  entity_id: UInt64.from(entityId),
226
181
  module_index: moduleIndex,
227
- target_cargo_id: UInt64.from(targetCargoId),
182
+ target_ref: targetRef ?? undefined,
228
183
  })
229
184
  }
230
185
 
231
186
  wrap(
232
187
  owner: NameType,
233
- entityType: EntityTypeName,
234
188
  entityId: UInt64Type,
235
- cargoId: UInt64Type,
236
- quantity: UInt64Type
189
+ nexusId: UInt64Type,
190
+ items: ServerContract.ActionParams.Type.cargo_item[]
237
191
  ): Action {
238
192
  return this.server.action('wrap', {
239
193
  owner: Name.from(owner),
240
- entity_type: entityType,
241
194
  entity_id: UInt64.from(entityId),
242
- cargo_id: UInt64.from(cargoId),
243
- quantity: UInt64.from(quantity),
195
+ nexus_id: UInt64.from(nexusId),
196
+ items,
197
+ })
198
+ }
199
+
200
+ undeploy(hostId: UInt64Type, targetId: UInt64Type): Action {
201
+ return this.server.action('undeploy', {
202
+ host_id: UInt64.from(hostId),
203
+ target_id: UInt64.from(targetId),
204
+ })
205
+ }
206
+
207
+ wrapEntity(entityId: UInt64Type, nexusId: UInt64Type): Action {
208
+ return this.server.action('wrapentity', {
209
+ entity_id: UInt64.from(entityId),
210
+ nexus_id: UInt64.from(nexusId),
211
+ })
212
+ }
213
+
214
+ demolish(entityId: UInt64Type): Action {
215
+ return this.server.action('demolish', {
216
+ entity_id: UInt64.from(entityId),
244
217
  })
245
218
  }
246
219
 
@@ -3,14 +3,14 @@ import {BaseManager} from './base'
3
3
  import {Ship} from '../entities/ship'
4
4
  import {Warehouse} from '../entities/warehouse'
5
5
  import {Container} from '../entities/container'
6
+ import {Extractor} from '../entities/extractor'
6
7
  import type {ServerContract} from '../contracts'
7
8
 
8
- export type EntityType = 'ship' | 'warehouse' | 'container' | 'location'
9
+ export type EntityType = 'ship' | 'warehouse' | 'extractor' | 'container'
9
10
 
10
11
  export class EntitiesManager extends BaseManager {
11
- async getEntity(type: EntityType, id: UInt64Type): Promise<Ship | Warehouse | Container> {
12
+ async getEntity(id: UInt64Type): Promise<Ship | Warehouse | Extractor | Container> {
12
13
  const result = await this.server.readonly('getentity', {
13
- entity_type: Name.from(type),
14
14
  entity_id: id,
15
15
  })
16
16
  const entityInfo = result as ServerContract.Types.entity_info
@@ -20,11 +20,11 @@ export class EntitiesManager extends BaseManager {
20
20
  async getEntities(
21
21
  owner: NameType | ServerContract.Types.player_row,
22
22
  type?: EntityType
23
- ): Promise<(Ship | Warehouse | Container)[]> {
23
+ ): Promise<(Ship | Warehouse | Extractor | Container)[]> {
24
24
  const ownerName = this.resolveOwner(owner)
25
25
  const result = await this.server.readonly('getentities', {
26
26
  owner: ownerName,
27
- entity_type: type ? Name.from(type) : null,
27
+ entity_type: type,
28
28
  })
29
29
  const entities = result as ServerContract.Types.entity_info[]
30
30
  return entities.map((entity) => this.wrapEntity(entity))
@@ -37,21 +37,25 @@ export class EntitiesManager extends BaseManager {
37
37
  const ownerName = this.resolveOwner(owner)
38
38
  const result = await this.server.readonly('getsummaries', {
39
39
  owner: ownerName,
40
- entity_type: type ? Name.from(type) : null,
40
+ entity_type: type,
41
41
  })
42
42
  return result as ServerContract.Types.entity_summary[]
43
43
  }
44
44
 
45
45
  async getShip(id: UInt64Type): Promise<Ship> {
46
- return (await this.getEntity('ship', id)) as Ship
46
+ return (await this.getEntity(id)) as Ship
47
47
  }
48
48
 
49
49
  async getWarehouse(id: UInt64Type): Promise<Warehouse> {
50
- return (await this.getEntity('warehouse', id)) as Warehouse
50
+ return (await this.getEntity(id)) as Warehouse
51
51
  }
52
52
 
53
53
  async getContainer(id: UInt64Type): Promise<Container> {
54
- return (await this.getEntity('container', id)) as Container
54
+ return (await this.getEntity(id)) as Container
55
+ }
56
+
57
+ async getExtractor(id: UInt64Type): Promise<Extractor> {
58
+ return (await this.getEntity(id)) as Extractor
55
59
  }
56
60
 
57
61
  async getShips(owner: NameType | ServerContract.Types.player_row): Promise<Ship[]> {
@@ -66,6 +70,10 @@ export class EntitiesManager extends BaseManager {
66
70
  return (await this.getEntities(owner, 'container')) as Container[]
67
71
  }
68
72
 
73
+ async getExtractors(owner: NameType | ServerContract.Types.player_row): Promise<Extractor[]> {
74
+ return (await this.getEntities(owner, 'extractor')) as Extractor[]
75
+ }
76
+
69
77
  async getShipSummaries(
70
78
  owner: NameType | ServerContract.Types.player_row
71
79
  ): Promise<ServerContract.Types.entity_summary[]> {
@@ -84,14 +92,20 @@ export class EntitiesManager extends BaseManager {
84
92
  return this.getSummaries(owner, 'container')
85
93
  }
86
94
 
87
- private wrapEntity(entity: ServerContract.Types.entity_info): Ship | Warehouse | Container {
88
- if (entity.type.equals('ship')) {
89
- return new Ship(entity)
90
- } else if (entity.type.equals('warehouse')) {
91
- return new Warehouse(entity)
92
- } else {
93
- return new Container(entity)
94
- }
95
+ async getExtractorSummaries(
96
+ owner: NameType | ServerContract.Types.player_row
97
+ ): Promise<ServerContract.Types.entity_summary[]> {
98
+ return this.getSummaries(owner, 'extractor')
99
+ }
100
+
101
+ private wrapEntity(
102
+ entity: ServerContract.Types.entity_info
103
+ ): Ship | Warehouse | Extractor | Container {
104
+ if (entity.type.equals('ship')) return new Ship(entity)
105
+ if (entity.type.equals('warehouse')) return new Warehouse(entity)
106
+ if (entity.type.equals('extractor')) return new Extractor(entity)
107
+ if (entity.type.equals('container')) return new Container(entity)
108
+ throw new Error(`unknown entity type: ${entity.type}`)
95
109
  }
96
110
 
97
111
  private resolveOwner(owner: NameType | ServerContract.Types.player_row): Name {
@@ -1,6 +1,6 @@
1
- import {type UInt16Type, UInt64, type UInt64Type} from '@wharfkit/antelope'
1
+ import type {UInt16Type} from '@wharfkit/antelope'
2
2
  import {BaseManager} from './base'
3
- import {type CoordinatesType, coordsToLocationId, type Distance} from '../types'
3
+ import type {CoordinatesType, Distance} from '../types'
4
4
  import {hasSystem} from '../utils/system'
5
5
  import {findNearbyPlanets} from '../travel/travel'
6
6
  import type {ServerContract} from '../contracts'
@@ -47,22 +47,4 @@ export class LocationsManager extends BaseManager {
47
47
  reserve: overrideMap.get(s.index) ?? s.reserve,
48
48
  }))
49
49
  }
50
-
51
- async getLocationEntity(
52
- id: UInt64Type
53
- ): Promise<ServerContract.Types.location_row | undefined> {
54
- const row = await this.server.table('location').get(UInt64.from(id))
55
- return row ?? undefined
56
- }
57
-
58
- async getLocationEntityAt(
59
- coords: CoordinatesType
60
- ): Promise<ServerContract.Types.location_row | undefined> {
61
- const id = coordsToLocationId(coords)
62
- return this.getLocationEntity(id)
63
- }
64
-
65
- async getAllLocationEntities(): Promise<ServerContract.Types.location_row[]> {
66
- return this.server.table('location').all()
67
- }
68
50
  }
@@ -0,0 +1,125 @@
1
+ export interface SchemaField {
2
+ name: string
3
+ type: string
4
+ }
5
+
6
+ export type RawData =
7
+ | Uint8Array
8
+ | string
9
+ | number[]
10
+ | {immutable_serialized_data: Uint8Array | string | number[]}
11
+
12
+ export function deserializeAtomicData(
13
+ data: RawData,
14
+ schema: SchemaField[]
15
+ ): Record<string, unknown> {
16
+ let rawData: Uint8Array | string | number[]
17
+ if (data && typeof data === 'object' && 'immutable_serialized_data' in (data as object)) {
18
+ rawData = (data as {immutable_serialized_data: Uint8Array | string | number[]})
19
+ .immutable_serialized_data
20
+ } else {
21
+ rawData = data as Uint8Array | string | number[]
22
+ }
23
+
24
+ let bytes: Uint8Array
25
+ if (typeof rawData === 'string') {
26
+ const hex = rawData
27
+ bytes = new Uint8Array(hex.length / 2)
28
+ for (let i = 0; i < hex.length; i += 2) {
29
+ bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16)
30
+ }
31
+ } else if (Array.isArray(rawData)) {
32
+ bytes = new Uint8Array(rawData)
33
+ } else {
34
+ bytes = rawData
35
+ }
36
+
37
+ let offset = 0
38
+
39
+ function readVarint(): number {
40
+ let result = 0
41
+ let multiplier = 1
42
+ while (bytes[offset] >= 128) {
43
+ result += (bytes[offset] - 128) * multiplier
44
+ offset++
45
+ multiplier *= 128
46
+ }
47
+ result += bytes[offset] * multiplier
48
+ offset++
49
+ return result
50
+ }
51
+
52
+ function readVarint64(): bigint {
53
+ let result = 0n
54
+ let multiplier = 1n
55
+ while (bytes[offset] >= 128) {
56
+ result += BigInt(bytes[offset] - 128) * multiplier
57
+ offset++
58
+ multiplier *= 128n
59
+ }
60
+ result += BigInt(bytes[offset]) * multiplier
61
+ offset++
62
+ return result
63
+ }
64
+
65
+ function readZigzagInt64(): bigint {
66
+ const unsigned = readVarint64()
67
+ if (unsigned % 2n === 0n) {
68
+ return unsigned / 2n
69
+ } else {
70
+ return -(unsigned / 2n) - 1n
71
+ }
72
+ }
73
+
74
+ function readString(): string {
75
+ const length = readVarint()
76
+ const str = new TextDecoder().decode(bytes.slice(offset, offset + length))
77
+ offset += length
78
+ return str
79
+ }
80
+
81
+ const RESERVED = 4
82
+ const result: Record<string, unknown> = {}
83
+
84
+ while (offset < bytes.length) {
85
+ const fieldIndex = readVarint() - RESERVED
86
+ const field = schema[fieldIndex]
87
+ if (!field) break
88
+
89
+ switch (field.type) {
90
+ case 'uint16':
91
+ result[field.name] = readVarint()
92
+ break
93
+ case 'uint32':
94
+ result[field.name] = readVarint()
95
+ break
96
+ case 'uint64':
97
+ result[field.name] = readVarint64()
98
+ break
99
+ case 'int64':
100
+ result[field.name] = readZigzagInt64()
101
+ break
102
+ case 'string':
103
+ result[field.name] = readString()
104
+ break
105
+ case 'uint16[]': {
106
+ const len = readVarint()
107
+ const arr: number[] = []
108
+ for (let i = 0; i < len; i++) arr.push(readVarint())
109
+ result[field.name] = arr
110
+ break
111
+ }
112
+ case 'uint64[]': {
113
+ const len = readVarint()
114
+ const arr: bigint[] = []
115
+ for (let i = 0; i < len; i++) arr.push(readVarint64())
116
+ result[field.name] = arr
117
+ break
118
+ }
119
+ default:
120
+ throw new Error(`Unknown type: ${field.type}`)
121
+ }
122
+ }
123
+
124
+ return result
125
+ }
@@ -4,22 +4,29 @@ import {
4
4
  MODULE_ENGINE,
5
5
  MODULE_GATHERER,
6
6
  MODULE_GENERATOR,
7
+ MODULE_HAULER,
7
8
  MODULE_LOADER,
8
9
  MODULE_STORAGE,
10
+ MODULE_WARP,
9
11
  } from '../capabilities/modules'
10
12
  import {
11
13
  ITEM_CONTAINER_T1_PACKED,
12
14
  ITEM_CONTAINER_T2_PACKED,
13
15
  ITEM_CRAFTER_T1,
14
16
  ITEM_ENGINE_T1,
17
+ ITEM_EXTRACTOR_T1_PACKED,
15
18
  ITEM_GATHERER_T1,
16
19
  ITEM_GENERATOR_T1,
20
+ ITEM_HAULER_T1,
17
21
  ITEM_LOADER_T1,
18
22
  ITEM_SHIP_T1_PACKED,
19
23
  ITEM_STORAGE_T1,
20
24
  ITEM_WAREHOUSE_T1_PACKED,
25
+ ITEM_WARP_T1,
21
26
  } from '../data/item-ids'
22
27
  import {decodeStat} from '../derivation/crafting'
28
+ import {gathererDepthForTier} from '../entities/ship-deploy'
29
+ import {getItem} from '../data/catalog'
23
30
 
24
31
  function idiv(a: number, b: number): number {
25
32
  return Math.floor(a / b)
@@ -27,7 +34,7 @@ function idiv(a: number, b: number): number {
27
34
 
28
35
  export function computeBaseHullmass(stats: bigint): number {
29
36
  const density = decodeStat(stats, 1)
30
- return 25000 + 75 * density
37
+ return 100000 - 75 * density
31
38
  }
32
39
 
33
40
  export function computeBaseCapacityShip(stats: bigint): number {
@@ -42,17 +49,22 @@ export function computeBaseCapacityWarehouse(stats: bigint): number {
42
49
 
43
50
  export const computeEngineThrust = (vol: number): number => 400 + idiv(vol * 3, 4)
44
51
  export const computeEngineDrain = (thm: number): number => Math.max(30, 50 - idiv(thm, 70))
45
- export const computeGeneratorCap = (res: number): number => 300 + idiv(res, 6)
46
- export const computeGeneratorRech = (ref: number): number => 1 + idiv(ref * 3, 1000)
52
+ export const computeGeneratorCap = (com: number): number => 300 + idiv(com, 6)
53
+ export const computeGeneratorRech = (fin: number): number => 1 + idiv(fin * 3, 1000)
47
54
  export const computeGathererYield = (str: number): number => 200 + str
48
55
  export const computeGathererDrain = (con: number): number =>
49
56
  Math.max(250, 1250 - idiv(con * 25, 20))
50
- export const computeGathererDepth = (tol: number): number => 200 + idiv(tol * 3, 2)
57
+ export const computeGathererDepth = (tol: number, tier: number): number =>
58
+ gathererDepthForTier(tol, tier)
51
59
  export const computeGathererSpeed = (ref: number): number => 100 + idiv(ref * 4, 5)
52
- export const computeLoaderMass = (fin: number): number => Math.max(200, 2000 - fin * 2)
60
+ export const computeLoaderMass = (ins: number): number => Math.max(200, 2000 - ins * 2)
53
61
  export const computeLoaderThrust = (pla: number): number => 1 + idiv(pla, 500)
54
62
  export const computeCrafterSpeed = (rea: number): number => 100 + idiv(rea * 4, 5)
55
- export const computeCrafterDrain = (com: number): number => Math.max(5, 30 - idiv(com, 33))
63
+ export const computeCrafterDrain = (fin: number): number => Math.max(5, 30 - idiv(fin, 33))
64
+ export const computeHaulerCapacity = (fin: number): number => Math.max(1, 1 + idiv(fin, 400))
65
+ export const computeHaulerEfficiency = (con: number): number => 2000 + con * 6
66
+ export const computeHaulerDrain = (com: number): number => Math.max(3, 15 - idiv(com, 80))
67
+ export const computeWarpRange = (stat: number): number => 100 + stat * 3
56
68
 
57
69
  export function entityDisplayName(itemId: number): string {
58
70
  switch (itemId) {
@@ -60,6 +72,8 @@ export function entityDisplayName(itemId: number): string {
60
72
  return 'Ship'
61
73
  case ITEM_WAREHOUSE_T1_PACKED:
62
74
  return 'Warehouse'
75
+ case ITEM_EXTRACTOR_T1_PACKED:
76
+ return 'Extractor'
63
77
  case ITEM_CONTAINER_T1_PACKED:
64
78
  return 'Container'
65
79
  case ITEM_CONTAINER_T2_PACKED:
@@ -83,6 +97,10 @@ export function moduleDisplayName(itemId: number): string {
83
97
  return 'Crafter'
84
98
  case ITEM_STORAGE_T1:
85
99
  return 'Storage'
100
+ case ITEM_HAULER_T1:
101
+ return 'Hauler'
102
+ case ITEM_WARP_T1:
103
+ return 'Warp'
86
104
  default:
87
105
  return 'Module'
88
106
  }
@@ -116,8 +134,10 @@ export function formatModuleLine(slot: number, itemId: number, stats: bigint): s
116
134
  const tol = decodeStat(stats, 1)
117
135
  const con = decodeStat(stats, 3)
118
136
  const ref = decodeStat(stats, 4)
137
+ const tier = getItem(itemId).tier
119
138
  out += ` Yield ${computeGathererYield(str)} Depth ${computeGathererDepth(
120
- tol
139
+ tol,
140
+ tier
121
141
  )} Speed ${computeGathererSpeed(ref)} Drain ${computeGathererDrain(con)}`
122
142
  break
123
143
  }
@@ -142,6 +162,18 @@ export function formatModuleLine(slot: number, itemId: number, stats: bigint): s
142
162
  out += ` +${pct}% capacity`
143
163
  break
144
164
  }
165
+ case MODULE_HAULER: {
166
+ const fin = decodeStat(stats, 0)
167
+ const con = decodeStat(stats, 1)
168
+ const com = decodeStat(stats, 2)
169
+ out += ` Capacity ${computeHaulerCapacity(fin)} Efficiency ${computeHaulerEfficiency(con)} Drain ${computeHaulerDrain(com)}`
170
+ break
171
+ }
172
+ case MODULE_WARP: {
173
+ const stat = decodeStat(stats, 0)
174
+ out += ` Range ${computeWarpRange(stat)}`
175
+ break
176
+ }
145
177
  }
146
178
  return out
147
179
  }
@@ -158,6 +190,8 @@ export function buildEntityDescription(
158
190
  baseCapacity = computeBaseCapacityShip(hullStats)
159
191
  } else if (itemId === ITEM_WAREHOUSE_T1_PACKED) {
160
192
  baseCapacity = computeBaseCapacityWarehouse(hullStats)
193
+ } else if (itemId === ITEM_EXTRACTOR_T1_PACKED) {
194
+ baseCapacity = computeBaseCapacityShip(hullStats)
161
195
  }
162
196
 
163
197
  let out = entityDisplayName(itemId)
package/src/nft/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './deserializers'
2
2
  export * from './description'
3
+ export * from './atomicdata'