@shipload/sdk 1.0.0-next.44 → 1.0.0-next.45

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipload/sdk",
3
3
  "description": "SDKs for Shipload",
4
- "version": "1.0.0-next.44",
4
+ "version": "1.0.0-next.45",
5
5
  "homepage": "https://github.com/shipload/toolkit/tree/master/packages/sdk",
6
6
  "repository": {
7
7
  "type": "git",
@@ -2,10 +2,11 @@ import {expect, test} from 'bun:test'
2
2
  import {UInt16, UInt64} from '@wharfkit/antelope'
3
3
  import {resolveItem} from './resolve-item'
4
4
  import {encodeStats} from '../derivation/crafting'
5
- import {computeContainerCapabilities} from '../derivation/capabilities'
5
+ import {computeBaseHullmass, computeContainerCapabilities} from '../derivation/capabilities'
6
6
  import {
7
7
  ITEM_EXTRACTOR_T1_PACKED,
8
8
  ITEM_FACTORY_T1_PACKED,
9
+ ITEM_HUB_T1_PACKED,
9
10
  ITEM_MASS_DRIVER_T1_PACKED,
10
11
  ITEM_MASS_CATCHER_T1_PACKED,
11
12
  } from '../data/item-ids'
@@ -35,3 +36,13 @@ for (const [label, itemId] of CONTAINER_ENTITIES) {
35
36
  expect(capacity).toBe(expected)
36
37
  })
37
38
  }
39
+
40
+ test('resolveItem resolves the station hub with hullmass and zero cargo capacity', () => {
41
+ const stats = hullStats(300, 100, 400)
42
+ const resolved = resolveItem(UInt16.from(ITEM_HUB_T1_PACKED), stats)
43
+ const hull = resolved.attributes?.find((g) => g.capability === 'Hull')
44
+ expect(hull?.attributes.find((a) => a.label === 'Mass')?.value).toBe(
45
+ computeBaseHullmass({density: 100})
46
+ )
47
+ expect(hull?.attributes.find((a) => a.label === 'Capacity')?.value).toBe(0)
48
+ })
@@ -26,6 +26,7 @@ import {
26
26
  computeGeneratorCapabilities,
27
27
  computeHaulerCapabilities,
28
28
  computeLoaderCapabilities,
29
+ computeBaseHullmass,
29
30
  computeShipHullCapabilities,
30
31
  computeWarehouseHullCapabilities,
31
32
  computeContainerCapabilities,
@@ -298,7 +299,7 @@ function hullCapsForEntity(
298
299
  case ITEM_CONTAINER_T2_PACKED:
299
300
  return computeContainerT2Capabilities(decoded)
300
301
  default:
301
- throw new Error(`resolveItem: no capacity formula wired for entity item ${itemId}`)
302
+ return {hullmass: computeBaseHullmass(decoded), capacity: 0}
302
303
  }
303
304
  }
304
305
 
@@ -316,6 +317,7 @@ function resolveEntity(
316
317
  const bigStats = toBigStats(stats)
317
318
  const decoded = decodeCraftedItemStats(id, bigStats)
318
319
  if (decoded.strength === undefined) decoded.strength = decodeStat(bigStats, 0)
320
+ if (decoded.density === undefined) decoded.density = decodeStat(bigStats, 1)
319
321
  if (decoded.hardness === undefined) decoded.hardness = decodeStat(bigStats, 2)
320
322
  const hullCaps = hullCapsForEntity(id, decoded)
321
323
  attributes = [