@shipload/sdk 1.0.0-next.75 → 1.0.0-next.76
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/scan.js +1 -1
- package/lib/scan.js.map +1 -1
- package/lib/scan.m.js +1 -1
- package/lib/scan.m.js.map +1 -1
- package/lib/shipload.d.ts +69 -35
- package/lib/shipload.js +13551 -11325
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +13532 -11325
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +20 -16
- package/lib/testing.js +214 -48
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +214 -48
- package/lib/testing.m.js.map +1 -1
- package/package.json +6 -6
- package/src/capabilities/storage.ts +45 -10
- package/src/contracts/server.ts +49 -41
- package/src/data/entities.json +367 -2
- package/src/data/item-ids.ts +15 -0
- package/src/data/items.json +90 -0
- package/src/data/kind-registry.json +97 -7
- package/src/data/metadata.ts +65 -0
- package/src/data/recipes-runtime.ts +1 -1
- package/src/data/recipes.json +1476 -10
- package/src/data/task-types.json +9 -0
- package/src/derivation/capabilities.test.ts +25 -2
- package/src/derivation/capabilities.ts +16 -3
- package/src/derivation/capacity-fn-registry.ts +8 -1
- package/src/derivation/reserve-regen.ts +5 -9
- package/src/derivation/stratum.ts +1 -1
- package/src/derivation/tiers.ts +1 -1
- package/src/derivation/upgrades.ts +5 -4
- package/src/index-module.ts +3 -0
- package/src/influence/influence.test.ts +1 -1
- package/src/managers/actions.ts +12 -19
- package/src/managers/entities.test.ts +23 -0
- package/src/managers/entities.ts +8 -1
- package/src/managers/shuttle.test.ts +67 -0
- package/src/managers/shuttle.ts +17 -0
- package/src/nft/description.ts +6 -0
- package/src/resolution/resolve-item.test.ts +6 -6
- package/src/scan/scan-wasm.base64.ts +1 -1
- package/src/scheduling/availability.test.ts +3 -3
- package/src/scheduling/availability.ts +3 -4
- package/src/scheduling/lanes.ts +1 -1
- package/src/scheduling/projection.ts +15 -13
- package/src/scheduling/schedule.test.ts +24 -0
- package/src/scheduling/schedule.ts +11 -4
- package/src/scheduling/task-effects.ts +3 -1
- package/src/scheduling/unwrap.test.ts +25 -6
- package/src/scheduling/unwrap.ts +19 -3
- package/src/travel/travel.ts +4 -0
- package/src/types.ts +2 -0
|
@@ -11,9 +11,20 @@ import {
|
|
|
11
11
|
import {TimePoint, UInt8, UInt16, UInt32, UInt64} from '@wharfkit/antelope'
|
|
12
12
|
import {ServerContract} from '../contracts'
|
|
13
13
|
import {getItem} from '../data/catalog'
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
ITEM_BEAM,
|
|
16
|
+
ITEM_ENGINE_T1,
|
|
17
|
+
ITEM_GENERATOR_T1,
|
|
18
|
+
ITEM_ROUSTABOUT_T1A_PACKED,
|
|
19
|
+
} from '../data/item-ids'
|
|
20
|
+
import {getBaseHullmassFor} from '../derivation/capabilities'
|
|
15
21
|
import {TaskType} from '../types'
|
|
16
22
|
|
|
23
|
+
const REFERENCE_MASS =
|
|
24
|
+
getBaseHullmassFor(ITEM_ROUSTABOUT_T1A_PACKED) +
|
|
25
|
+
Number(getItem(ITEM_ENGINE_T1).mass) +
|
|
26
|
+
Number(getItem(ITEM_GENERATOR_T1).mass)
|
|
27
|
+
|
|
17
28
|
describe('unwrap duration mirror', () => {
|
|
18
29
|
test('derivedLoaders aggregates lanes like derived_loaders()', () => {
|
|
19
30
|
expect(derivedLoaders([])).toBeNull()
|
|
@@ -25,12 +36,20 @@ describe('unwrap duration mirror', () => {
|
|
|
25
36
|
).toEqual({mass: 1200, thrust: 30, quantity: 2}) // floor(2400/2)=1200, sum thrust, count
|
|
26
37
|
})
|
|
27
38
|
|
|
28
|
-
test('transit floors distance
|
|
29
|
-
// distance
|
|
30
|
-
const
|
|
39
|
+
test('transit floors item mass at cruise-transition distance before cruise-capping flight time', () => {
|
|
40
|
+
// distance 50000 is past the cruise transition; item mass 1000 is under the floor, so accel uses it
|
|
41
|
+
const accel = (400 / (REFERENCE_MASS * 100)) * 10000
|
|
42
|
+
const cruiseVelocity = Math.sqrt(accel * 2 * 10000)
|
|
43
|
+
const expected = Math.floor(50000 / cruiseVelocity + cruiseVelocity / accel)
|
|
44
|
+
expect(unwrapTransitDuration(1000, {x: 0, y: 0}, {x: 3, y: 4})).toBe(expected)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('transit below cruise transition uses the sqrt curve, and a heavy item skips the mass floor', () => {
|
|
48
|
+
// distance 5000 is within the cruise transition
|
|
49
|
+
const mass = REFERENCE_MASS * 2
|
|
31
50
|
const accel = (400 / (mass * 100)) * 10000
|
|
32
|
-
const expected = Math.floor(2 * Math.sqrt(
|
|
33
|
-
expect(unwrapTransitDuration(mass, {x: 0, y: 0}, {x: 3, y: 4})).toBe(expected)
|
|
51
|
+
const expected = Math.floor(2 * Math.sqrt(5000 / accel))
|
|
52
|
+
expect(unwrapTransitDuration(mass, {x: 0, y: 0}, {x: 0.3, y: 0.4})).toBe(expected)
|
|
34
53
|
})
|
|
35
54
|
|
|
36
55
|
test('load uses altitude z, adds loader mass, divides by quantity', () => {
|
package/src/scheduling/unwrap.ts
CHANGED
|
@@ -2,11 +2,19 @@ import type {UInt16Type, UInt32Type} from '@wharfkit/antelope'
|
|
|
2
2
|
import {calcCargoItemMass} from '../capabilities/storage'
|
|
3
3
|
import type {ServerContract} from '../contracts'
|
|
4
4
|
import {MASS_STAT_SCALE, PRECISION} from '../types'
|
|
5
|
+
import {getBaseHullmassFor} from '../derivation/capabilities'
|
|
6
|
+
import {getItem} from '../data/catalog'
|
|
7
|
+
import {ITEM_ENGINE_T1, ITEM_GENERATOR_T1, ITEM_ROUSTABOUT_T1A_PACKED} from '../data/item-ids'
|
|
5
8
|
import * as sched from './schedule'
|
|
6
9
|
import {taskCargoEffect} from './availability'
|
|
7
10
|
import {candidateLaneCompletesAt} from './lanes'
|
|
8
11
|
|
|
9
12
|
const NFT_TRANSIT_THRUST = 400
|
|
13
|
+
const CRUISE_TRANSITION_DISTANCE = 2 * PRECISION
|
|
14
|
+
const NFT_TRANSIT_REFERENCE_MASS =
|
|
15
|
+
getBaseHullmassFor(ITEM_ROUSTABOUT_T1A_PACKED) +
|
|
16
|
+
Number(getItem(ITEM_ENGINE_T1).mass) +
|
|
17
|
+
Number(getItem(ITEM_GENERATOR_T1).mass)
|
|
10
18
|
const BASELINE_LOADER: DerivedLoaders = {mass: 20, thrust: 1, quantity: 1}
|
|
11
19
|
// ground-level entities (warehouses, z=0) still incur a base orbital climb of load effort
|
|
12
20
|
const MIN_LOAD_Z = 800
|
|
@@ -45,6 +53,13 @@ function flightTime(distance: number, accel: number): number {
|
|
|
45
53
|
return Math.floor(2 * Math.sqrt(distance / accel))
|
|
46
54
|
}
|
|
47
55
|
|
|
56
|
+
function travelFlightTime(distance: number, accel: number): number {
|
|
57
|
+
if (accel <= 0 || distance <= 0) return 0
|
|
58
|
+
if (distance <= CRUISE_TRANSITION_DISTANCE) return flightTime(distance, accel)
|
|
59
|
+
const cruiseVelocity = Math.sqrt(accel * CRUISE_TRANSITION_DISTANCE)
|
|
60
|
+
return Math.floor(distance / cruiseVelocity + cruiseVelocity / accel)
|
|
61
|
+
}
|
|
62
|
+
|
|
48
63
|
function distance2d(ax: number, ay: number, bx: number, by: number): number {
|
|
49
64
|
const dx = ax - bx
|
|
50
65
|
const dy = ay - by
|
|
@@ -57,9 +72,9 @@ export function unwrapTransitDuration(
|
|
|
57
72
|
dest: {x: number; y: number}
|
|
58
73
|
): number {
|
|
59
74
|
if (itemMass <= 0) return 0
|
|
60
|
-
return
|
|
75
|
+
return travelFlightTime(
|
|
61
76
|
distance2d(origin.x, origin.y, dest.x, dest.y),
|
|
62
|
-
acceleration(NFT_TRANSIT_THRUST, itemMass)
|
|
77
|
+
acceleration(NFT_TRANSIT_THRUST, Math.max(itemMass, NFT_TRANSIT_REFERENCE_MASS))
|
|
63
78
|
)
|
|
64
79
|
}
|
|
65
80
|
|
|
@@ -71,7 +86,8 @@ export function unwrapLoadDuration(
|
|
|
71
86
|
if (!loaders || itemMass <= 0) return 0
|
|
72
87
|
const total = itemMass + loaders.mass
|
|
73
88
|
const flight = flightTime(Math.max(destZ, MIN_LOAD_Z), acceleration(loaders.thrust, total))
|
|
74
|
-
|
|
89
|
+
const duration = Math.floor(flight / loaders.quantity)
|
|
90
|
+
return duration === 0 ? 1 : duration
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
export interface UnwrapItem {
|
package/src/travel/travel.ts
CHANGED
|
@@ -42,6 +42,7 @@ import {hasSystem} from '../utils/system'
|
|
|
42
42
|
import {WH} from '../derivation/wormhole'
|
|
43
43
|
import * as scheduleModel from '../scheduling/schedule'
|
|
44
44
|
import type {ScheduleData} from '../scheduling/schedule'
|
|
45
|
+
import {incomingHoldMass} from '../scheduling/unwrap'
|
|
45
46
|
|
|
46
47
|
function isPositionalTask(task: ServerContract.Types.task): boolean {
|
|
47
48
|
return task.type.equals(TaskType.TRAVEL) || task.type.equals(TaskType.TRANSIT)
|
|
@@ -273,6 +274,9 @@ export function calc_ship_mass(ship: ShipLike, cargos: CargoMassInfo[]): UInt64
|
|
|
273
274
|
mass.add(UInt64.from(cargoMass))
|
|
274
275
|
}
|
|
275
276
|
|
|
277
|
+
// barrier logic defers a mobility task past max_hold_until, so incoming cargo is aboard by departure
|
|
278
|
+
mass.add(UInt64.from(incomingHoldMass(ship.holds)))
|
|
279
|
+
|
|
276
280
|
return mass
|
|
277
281
|
}
|
|
278
282
|
|
package/src/types.ts
CHANGED
|
@@ -47,6 +47,7 @@ export interface ShipLike {
|
|
|
47
47
|
loader_lanes?: ServerContract.Types.loader_lane[]
|
|
48
48
|
hauler?: ServerContract.Types.hauler_stats
|
|
49
49
|
capacity?: UInt32
|
|
50
|
+
holds?: ServerContract.Types.hold[]
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export interface CargoMassInfo {
|
|
@@ -80,6 +81,7 @@ export enum TaskType {
|
|
|
80
81
|
DEPOT_TAKE = 22,
|
|
81
82
|
CIVIC_DEPOSIT = 21,
|
|
82
83
|
CIVIC_WITHDRAW = 22,
|
|
84
|
+
CIVIC_DRAW = 23,
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
export enum RefitOp {
|