@shipload/sdk 0.7.0 → 1.0.0-beta1

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 (95) hide show
  1. package/lib/shipload.d.ts +2730 -287
  2. package/lib/shipload.js +10862 -2228
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +10434 -2170
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +11 -20
  7. package/src/capabilities/crafting.ts +22 -0
  8. package/src/capabilities/gathering.ts +36 -0
  9. package/src/capabilities/guards.ts +38 -0
  10. package/src/capabilities/hauling.ts +22 -0
  11. package/src/capabilities/index.ts +8 -0
  12. package/src/capabilities/loading.ts +8 -0
  13. package/src/capabilities/modules.ts +86 -0
  14. package/src/capabilities/movement.ts +29 -0
  15. package/src/capabilities/storage.ts +159 -0
  16. package/src/contracts/platform.ts +30 -30
  17. package/src/contracts/server.ts +1387 -283
  18. package/src/data/capabilities.ts +408 -0
  19. package/src/data/catalog.ts +135 -0
  20. package/src/data/categories.ts +55 -0
  21. package/src/data/colors.ts +84 -0
  22. package/src/data/entities.json +50 -0
  23. package/src/data/item-ids.ts +75 -0
  24. package/src/data/items.json +252 -0
  25. package/src/data/locations.ts +53 -0
  26. package/src/data/metadata.ts +208 -0
  27. package/src/data/nebula-adjectives.json +211 -0
  28. package/src/data/nebula-nouns.json +151 -0
  29. package/src/data/recipes-runtime.ts +65 -0
  30. package/src/data/recipes.json +878 -0
  31. package/src/data/syllables.json +1790 -0
  32. package/src/data/tiers.ts +45 -0
  33. package/src/derivation/crafting.ts +350 -0
  34. package/src/derivation/index.ts +32 -0
  35. package/src/derivation/location-size.ts +15 -0
  36. package/src/derivation/resources.ts +112 -0
  37. package/src/derivation/stats.ts +146 -0
  38. package/src/derivation/strata.ts +43 -0
  39. package/src/derivation/stratum.ts +134 -0
  40. package/src/derivation/tiers.ts +54 -0
  41. package/src/entities/cargo-utils.ts +84 -0
  42. package/src/entities/container.ts +108 -0
  43. package/src/entities/entity-inventory.ts +39 -0
  44. package/src/entities/gamestate.ts +152 -0
  45. package/src/entities/inventory-accessor.ts +42 -0
  46. package/src/entities/location.ts +60 -0
  47. package/src/entities/makers.ts +196 -0
  48. package/src/entities/player.ts +15 -0
  49. package/src/entities/ship-deploy.ts +258 -0
  50. package/src/entities/ship.ts +204 -0
  51. package/src/entities/warehouse.ts +119 -0
  52. package/src/errors.ts +100 -9
  53. package/src/format.ts +12 -0
  54. package/src/index-module.ts +317 -7
  55. package/src/managers/actions.ts +250 -0
  56. package/src/managers/base.ts +25 -0
  57. package/src/managers/context.ts +114 -0
  58. package/src/managers/entities.ts +103 -0
  59. package/src/managers/epochs.ts +47 -0
  60. package/src/managers/index.ts +9 -0
  61. package/src/managers/locations.ts +68 -0
  62. package/src/managers/players.ts +13 -0
  63. package/src/nft/description.ts +176 -0
  64. package/src/nft/deserializers.ts +83 -0
  65. package/src/nft/index.ts +2 -0
  66. package/src/resolution/describe-module.ts +166 -0
  67. package/src/resolution/display-name.ts +39 -0
  68. package/src/resolution/resolve-item.ts +358 -0
  69. package/src/scheduling/accessor.ts +82 -0
  70. package/src/{epoch.ts → scheduling/epoch.ts} +1 -1
  71. package/src/scheduling/projection.ts +463 -0
  72. package/src/scheduling/schedule.ts +179 -0
  73. package/src/shipload.ts +47 -160
  74. package/src/subscriptions/connection.ts +154 -0
  75. package/src/subscriptions/debug.ts +17 -0
  76. package/src/subscriptions/index.ts +5 -0
  77. package/src/subscriptions/manager.ts +240 -0
  78. package/src/subscriptions/mappers.ts +28 -0
  79. package/src/subscriptions/types.ts +143 -0
  80. package/src/travel/travel.ts +500 -0
  81. package/src/types/capabilities.ts +76 -0
  82. package/src/types/entity-traits.ts +69 -0
  83. package/src/types/entity.ts +39 -0
  84. package/src/types/index.ts +3 -0
  85. package/src/types.ts +140 -35
  86. package/src/{hash.ts → utils/hash.ts} +2 -2
  87. package/src/utils/system.ts +168 -0
  88. package/src/goods.ts +0 -124
  89. package/src/market.ts +0 -214
  90. package/src/rolls.ts +0 -8
  91. package/src/ship.ts +0 -36
  92. package/src/state.ts +0 -0
  93. package/src/syllables.ts +0 -1184
  94. package/src/system.ts +0 -36
  95. package/src/travel.ts +0 -259
