@shipload/sdk 1.0.0-next.45 → 1.0.0-next.46
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 +235 -39
- package/lib/shipload.js +1399 -157
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +1385 -158
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +81 -15
- package/lib/testing.js +374 -41
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +375 -42
- 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 +4 -0
- package/src/contracts/server.ts +242 -28
- 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 +68 -0
- package/src/data/recipes-runtime.ts +1 -0
- package/src/data/recipes.json +720 -0
- package/src/derivation/capabilities.test.ts +11 -11
- package/src/derivation/capabilities.ts +42 -27
- 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 +20 -11
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {expect, test} from 'bun:test'
|
|
2
2
|
import type {GathererStats} from '../types/capabilities'
|
|
3
|
-
import {calc_gather_energy} from './gathering'
|
|
3
|
+
import {calc_gather_duration, calc_gather_energy} from './gathering'
|
|
4
4
|
|
|
5
5
|
function gatherer(drain: number): GathererStats {
|
|
6
6
|
return {
|
|
@@ -14,3 +14,16 @@ test('calc_gather_energy does not clamp above the old uint16 ceiling', () => {
|
|
|
14
14
|
const energy = calc_gather_energy(gatherer(30), 400_000_000)
|
|
15
15
|
expect(Number(energy)).toBeGreaterThan(65535)
|
|
16
16
|
})
|
|
17
|
+
|
|
18
|
+
test('splitting a bulk gather never undercuts total lane-time', () => {
|
|
19
|
+
const g: GathererStats = {
|
|
20
|
+
yield: {toNumber: () => 413},
|
|
21
|
+
drain: {toNumber: () => 30},
|
|
22
|
+
depth: {toNumber: () => 0, toString: () => '0'},
|
|
23
|
+
}
|
|
24
|
+
const bulk = Number(calc_gather_duration(g, 1000, 10, 8, 500))
|
|
25
|
+
const unit = Number(calc_gather_duration(g, 1000, 1, 8, 500))
|
|
26
|
+
// d1 >= 1 regime (bulk > quantity), where the split exploit lived
|
|
27
|
+
expect(bulk).toBeGreaterThan(10)
|
|
28
|
+
expect(unit * 10).toBeGreaterThanOrEqual(bulk)
|
|
29
|
+
})
|
|
@@ -30,9 +30,9 @@ export function calc_gather_duration(
|
|
|
30
30
|
stratum: number,
|
|
31
31
|
richness: number
|
|
32
32
|
): UInt32 {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
33
|
+
const raw = gather_duration_raw(gatherer, itemMass, quantity, stratum, richness)
|
|
34
|
+
// +1 per-gather setup cost mirrors the contract: splitting a bulk gather must not undercut lane-time
|
|
35
|
+
return UInt32.from(raw <= 0 ? 0 : Math.floor(raw) + 1)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function calc_gather_rate(
|
|
@@ -48,6 +48,7 @@ export function calc_gather_rate(
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export function calc_gather_energy(gatherer: GathererStats, duration: number): UInt32 {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (duration <= 0) return UInt32.from(0)
|
|
52
|
+
const raw = Math.floor((duration * gatherer.drain.toNumber()) / PRECISION)
|
|
53
|
+
return UInt32.from(Math.min(Math.max(raw, 1), 4294967295))
|
|
53
54
|
}
|
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
ITEM_CRAFTER_T1,
|
|
4
4
|
ITEM_ENGINE_T1,
|
|
5
5
|
ITEM_GATHERER_T1,
|
|
6
|
+
ITEM_GATHERER_T2,
|
|
6
7
|
ITEM_GENERATOR_T1,
|
|
7
8
|
ITEM_HAULER_T1,
|
|
9
|
+
ITEM_HAULER_T2,
|
|
8
10
|
ITEM_LAUNCHER_T1,
|
|
9
11
|
ITEM_LOADER_T1,
|
|
10
12
|
ITEM_STORAGE_T1,
|
|
@@ -44,6 +46,7 @@ export function getModuleCapabilityType(itemId: number): number {
|
|
|
44
46
|
case ITEM_GENERATOR_T1:
|
|
45
47
|
return MODULE_GENERATOR
|
|
46
48
|
case ITEM_GATHERER_T1:
|
|
49
|
+
case ITEM_GATHERER_T2:
|
|
47
50
|
return MODULE_GATHERER
|
|
48
51
|
case ITEM_LOADER_T1:
|
|
49
52
|
return MODULE_LOADER
|
|
@@ -52,6 +55,7 @@ export function getModuleCapabilityType(itemId: number): number {
|
|
|
52
55
|
case ITEM_STORAGE_T1:
|
|
53
56
|
return MODULE_STORAGE
|
|
54
57
|
case ITEM_HAULER_T1:
|
|
58
|
+
case ITEM_HAULER_T2:
|
|
55
59
|
return MODULE_HAULER
|
|
56
60
|
case ITEM_WARP_T1:
|
|
57
61
|
return MODULE_WARP
|