@shipload/sdk 1.0.0-next.45 → 1.0.0-next.47
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.
- package/lib/shipload.d.ts +236 -39
- package/lib/shipload.js +1465 -191
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +1450 -192
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +81 -15
- package/lib/testing.js +377 -44
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +378 -45
- package/lib/testing.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/gathering.test.ts +14 -1
- package/src/capabilities/gathering.ts +6 -5
- package/src/capabilities/modules.ts +13 -0
- package/src/contracts/server.ts +242 -28
- package/src/data/capabilities.ts +1 -1
- package/src/data/entities.json +93 -19
- package/src/data/item-ids.ts +12 -0
- package/src/data/items.json +76 -2
- package/src/data/kind-registry.json +10 -0
- package/src/data/metadata.ts +75 -7
- package/src/data/recipes-runtime.ts +1 -0
- package/src/data/recipes.json +736 -0
- package/src/derivation/capabilities.test.ts +11 -11
- package/src/derivation/capabilities.ts +42 -27
- package/src/derivation/crafting.ts +13 -9
- package/src/derivation/index.ts +2 -0
- package/src/derivation/recipe-usage.test.ts +11 -7
- package/src/derivation/stars.test.ts +16 -0
- package/src/derivation/stars.ts +10 -0
- package/src/derivation/stratum.ts +11 -4
- package/src/entities/makers.ts +8 -1
- package/src/index-module.ts +5 -1
- package/src/managers/actions.ts +10 -0
- package/src/nft/buildImmutableData.ts +1 -1
- package/src/nft/description.ts +25 -12
- package/src/resolution/describe-module.ts +21 -8
- package/src/resolution/resolve-item.ts +31 -33
- package/src/scheduling/projection.ts +8 -1
- package/src/subscriptions/manager.cluster.test.ts +7 -2
- package/src/subscriptions/types.ts +1 -0
- package/src/utils/cargo.test.ts +14 -0
- package/src/utils/cargo.ts +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {UInt16, UInt64} from '@wharfkit/antelope'
|
|
2
2
|
import type {UInt16Type, UInt64Type} from '@wharfkit/antelope'
|
|
3
3
|
import type {ResourceCategory} from '../types'
|
|
4
|
-
import {getItem} from '../data/catalog'
|
|
4
|
+
import {getItem, getModules} from '../data/catalog'
|
|
5
5
|
import {getEntityLayout} from '../data/recipes-runtime'
|
|
6
6
|
import {entityMetadata, itemMetadata} from '../data/metadata'
|
|
7
7
|
import {
|
|
@@ -26,26 +26,13 @@ import {
|
|
|
26
26
|
computeGeneratorCapabilities,
|
|
27
27
|
computeHaulerCapabilities,
|
|
28
28
|
computeLoaderCapabilities,
|
|
29
|
+
computeBaseCapacity,
|
|
29
30
|
computeBaseHullmass,
|
|
30
|
-
computeShipHullCapabilities,
|
|
31
|
-
computeWarehouseHullCapabilities,
|
|
32
|
-
computeContainerCapabilities,
|
|
33
|
-
computeContainerT2Capabilities,
|
|
34
31
|
computeStorageCapabilities,
|
|
35
32
|
} from '../derivation/capabilities'
|
|
36
33
|
import {applySlotMultiplierUint32} from '../entities/slot-multiplier'
|
|
37
34
|
import {categoryColors, componentIcon, itemAbbreviations, moduleIcon} from '../data/colors'
|
|
38
35
|
import type {ServerContract} from '../contracts'
|
|
39
|
-
import {
|
|
40
|
-
ITEM_CONTAINER_T1_PACKED,
|
|
41
|
-
ITEM_CONTAINER_T2_PACKED,
|
|
42
|
-
ITEM_EXTRACTOR_T1_PACKED,
|
|
43
|
-
ITEM_FACTORY_T1_PACKED,
|
|
44
|
-
ITEM_MASS_CATCHER_T1_PACKED,
|
|
45
|
-
ITEM_MASS_DRIVER_T1_PACKED,
|
|
46
|
-
ITEM_SHIP_T1_PACKED,
|
|
47
|
-
ITEM_WAREHOUSE_T1_PACKED,
|
|
48
|
-
} from '../data/item-ids'
|
|
49
36
|
|
|
50
37
|
export interface ResolvedItemStat {
|
|
51
38
|
key: string
|
|
@@ -69,6 +56,10 @@ export interface ResolvedModuleSlot {
|
|
|
69
56
|
capability?: string
|
|
70
57
|
installed: boolean
|
|
71
58
|
attributes?: {label: string; value: number}[]
|
|
59
|
+
slotLabel?: string
|
|
60
|
+
slotType?: string
|
|
61
|
+
outputPct?: number
|
|
62
|
+
maxTier?: number
|
|
72
63
|
}
|
|
73
64
|
|
|
74
65
|
export interface ResolvedItem {
|
|
@@ -218,7 +209,7 @@ function computeCapabilityGroup(
|
|
|
218
209
|
}
|
|
219
210
|
}
|
|
220
211
|
case MODULE_HAULER: {
|
|
221
|
-
const caps = computeHaulerCapabilities(stats)
|
|
212
|
+
const caps = computeHaulerCapabilities(stats, tier)
|
|
222
213
|
return {
|
|
223
214
|
capability: 'Hauling',
|
|
224
215
|
attributes: [
|
|
@@ -257,11 +248,22 @@ function computeCapabilityGroup(
|
|
|
257
248
|
}
|
|
258
249
|
}
|
|
259
250
|
|
|
251
|
+
// Recipe-less higher-tier modules reuse the T1 stat layout of their module type.
|
|
252
|
+
function decodeModuleStats(id: number, big: bigint): Record<string, number> {
|
|
253
|
+
const decoded = decodeCraftedItemStats(id, big)
|
|
254
|
+
if (Object.keys(decoded).length > 0) return decoded
|
|
255
|
+
const moduleType = getItem(id).moduleType
|
|
256
|
+
if (!moduleType) return decoded
|
|
257
|
+
const t1 = getModules({moduleType, tier: 1})[0]
|
|
258
|
+
if (!t1) return decoded
|
|
259
|
+
return decodeCraftedItemStats(Number(t1.id), big)
|
|
260
|
+
}
|
|
261
|
+
|
|
260
262
|
function resolveModule(id: number, stats?: UInt64Type): ResolvedItem {
|
|
261
263
|
const item = getItem(id)
|
|
262
264
|
let attributes: ResolvedAttributeGroup[] | undefined
|
|
263
265
|
if (stats !== undefined) {
|
|
264
|
-
const decoded =
|
|
266
|
+
const decoded = decodeModuleStats(id, toBigStats(stats))
|
|
265
267
|
const modType = getModuleCapabilityType(id)
|
|
266
268
|
const group = computeCapabilityGroup(modType, decoded, item.tier)
|
|
267
269
|
if (group) attributes = [group]
|
|
@@ -285,21 +287,9 @@ function hullCapsForEntity(
|
|
|
285
287
|
hullmass: number
|
|
286
288
|
capacity: number
|
|
287
289
|
} {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
case ITEM_WAREHOUSE_T1_PACKED:
|
|
292
|
-
return computeWarehouseHullCapabilities(decoded)
|
|
293
|
-
case ITEM_EXTRACTOR_T1_PACKED:
|
|
294
|
-
case ITEM_FACTORY_T1_PACKED:
|
|
295
|
-
case ITEM_MASS_DRIVER_T1_PACKED:
|
|
296
|
-
case ITEM_MASS_CATCHER_T1_PACKED:
|
|
297
|
-
case ITEM_CONTAINER_T1_PACKED:
|
|
298
|
-
return computeContainerCapabilities(decoded)
|
|
299
|
-
case ITEM_CONTAINER_T2_PACKED:
|
|
300
|
-
return computeContainerT2Capabilities(decoded)
|
|
301
|
-
default:
|
|
302
|
-
return {hullmass: computeBaseHullmass(decoded), capacity: 0}
|
|
290
|
+
return {
|
|
291
|
+
hullmass: computeBaseHullmass(decoded),
|
|
292
|
+
capacity: computeBaseCapacity(itemId, decoded),
|
|
303
293
|
}
|
|
304
294
|
}
|
|
305
295
|
|
|
@@ -334,11 +324,17 @@ function resolveEntity(
|
|
|
334
324
|
if (layout && layout.slots.length > 0) {
|
|
335
325
|
const slotLabels = entityMetadata[id]?.moduleSlotLabels ?? []
|
|
336
326
|
moduleSlots = layout.slots.map((slot, i) => {
|
|
327
|
+
const slotInfo = {
|
|
328
|
+
slotLabel: slotLabels[i] ?? slot.type,
|
|
329
|
+
slotType: slot.type,
|
|
330
|
+
outputPct: slot.outputPct,
|
|
331
|
+
maxTier: slot.maxTier,
|
|
332
|
+
}
|
|
337
333
|
const mod = modules?.[i]
|
|
338
334
|
if (mod?.installed) {
|
|
339
335
|
const modItemId = Number(mod.installed.item_id.value.toString())
|
|
340
336
|
const modStats = BigInt(mod.installed.stats.toString())
|
|
341
|
-
const decodedStats =
|
|
337
|
+
const decodedStats = decodeModuleStats(modItemId, modStats)
|
|
342
338
|
const modType = getModuleCapabilityType(modItemId)
|
|
343
339
|
let modName = 'Module'
|
|
344
340
|
let modTier = 1
|
|
@@ -355,11 +351,13 @@ function resolveEntity(
|
|
|
355
351
|
capability: group?.capability,
|
|
356
352
|
installed: true,
|
|
357
353
|
attributes: group?.attributes,
|
|
354
|
+
...slotInfo,
|
|
358
355
|
}
|
|
359
356
|
}
|
|
360
357
|
return {
|
|
361
358
|
name: slotLabels[i] ?? slot.type,
|
|
362
359
|
installed: false,
|
|
360
|
+
...slotInfo,
|
|
363
361
|
}
|
|
364
362
|
})
|
|
365
363
|
}
|
|
@@ -167,7 +167,14 @@ function recomputeCaps(entity: Projectable): ProjectedCaps | undefined {
|
|
|
167
167
|
loaderLanes: (caps.loaderLanes ?? []).map(toLoaderLane),
|
|
168
168
|
gathererLanes: (caps.gathererLanes ?? []).map(toGathererLane),
|
|
169
169
|
crafterLanes: (caps.crafterLanes ?? []).map(toCrafterLane),
|
|
170
|
-
hauler: caps.hauler
|
|
170
|
+
hauler: caps.hauler
|
|
171
|
+
? ServerContract.Types.hauler_stats.from({
|
|
172
|
+
capacity: caps.hauler.capacity,
|
|
173
|
+
efficiency: caps.hauler.efficiency,
|
|
174
|
+
drain: caps.hauler.drain,
|
|
175
|
+
capacity_by_tier: caps.hauler.capacityByTier,
|
|
176
|
+
})
|
|
177
|
+
: undefined,
|
|
171
178
|
launcher: caps.launcher
|
|
172
179
|
? ServerContract.Types.launcher_stats.from({
|
|
173
180
|
charge_rate: caps.launcher.chargeRate,
|
|
@@ -29,10 +29,15 @@ describe('cluster delta routing', () => {
|
|
|
29
29
|
sub_id: handle.subId,
|
|
30
30
|
hub_id: 42,
|
|
31
31
|
seq: 7,
|
|
32
|
-
cells: [{gx: 0, gy: 1, entity: 99}],
|
|
32
|
+
cells: [{gx: 0, gy: 1, entity: 99, type: 'warehouse'}],
|
|
33
33
|
})
|
|
34
34
|
expect(received).toEqual([
|
|
35
|
-
{
|
|
35
|
+
{
|
|
36
|
+
hubId: 42,
|
|
37
|
+
seq: 7,
|
|
38
|
+
cells: [{gx: 0, gy: 1, entity: 99, type: 'warehouse'}],
|
|
39
|
+
erased: false,
|
|
40
|
+
},
|
|
36
41
|
])
|
|
37
42
|
})
|
|
38
43
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {describe, expect, test} from 'bun:test'
|
|
2
|
+
import {cargoRef} from './cargo'
|
|
3
|
+
|
|
4
|
+
describe('cargoRef', () => {
|
|
5
|
+
test('forwards entity_id when provided', () => {
|
|
6
|
+
const ref = cargoRef({item_id: 10201, stats: 196849n, modules: [], entity_id: 42n})
|
|
7
|
+
expect(ref.entity_id).toBe(42n)
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
test('omits entity_id when absent', () => {
|
|
11
|
+
const ref = cargoRef({item_id: 10201, stats: 196849n})
|
|
12
|
+
expect(ref.entity_id).toBeUndefined()
|
|
13
|
+
})
|
|
14
|
+
})
|
package/src/utils/cargo.ts
CHANGED
|
@@ -4,11 +4,13 @@ export function cargoRef(src: {
|
|
|
4
4
|
item_id: number
|
|
5
5
|
stats: bigint | number
|
|
6
6
|
modules?: ServerContract.Types.module_entry[]
|
|
7
|
+
entity_id?: bigint | number
|
|
7
8
|
}): ServerContract.ActionParams.Type.cargo_ref {
|
|
8
9
|
return {
|
|
9
10
|
item_id: src.item_id,
|
|
10
11
|
stats: src.stats,
|
|
11
12
|
modules: src.modules ?? [],
|
|
13
|
+
entity_id: src.entity_id,
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
|