@@ -0,0 +1,204 @@
1
+ import {type UInt16, type UInt16Type, UInt32, UInt64, type UInt64Type} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import {Coordinates, type CoordinatesType} from '../types'
4
+ import {
5
+ getDestinationLocation,
6
+ getPositionAt,
7
+ getFlightOrigin as travelGetFlightOrigin,
8
+ } from '../travel/travel'
9
+ import {
10
+ type ProjectedEntity,
11
+ projectFromCurrentState as sharedProjectFromCurrentState,
12
+ projectFromCurrentStateAt as sharedProjectFromCurrentStateAt,
13
+ } from '../scheduling/projection'
14
+ import {Location} from './location'
15
+ import {ScheduleAccessor} from '../scheduling/accessor'
16
+ import {InventoryAccessor} from './inventory-accessor'
17
+ import type {EntityInventory} from './entity-inventory'
18
+ import {
19
+ energyPercent as calcEnergyPercent,
20
+ needsRecharge as calcNeedsRecharge,
21
+ hasEnergyForDistance,
22
+ maxTravelDistance,
23
+ } from '../capabilities/movement'
24
+ import * as schedule from '../scheduling/schedule'
25
+
26
+ export interface PackedModuleInput {
27
+ itemId: UInt16Type
28
+ stats: UInt64Type
29
+ }
30
+
31
+ export interface ShipStateInput {
32
+ id: UInt64Type
33
+ owner: string
34
+ name: string
35
+ coordinates: CoordinatesType | {x: number; y: number; z?: number}
36
+ hullmass?: number
37
+ capacity?: number
38
+ energy?: number
39
+ modules?: PackedModuleInput[]
40
+ schedule?: ServerContract.Types.schedule
41
+ cargo?: ServerContract.Types.cargo_item[]
42
+ }
43
+
44
+ type MovementEntity = {
45
+ engines: ServerContract.Types.movement_stats
46
+ generator: ServerContract.Types.energy_stats
47
+ energy: UInt16
48
+ }
49
+
50
+ export class Ship extends ServerContract.Types.entity_info {
51
+ private _sched?: ScheduleAccessor
52
+ private _inv?: InventoryAccessor
53
+
54
+ get name(): string {
55
+ return this.entity_name
56
+ }
57
+
58
+ get inv(): InventoryAccessor {
59
+ this._inv ??= new InventoryAccessor(this)
60
+ return this._inv
61
+ }
62
+
63
+ get inventory(): EntityInventory[] {
64
+ return this.inv.items
65
+ }
66
+
67
+ get sched(): ScheduleAccessor {
68
+ this._sched ??= new ScheduleAccessor(this)
69
+ return this._sched
70
+ }
71
+
72
+ get maxDistance(): UInt32 {
73
+ if (!this.generator || !this.engines) return UInt32.from(0)
74
+ return maxTravelDistance(this as MovementEntity)
75
+ }
76
+
77
+ get isIdle(): boolean {
78
+ return this.is_idle
79
+ }
80
+
81
+ getFlightOrigin(flightTaskIndex: number): Coordinates {
82
+ return Coordinates.from(travelGetFlightOrigin(this, flightTaskIndex))
83
+ }
84
+
85
+ destinationLocation(): Coordinates | undefined {
86
+ const dest = getDestinationLocation(this)
87
+ return dest ? Coordinates.from(dest) : undefined
88
+ }
89
+
90
+ positionAt(now: Date): Coordinates {
91
+ const taskIndex = this.sched.currentTaskIndex(now)
92
+ const progress = this.sched.currentTaskProgress(now)
93
+ return Coordinates.from(getPositionAt(this, taskIndex, progress))
94
+ }
95
+
96
+ isInFlight(now: Date): boolean {
97
+ return schedule.isInFlight(this, now)
98
+ }
99
+
100
+ isRecharging(now: Date): boolean {
101
+ return schedule.isRecharging(this, now)
102
+ }
103
+
104
+ isLoading(now: Date): boolean {
105
+ return schedule.isLoading(this, now)
106
+ }
107
+
108
+ isUnloading(now: Date): boolean {
109
+ return schedule.isUnloading(this, now)
110
+ }
111
+
112
+ isGathering(now: Date): boolean {
113
+ return schedule.isGathering(this, now)
114
+ }
115
+
116
+ get hasEngines(): boolean {
117
+ return this.engines !== undefined
118
+ }
119
+
120
+ get hasGenerator(): boolean {
121
+ return this.generator !== undefined
122
+ }
123
+
124
+ get hasGatherer(): boolean {
125
+ return this.gatherer !== undefined
126
+ }
127
+
128
+ get hasWarp(): boolean {
129
+ return this.warp !== undefined
130
+ }
131
+
132
+ project(): ProjectedEntity {
133
+ return sharedProjectFromCurrentState(this)
134
+ }
135
+
136
+ projectAt(now: Date): ProjectedEntity {
137
+ return sharedProjectFromCurrentStateAt(this, now)
138
+ }
139
+
140
+ get location(): Location {
141
+ return Location.from(this.coordinates)
142
+ }
143
+
144
+ get totalCargoMass(): UInt64 {
145
+ return this.inv.totalMass
146
+ }
147
+
148
+ get totalMass(): UInt64 {
149
+ let mass = UInt64.from(this.hullmass ?? 0).adding(this.totalCargoMass)
150
+ if (this.loaders) {
151
+ mass = mass.adding(UInt64.from(this.loaders.mass).multiplying(this.loaders.quantity))
152
+ }
153
+ return mass
154
+ }
155
+
156
+ get maxCapacity(): UInt64 {
157
+ return UInt64.from(this.capacity)
158
+ }
159
+
160
+ hasSpace(goodMass: UInt64, quantity: number): boolean {
161
+ return this.totalMass.adding(goodMass.multiplying(quantity)).lte(this.maxCapacity)
162
+ }
163
+
164
+ get availableCapacity(): UInt64 {
165
+ return this.totalMass.gte(this.maxCapacity)
166
+ ? UInt64.from(0)
167
+ : this.maxCapacity.subtracting(this.totalMass)
168
+ }
169
+
170
+ getCargoForItem(goodId: UInt64Type): EntityInventory | undefined {
171
+ return this.inv.forItem(goodId)
172
+ }
173
+
174
+ get sellableCargo(): EntityInventory[] {
175
+ return this.inv.sellable
176
+ }
177
+
178
+ get hasSellableCargo(): boolean {
179
+ return this.inv.hasSellable
180
+ }
181
+
182
+ get sellableGoodsCount(): number {
183
+ return this.inv.sellableCount
184
+ }
185
+
186
+ get isFull(): boolean {
187
+ return this.totalMass.gte(this.maxCapacity)
188
+ }
189
+
190
+ get energyPercent(): number {
191
+ if (!this.generator || this.energy === undefined) return 0
192
+ return calcEnergyPercent(this as MovementEntity)
193
+ }
194
+
195
+ get needsRecharge(): boolean {
196
+ if (!this.generator || this.energy === undefined) return false
197
+ return calcNeedsRecharge(this as MovementEntity)
198
+ }
199
+
200
+ hasEnergyFor(distance: UInt64): boolean {
201
+ if (!this.engines || !this.generator || this.energy === undefined) return false
202
+ return hasEnergyForDistance(this as MovementEntity, distance)
203
+ }
204
+ }
@@ -0,0 +1,119 @@
1
+ import {UInt64, type UInt64Type} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import type {CoordinatesType} from '../types'
4
+ import {Location} from './location'
5
+ import {ScheduleAccessor} from '../scheduling/accessor'
6
+ import {InventoryAccessor} from './inventory-accessor'
7
+ import type {EntityInventory} from './entity-inventory'
8
+ import * as schedule from '../scheduling/schedule'
9
+ import type {PackedModuleInput} from './ship'
10
+ import {decodeCraftedItemStats} from '../derivation/crafting'
11
+ import {getModuleCapabilityType, MODULE_LOADER} from '../capabilities/modules'
12
+ import {computeLoaderCapabilities} from './ship-deploy'
13
+
14
+ export interface WarehouseStateInput {
15
+ id: UInt64Type
16
+ owner: string
17
+ name: string
18
+ coordinates: CoordinatesType | {x: number; y: number; z?: number}
19
+ hullmass?: number
20
+ capacity: number
21
+ modules?: PackedModuleInput[]
22
+ schedule?: ServerContract.Types.schedule
23
+ cargo?: ServerContract.Types.cargo_item[]
24
+ }
25
+
26
+ export class Warehouse extends ServerContract.Types.entity_info {
27
+ private _sched?: ScheduleAccessor
28
+ private _inv?: InventoryAccessor
29
+
30
+ get name(): string {
31
+ return this.entity_name
32
+ }
33
+
34
+ get inv(): InventoryAccessor {
35
+ this._inv ??= new InventoryAccessor(this)
36
+ return this._inv
37
+ }
38
+
39
+ get inventory(): EntityInventory[] {
40
+ return this.inv.items
41
+ }
42
+
43
+ get sched(): ScheduleAccessor {
44
+ this._sched ??= new ScheduleAccessor(this)
45
+ return this._sched
46
+ }
47
+
48
+ get isIdle(): boolean {
49
+ return this.is_idle
50
+ }
51
+
52
+ isLoading(now: Date): boolean {
53
+ return schedule.isLoading(this, now)
54
+ }
55
+
56
+ isUnloading(now: Date): boolean {
57
+ return schedule.isUnloading(this, now)
58
+ }
59
+
60
+ get location(): Location {
61
+ return Location.from(this.coordinates)
62
+ }
63
+
64
+ get totalCargoMass(): UInt64 {
65
+ return this.inv.totalMass
66
+ }
67
+
68
+ get maxCapacity(): UInt64 {
69
+ return UInt64.from(this.capacity)
70
+ }
71
+
72
+ get availableCapacity(): UInt64 {
73
+ const cargo = this.totalCargoMass
74
+ return cargo.gte(this.maxCapacity) ? UInt64.from(0) : this.maxCapacity.subtracting(cargo)
75
+ }
76
+
77
+ hasSpace(goodMass: UInt64, quantity: number): boolean {
78
+ return this.totalCargoMass.adding(goodMass.multiplying(quantity)).lte(this.maxCapacity)
79
+ }
80
+
81
+ get isFull(): boolean {
82
+ return this.totalCargoMass.gte(this.maxCapacity)
83
+ }
84
+
85
+ getCargoForItem(goodId: UInt64Type): EntityInventory | undefined {
86
+ return this.inv.forItem(goodId)
87
+ }
88
+
89
+ get orbitalAltitude(): number {
90
+ return this.coordinates.z?.toNumber() || 0
91
+ }
92
+
93
+ get totalMass(): UInt64 {
94
+ const hull = this.hullmass ? UInt64.from(this.hullmass) : UInt64.from(0)
95
+ return hull.adding(this.totalCargoMass)
96
+ }
97
+ }
98
+
99
+ export function computeWarehouseCapabilities(modules: {itemId: number; stats: bigint}[]): {
100
+ loaders?: {mass: number; thrust: number; quantity: number}
101
+ } {
102
+ const warehouse: {loaders?: {mass: number; thrust: number; quantity: number}} = {}
103
+
104
+ const loaderModules = modules.filter((m) => getModuleCapabilityType(m.itemId) === MODULE_LOADER)
105
+ if (loaderModules.length > 0) {
106
+ let totalMass = 0
107
+ let totalThrust = 0
108
+ let totalQuantity = 0
109
+ for (const m of loaderModules) {
110
+ const caps = computeLoaderCapabilities(decodeCraftedItemStats(m.itemId, m.stats))
111
+ totalMass += caps.mass
112
+ totalThrust += caps.thrust
113
+ totalQuantity += caps.quantity
114
+ }
115
+ warehouse.loaders = {mass: totalMass, thrust: totalThrust, quantity: totalQuantity}
116
+ }
117
+
118
+ return warehouse
119
+ }
package/src/errors.ts CHANGED
@@ -1,9 +1,100 @@
1
- export const ERROR_SYSTEM_NOT_INITIALIZED = 'System not initialized'
2
- export const GOOD_DOES_NOT_EXIST = 'Good does not exist'
3
- export const GOOD_NOT_AVAILABLE_AT_LOCATION = 'Good not available at location'
4
- export const PLAYER_NOT_FOUND = 'Player not found'
5
- export const SHIP_NOT_FOUND = 'Ship not found'
6
- export const SHIP_CANNOT_BUY_TRAVELING = 'Ship cannot buy while traveling'
7
- export const INSUFFICIENT_BALANCE = 'Insufficient balance'
8
- export const INSUFFICIENT_GOOD_QUANTITY = 'Insufficient good quantity'
9
- export const REQUIRES_MORE_THAN_ONE = 'Requires more than one'
1
+ export const COMPANY_NOT_FOUND = 'Cannot find company for given account.'
2
+ export const COMMIT_ALREADY_SET = 'Commit has already been set.'
3
+ export const COMMIT_CANNOT_MATCH = 'Next commit cannot match current commit.'
4
+ export const COMMIT_NOT_SET = 'Commit has not been set.'
5
+ export const EPOCH_NON_ZERO = 'Epoch must be greater than zero.'
6
+ export const EPOCH_NOT_READY = 'Current epoch is not ready to advance'
7
+ export const ERROR_SYSTEM_ALREADY_INITIALIZED = 'This game has already been initialized.'
8
+ export const ERROR_SYSTEM_DISABLED = 'This game is currently disabled.'
9
+ export const ERROR_SYSTEM_NOT_INITIALIZED = 'This game has not been initialized.'
10
+ export const GAME_NOT_FOUND = 'Cannot find game for given account name.'
11
+ export const GAME_SEED_NOT_SET = 'This game has not initialized an epoch seed value.'
12
+ export const ITEM_DOES_NOT_EXIST = 'Item does not exist.'
13
+ export const INVALID_AMOUNT = 'Invalid amount.'
14
+ export const REQUIRES_MORE_THAN_ONE = 'A value greater than one is required.'
15
+ export const REQUIRES_POSITIVE_VALUE = 'Value must be greater than zero.'
16
+ export const PLAYER_ALREADY_JOINED = 'Player has already joined the game.'
17
+ export const PLAYER_NOT_JOINED = 'Player has not joined the game.'
18
+ export const PLAYER_NOT_FOUND = 'Cannot find player for given account name.'
19
+ export const STARTER_ALREADY_CLAIMED =
20
+ 'Starter ship already claimed; destroy existing ships to re-claim.'
21
+ export const SHIP_ALREADY_THERE = 'Ship cannot travel to the location its already at.'
22
+ export const SHIP_ALREADY_TRAVELING = 'Ship is already traveling.'
23
+ export const SHIP_CANNOT_BUY_TRAVELING = 'Ship cannot buy goods while traveling.'
24
+ export const SHIP_CANNOT_UPDATE_TRAVELING = 'Ship cannot be updated while traveling.'
25
+ export const SHIP_INVALID_DESTINATION = 'Ship cannot travel, no system at specified destination.'
26
+ export const SHIP_INVALID_TRAVEL_DURATION =
27
+ 'This trip cannot be made as it would exceed the maximum travel duration.'
28
+ export const SHIP_NOT_ARRIVED = 'Ship has not yet arrived at its destination.'
29
+ export const SHIP_NOT_ENOUGH_ENERGY =
30
+ 'Ship does not have enough energy to travel to the destination.'
31
+ export const SHIP_NOT_ENOUGH_ENERGY_CAPACITY =
32
+ 'Ship does not have enough energy capacity to travel.'
33
+ export const SHIP_NOT_FOUND = 'Cannot find ship for given account.'
34
+ export const SHIP_NOT_OWNED = 'Ship is not owned by this account.'
35
+ export const NO_SCHEDULE = 'No scheduled tasks.'
36
+ export const SHIP_NOT_IDLE = 'Ship must be idle (no active schedule) for this action.'
37
+ export const SHIP_NO_COMPLETED_TASKS = 'No completed tasks to resolve.'
38
+ export const RESOLVE_COUNT_EXCEEDS_COMPLETED = 'Requested resolve count exceeds completed tasks.'
39
+ export const SHIP_CANNOT_CANCEL_TASK = 'Cannot cancel task that is immutable or in progress.'
40
+ export const SHIP_NO_TASKS_TO_CANCEL = 'No tasks to cancel.'
41
+ export const SHIP_INVALID_CARGO = 'Invalid cargo specified for load/unload.'
42
+ export const SHIP_CARGO_NOT_OWNED = 'Cannot load cargo that is not owned.'
43
+ export const SHIP_CARGO_NOT_LOADED = 'Cannot unload cargo that is not loaded.'
44
+ export const SHIP_CAPACITY_EXCEEDED = 'Ship cargo capacity would be exceeded.'
45
+ export const ENTITY_CAPACITY_EXCEEDED = 'Entity cargo capacity would be exceeded.'
46
+ export const WAREHOUSE_NOT_FOUND = 'Cannot find warehouse for given id.'
47
+ export const WAREHOUSE_ALREADY_AT_LOCATION = 'Warehouse already exists at this location.'
48
+ export const WAREHOUSE_CAPACITY_EXCEEDED = 'Warehouse capacity would be exceeded.'
49
+ export const CONTAINER_NOT_FOUND = 'Cannot find container for given id.'
50
+ export const CONTAINER_CAPACITY_EXCEEDED = 'Container capacity would be exceeded.'
51
+ export const DESTINATION_CAPACITY_EXCEEDED =
52
+ 'Destination entity does not have enough capacity for the gather.'
53
+ export const CANCEL_PAIRED_HAS_PENDING = 'Cannot cancel transfer, paired entity has pending tasks.'
54
+ export const GROUP_EMPTY = 'Group travel requires at least one entity.'
55
+ export const GROUP_NO_THRUST = 'Group travel requires at least one entity with engines.'
56
+ export const GROUP_NOT_SAME_LOCATION = 'All entities must be at the same location for group travel.'
57
+ export const GROUP_NOT_SAME_OWNER = 'All entities must have the same owner for group travel.'
58
+ export const GROUP_ENTITY_NOT_MOVABLE = 'Entity cannot participate in group travel.'
59
+ export const GROUP_NOT_FOUND = 'Entity group not found.'
60
+ export const GROUP_DUPLICATE_ENTITY = 'Duplicate entity in group.'
61
+ export const GROUP_HAUL_CAPACITY_EXCEEDED =
62
+ 'Group travel requires sufficient hauler capacity for all non-self-propelled entities.'
63
+ export const CANCEL_CONTAINS_GROUPED_TASK =
64
+ 'Cannot cancel range containing grouped task - cancel non-grouped tasks first.'
65
+ export const WARP_NO_CAPABILITY = 'Entity does not have warp capability.'
66
+ export const WARP_HAS_SCHEDULE = 'Entity must be idle to warp.'
67
+ export const WARP_HAS_CARGO = 'Entity must have no cargo to warp.'
68
+ export const WARP_NOT_FULL_ENERGY = 'Entity must have full energy to warp.'
69
+ export const WARP_OUT_OF_RANGE = 'Destination exceeds warp range.'
70
+
71
+ export const ENTITY_NO_CRAFTER = 'Entity does not have crafting capability.'
72
+ export const RECIPE_NOT_FOUND = 'Recipe does not exist.'
73
+ export const RECIPE_INPUTS_INSUFFICIENT = 'Insufficient inputs for recipe.'
74
+ export const RECIPE_INPUTS_INVALID = 'Input cargo does not match recipe requirements.'
75
+ export const RECIPE_INPUTS_EXCESS = 'Provided inputs exceed recipe requirements.'
76
+ export const RECIPE_INPUTS_MIXED = 'All stacks for a recipe input must be the same resource.'
77
+ export const ITEM_NOT_DEPLOYABLE = 'Item cannot be deployed as an entity.'
78
+ export const DEPLOY_ENTITY_HAS_SCHEDULE = 'Entity must be idle to deploy.'
79
+ export const BLEND_INPUTS_MUST_MATCH = 'All blend inputs must be the same item.'
80
+ export const GATHER_NOT_ENOUGH_ENERGY = 'Gather requires more energy than entity has.'
81
+ export const GATHER_EXCEEDS_ENERGY_CAPACITY = "Gather drain exceeds entity's energy capacity."
82
+ export const CRAFT_NOT_ENOUGH_ENERGY = 'Craft requires more energy than entity has.'
83
+ export const CRAFT_EXCEEDS_ENERGY_CAPACITY = "Craft drain exceeds entity's energy capacity."
84
+ export const BLEND_REQUIRES_MULTIPLE = 'Blend requires at least two input stacks.'
85
+ export const BLEND_STAT_LESS_NOT_SUPPORTED = 'Stat-less items cannot be blended.'
86
+
87
+ export const MODULE_SLOT_INVALID = 'Module slot index is invalid.'
88
+ export const MODULE_SLOT_OCCUPIED = 'Module slot is already occupied.'
89
+ export const MODULE_SLOT_EMPTY = 'Module slot is empty.'
90
+ export const MODULE_TYPE_MISMATCH = 'Module type not allowed in this slot.'
91
+ export const MODULE_CARGO_NOT_FOUND = 'Module cargo not found.'
92
+ export const MODULE_NOT_MODULE = 'Item is not a module.'
93
+ export const MODULE_ENTITY_BUSY = 'Entity must be idle to modify modules.'
94
+ export const ITEM_NOT_PACKED_ENTITY = 'Item is not a packed entity.'
95
+
96
+ // SDK-only market errors (no contract counterpart yet)
97
+ export const ITEM_NOT_AVAILABLE_AT_LOCATION = 'Item is not tradeable at ship location.'
98
+ export const INSUFFICIENT_BALANCE = 'Insufficient balance.'
99
+ export const INSUFFICIENT_ITEM_QUANTITY = 'Insufficient quantity in cargo.'
100
+ export const INSUFFICIENT_ITEM_SUPPLY = 'Insufficient supply of item at location.'
package/src/format.ts ADDED
@@ -0,0 +1,12 @@
1
+ export function formatMass(kg: number): string {
2
+ const t = kg / 1000
3
+ const fixed = t.toFixed(2)
4
+ const trimmed = fixed.replace(/\.?0+$/, '')
5
+ return `${trimmed} t`
6
+ }
7
+
8
+ export function formatMassDelta(kg: number): string {
9
+ if (kg === 0) return '0 t'
10
+ const sign = kg > 0 ? '+' : '-'
11
+ return `${sign}${formatMass(Math.abs(kg))}`
12
+ }