@shipload/sdk 0.7.1 → 2.0.0-rc10

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 (79) hide show
  1. package/lib/shipload.d.ts +2203 -288
  2. package/lib/shipload.js +8441 -2210
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +8160 -2167
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +7 -6
  7. package/src/capabilities/crafting.ts +26 -0
  8. package/src/capabilities/extraction.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 +57 -0
  14. package/src/capabilities/movement.ts +29 -0
  15. package/src/capabilities/storage.ts +72 -0
  16. package/src/contracts/server.ts +1217 -254
  17. package/src/data/capabilities.ts +408 -0
  18. package/src/data/categories.ts +58 -0
  19. package/src/data/colors.ts +52 -0
  20. package/src/data/items.json +17 -0
  21. package/src/data/locations.ts +53 -0
  22. package/src/data/nebula-adjectives.json +211 -0
  23. package/src/data/nebula-nouns.json +151 -0
  24. package/src/data/recipes.ts +571 -0
  25. package/src/data/syllables.json +1790 -0
  26. package/src/data/tiers.ts +45 -0
  27. package/src/derivation/crafting.ts +197 -0
  28. package/src/derivation/index.ts +28 -0
  29. package/src/derivation/location-size.ts +15 -0
  30. package/src/derivation/resources.ts +142 -0
  31. package/src/derivation/stats.ts +146 -0
  32. package/src/derivation/stratum.ts +118 -0
  33. package/src/entities/cargo-utils.ts +84 -0
  34. package/src/entities/container.ts +106 -0
  35. package/src/entities/entity-inventory.ts +39 -0
  36. package/src/entities/gamestate.ts +152 -0
  37. package/src/entities/inventory-accessor.ts +42 -0
  38. package/src/entities/location.ts +60 -0
  39. package/src/entities/makers.ts +72 -0
  40. package/src/entities/player.ts +15 -0
  41. package/src/entities/ship-deploy.ts +263 -0
  42. package/src/entities/ship.ts +199 -0
  43. package/src/entities/warehouse.ts +91 -0
  44. package/src/errors.ts +46 -9
  45. package/src/index-module.ts +302 -7
  46. package/src/managers/actions.ts +197 -0
  47. package/src/managers/base.ts +25 -0
  48. package/src/managers/context.ts +95 -0
  49. package/src/managers/entities.ts +103 -0
  50. package/src/managers/epochs.ts +47 -0
  51. package/src/managers/index.ts +8 -0
  52. package/src/managers/locations.ts +39 -0
  53. package/src/managers/players.ts +13 -0
  54. package/src/market/items.ts +30 -0
  55. package/src/nft/description.ts +175 -0
  56. package/src/nft/deserializers.ts +81 -0
  57. package/src/nft/index.ts +2 -0
  58. package/src/resolution/resolve-item.ts +313 -0
  59. package/src/scheduling/accessor.ts +82 -0
  60. package/src/{epoch.ts → scheduling/epoch.ts} +1 -1
  61. package/src/scheduling/projection.ts +322 -0
  62. package/src/scheduling/schedule.ts +179 -0
  63. package/src/shipload.ts +36 -159
  64. package/src/travel/travel.ts +499 -0
  65. package/src/types/capabilities.ts +71 -0
  66. package/src/types/entity-traits.ts +69 -0
  67. package/src/types/entity.ts +39 -0
  68. package/src/types/index.ts +3 -0
  69. package/src/types.ts +113 -35
  70. package/src/{hash.ts → utils/hash.ts} +1 -1
  71. package/src/utils/system.ts +155 -0
  72. package/src/goods.ts +0 -124
  73. package/src/market.ts +0 -214
  74. package/src/rolls.ts +0 -8
  75. package/src/ship.ts +0 -36
  76. package/src/state.ts +0 -0
  77. package/src/syllables.ts +0 -1184
  78. package/src/system.ts +0 -37
  79. package/src/travel.ts +0 -259
@@ -0,0 +1,263 @@
1
+ import {decodeCraftedItemStats} from '../derivation/crafting'
2
+ import {
3
+ getModuleCapabilityType,
4
+ MODULE_CRAFTER,
5
+ MODULE_ENGINE,
6
+ MODULE_EXTRACTOR,
7
+ MODULE_GENERATOR,
8
+ MODULE_HAULER,
9
+ MODULE_LOADER,
10
+ } from '../capabilities/modules'
11
+
12
+ export function computeShipHullCapabilities(stats: Record<string, number>): {
13
+ hullmass: number
14
+ capacity: number
15
+ } {
16
+ const density = stats.density ?? 500
17
+ const strength = stats.strength ?? 500
18
+ const ductility = stats.ductility ?? 500
19
+ const purity = stats.purity ?? 500
20
+
21
+ const hullmass = 25000 + 75 * density
22
+ const statSum = strength + ductility + purity
23
+ const exponent = statSum / 2997.0
24
+ const capacity = Math.floor(1000000 * Math.pow(10, exponent))
25
+
26
+ return {hullmass, capacity}
27
+ }
28
+
29
+ export function computeEngineCapabilities(stats: Record<string, number>): {
30
+ thrust: number
31
+ drain: number
32
+ } {
33
+ const vol = stats.volatility ?? 500
34
+ const thm = stats.thermal ?? 500
35
+
36
+ return {
37
+ thrust: 400 + Math.floor((vol * 3) / 4),
38
+ drain: Math.max(30, 50 - Math.floor(thm / 70)),
39
+ }
40
+ }
41
+
42
+ export function computeGeneratorCapabilities(stats: Record<string, number>): {
43
+ capacity: number
44
+ recharge: number
45
+ } {
46
+ const res = stats.resonance ?? 500
47
+ const clr = stats.clarity ?? 500
48
+
49
+ return {
50
+ capacity: 300 + Math.floor(res / 6),
51
+ recharge: 5 + Math.floor((clr * 15) / 1000),
52
+ }
53
+ }
54
+
55
+ export function computeExtractorCapabilities(stats: Record<string, number>): {
56
+ rate: number
57
+ drain: number
58
+ depth: number
59
+ drill: number
60
+ } {
61
+ const str = stats.strength ?? 500
62
+ const con = stats.conductivity ?? 500
63
+ const ref = stats.reflectivity ?? 500
64
+ const tol = stats.tolerance ?? 500
65
+
66
+ return {
67
+ rate: 200 + str,
68
+ drain: Math.max(10, 50 - Math.floor(con / 20)),
69
+ depth: 200 + Math.floor((tol * 3) / 2),
70
+ drill: 100 + Math.floor((ref * 4) / 5),
71
+ }
72
+ }
73
+
74
+ export function computeLoaderCapabilities(stats: Record<string, number>): {
75
+ mass: number
76
+ thrust: number
77
+ quantity: number
78
+ } {
79
+ const duc = stats.ductility ?? 500
80
+ const pla = stats.plasticity ?? 500
81
+
82
+ return {
83
+ mass: Math.max(200, 2000 - Math.floor(duc * 2)),
84
+ thrust: 1 + Math.floor(pla / 500),
85
+ quantity: 1,
86
+ }
87
+ }
88
+
89
+ export function computeManufacturingCapabilities(stats: Record<string, number>): {
90
+ speed: number
91
+ drain: number
92
+ } {
93
+ const rea = stats.reactivity ?? 500
94
+ const clr = stats.clarity ?? 500
95
+
96
+ return {
97
+ speed: 100 + Math.floor((rea * 4) / 5),
98
+ drain: Math.max(5, 30 - Math.floor(clr / 33)),
99
+ }
100
+ }
101
+
102
+ export function computeHaulerCapabilities(stats: Record<string, number>): {
103
+ capacity: number
104
+ efficiency: number
105
+ drain: number
106
+ } {
107
+ const res = stats.resonance ?? 500
108
+ const con = stats.conductivity ?? 500
109
+ const clr = stats.clarity ?? 500
110
+
111
+ return {
112
+ capacity: Math.max(1, 1 + Math.floor(res / 400)),
113
+ efficiency: 2000 + con * 6,
114
+ drain: Math.max(3, 15 - Math.floor(clr / 80)),
115
+ }
116
+ }
117
+
118
+ export function computeStorageCapabilities(
119
+ stats: Record<string, number>,
120
+ baseCapacity: number
121
+ ): {
122
+ capacityBonus: number
123
+ } {
124
+ const strength = stats.strength ?? 500
125
+ const ductility = stats.ductility ?? 500
126
+ const purity = stats.purity ?? 500
127
+
128
+ const statSum = strength + ductility + purity
129
+ const capacityBonus = Math.floor(
130
+ (baseCapacity * (10 + Math.floor((statSum * 10) / 2997))) / 100
131
+ )
132
+
133
+ return {capacityBonus}
134
+ }
135
+
136
+ export function computeWarehouseHullCapabilities(stats: Record<string, number>): {
137
+ hullmass: number
138
+ capacity: number
139
+ } {
140
+ const density = stats.density ?? 500
141
+ const strength = stats.strength ?? 500
142
+ const ductility = stats.ductility ?? 500
143
+ const purity = stats.purity ?? 500
144
+
145
+ const hullmass = 25000 + 75 * density
146
+ const statSum = strength + ductility + purity
147
+ const exponent = statSum / 2997.0
148
+ const capacity = Math.floor(20000000 * Math.pow(10, exponent))
149
+
150
+ return {hullmass, capacity}
151
+ }
152
+
153
+ export interface ShipCapabilities {
154
+ engines?: {thrust: number; drain: number}
155
+ generator?: {capacity: number; recharge: number}
156
+ extractor?: {rate: number; drain: number; depth: number; drill: number}
157
+ hauler?: {capacity: number; efficiency: number; drain: number}
158
+ loaders?: {mass: number; thrust: number; quantity: number}
159
+ crafter?: {speed: number; drain: number}
160
+ }
161
+
162
+ export function computeShipCapabilities(
163
+ modules: {itemId: number; seed: bigint}[]
164
+ ): ShipCapabilities {
165
+ const ship: ShipCapabilities = {}
166
+
167
+ const engineModules = modules.filter((m) => getModuleCapabilityType(m.itemId) === MODULE_ENGINE)
168
+ if (engineModules.length > 0) {
169
+ let totalThrust = 0
170
+ let totalDrain = 0
171
+ for (const m of engineModules) {
172
+ const caps = computeEngineCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
173
+ totalThrust += caps.thrust
174
+ totalDrain += caps.drain
175
+ }
176
+ ship.engines = {thrust: totalThrust, drain: totalDrain}
177
+ }
178
+
179
+ const generatorModules = modules.filter(
180
+ (m) => getModuleCapabilityType(m.itemId) === MODULE_GENERATOR
181
+ )
182
+ if (generatorModules.length > 0) {
183
+ let totalCapacity = 0
184
+ let totalRecharge = 0
185
+ for (const m of generatorModules) {
186
+ const caps = computeGeneratorCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
187
+ totalCapacity += caps.capacity
188
+ totalRecharge += caps.recharge
189
+ }
190
+ ship.generator = {capacity: totalCapacity, recharge: totalRecharge}
191
+ }
192
+
193
+ const extractorModules = modules.filter(
194
+ (m) => getModuleCapabilityType(m.itemId) === MODULE_EXTRACTOR
195
+ )
196
+ if (extractorModules.length > 0) {
197
+ let totalRate = 0
198
+ let totalDrain = 0
199
+ let totalDepth = 0
200
+ let totalDrill = 0
201
+ for (const m of extractorModules) {
202
+ const caps = computeExtractorCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
203
+ totalRate += caps.rate
204
+ totalDrain += caps.drain
205
+ totalDepth += caps.depth
206
+ totalDrill += caps.drill
207
+ }
208
+ ship.extractor = {rate: totalRate, drain: totalDrain, depth: totalDepth, drill: totalDrill}
209
+ }
210
+
211
+ const haulerModules = modules.filter((m) => getModuleCapabilityType(m.itemId) === MODULE_HAULER)
212
+ if (haulerModules.length > 0) {
213
+ let totalCapacity = 0
214
+ let weightedEffNum = 0
215
+ let totalDrain = 0
216
+ for (const m of haulerModules) {
217
+ const decoded = decodeCraftedItemStats(m.itemId, m.seed)
218
+ const caps = computeHaulerCapabilities({
219
+ resonance: decoded.capacity,
220
+ conductivity: decoded.efficiency,
221
+ clarity: decoded.drain,
222
+ })
223
+ totalCapacity += caps.capacity
224
+ weightedEffNum += caps.efficiency * caps.capacity
225
+ totalDrain += caps.drain
226
+ }
227
+ ship.hauler = {
228
+ capacity: totalCapacity,
229
+ efficiency: totalCapacity > 0 ? Math.floor(weightedEffNum / totalCapacity) : 0,
230
+ drain: totalDrain,
231
+ }
232
+ }
233
+
234
+ const loaderModules = modules.filter((m) => getModuleCapabilityType(m.itemId) === MODULE_LOADER)
235
+ if (loaderModules.length > 0) {
236
+ let totalMass = 0
237
+ let totalThrust = 0
238
+ let totalQuantity = 0
239
+ for (const m of loaderModules) {
240
+ const caps = computeLoaderCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
241
+ totalMass += caps.mass
242
+ totalThrust += caps.thrust
243
+ totalQuantity += caps.quantity
244
+ }
245
+ ship.loaders = {mass: totalMass, thrust: totalThrust, quantity: totalQuantity}
246
+ }
247
+
248
+ const crafterModules = modules.filter(
249
+ (m) => getModuleCapabilityType(m.itemId) === MODULE_CRAFTER
250
+ )
251
+ if (crafterModules.length > 0) {
252
+ let totalSpeed = 0
253
+ let totalDrain = 0
254
+ for (const m of crafterModules) {
255
+ const caps = computeManufacturingCapabilities(decodeCraftedItemStats(m.itemId, m.seed))
256
+ totalSpeed += caps.speed
257
+ totalDrain += caps.drain
258
+ }
259
+ ship.crafter = {speed: totalSpeed, drain: totalDrain}
260
+ }
261
+
262
+ return ship
263
+ }
@@ -0,0 +1,199 @@
1
+ import {UInt16, UInt32, UInt64, UInt64Type} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import {Coordinates, CoordinatesType} from '../types'
4
+ import {
5
+ getDestinationLocation,
6
+ getPositionAt,
7
+ getFlightOrigin as travelGetFlightOrigin,
8
+ } from '../travel/travel'
9
+ import {
10
+ ProjectedEntity,
11
+ projectEntity as sharedProjectEntity,
12
+ projectEntityAt as sharedProjectEntityAt,
13
+ } from '../scheduling/projection'
14
+ import {Location} from './location'
15
+ import {ScheduleAccessor} from '../scheduling/accessor'
16
+ import {InventoryAccessor} from './inventory-accessor'
17
+ import {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 ShipStateInput {
27
+ id: UInt64Type
28
+ owner: string
29
+ name: string
30
+ coordinates: CoordinatesType | {x: number; y: number; z?: number}
31
+ hullmass?: number
32
+ capacity?: number
33
+ energy?: number
34
+ engines?: ServerContract.Types.movement_stats
35
+ generator?: ServerContract.Types.energy_stats
36
+ loaders?: ServerContract.Types.loader_stats
37
+ schedule?: ServerContract.Types.schedule
38
+ cargo?: ServerContract.Types.cargo_item[]
39
+ }
40
+
41
+ type MovementEntity = {
42
+ engines: ServerContract.Types.movement_stats
43
+ generator: ServerContract.Types.energy_stats
44
+ energy: UInt16
45
+ }
46
+
47
+ export class Ship extends ServerContract.Types.entity_info {
48
+ private _sched?: ScheduleAccessor
49
+ private _inv?: InventoryAccessor
50
+
51
+ get name(): string {
52
+ return this.entity_name
53
+ }
54
+
55
+ get inv(): InventoryAccessor {
56
+ return (this._inv ??= new InventoryAccessor(this))
57
+ }
58
+
59
+ get inventory(): EntityInventory[] {
60
+ return this.inv.items
61
+ }
62
+
63
+ get sched(): ScheduleAccessor {
64
+ return (this._sched ??= new ScheduleAccessor(this))
65
+ }
66
+
67
+ get maxDistance(): UInt32 {
68
+ if (!this.generator || !this.engines) return UInt32.from(0)
69
+ return maxTravelDistance(this as MovementEntity)
70
+ }
71
+
72
+ get isIdle(): boolean {
73
+ return this.is_idle
74
+ }
75
+
76
+ getFlightOrigin(flightTaskIndex: number): Coordinates {
77
+ return Coordinates.from(travelGetFlightOrigin(this, flightTaskIndex))
78
+ }
79
+
80
+ destinationLocation(): Coordinates | undefined {
81
+ const dest = getDestinationLocation(this)
82
+ return dest ? Coordinates.from(dest) : undefined
83
+ }
84
+
85
+ positionAt(now: Date): Coordinates {
86
+ const taskIndex = this.sched.currentTaskIndex(now)
87
+ const progress = this.sched.currentTaskProgress(now)
88
+ return Coordinates.from(getPositionAt(this, taskIndex, progress))
89
+ }
90
+
91
+ isInFlight(now: Date): boolean {
92
+ return schedule.isInFlight(this, now)
93
+ }
94
+
95
+ isRecharging(now: Date): boolean {
96
+ return schedule.isRecharging(this, now)
97
+ }
98
+
99
+ isLoading(now: Date): boolean {
100
+ return schedule.isLoading(this, now)
101
+ }
102
+
103
+ isUnloading(now: Date): boolean {
104
+ return schedule.isUnloading(this, now)
105
+ }
106
+
107
+ isExtracting(now: Date): boolean {
108
+ return schedule.isExtracting(this, now)
109
+ }
110
+
111
+ get hasEngines(): boolean {
112
+ return this.engines !== undefined
113
+ }
114
+
115
+ get hasGenerator(): boolean {
116
+ return this.generator !== undefined
117
+ }
118
+
119
+ get hasExtractor(): boolean {
120
+ return this.extractor !== undefined
121
+ }
122
+
123
+ get hasWarp(): boolean {
124
+ return this.warp !== undefined
125
+ }
126
+
127
+ project(): ProjectedEntity {
128
+ return sharedProjectEntity(this)
129
+ }
130
+
131
+ projectAt(now: Date): ProjectedEntity {
132
+ return sharedProjectEntityAt(this, now)
133
+ }
134
+
135
+ get location(): Location {
136
+ return Location.from(this.coordinates)
137
+ }
138
+
139
+ get totalCargoMass(): UInt64 {
140
+ return this.inv.totalMass
141
+ }
142
+
143
+ get totalMass(): UInt64 {
144
+ let mass = UInt64.from(this.hullmass ?? 0).adding(this.totalCargoMass)
145
+ if (this.loaders) {
146
+ mass = mass.adding(UInt64.from(this.loaders.mass).multiplying(this.loaders.quantity))
147
+ }
148
+ return mass
149
+ }
150
+
151
+ get maxCapacity(): UInt64 {
152
+ return UInt64.from(this.capacity)
153
+ }
154
+
155
+ hasSpace(goodMass: UInt64, quantity: number): boolean {
156
+ return this.totalMass.adding(goodMass.multiplying(quantity)).lte(this.maxCapacity)
157
+ }
158
+
159
+ get availableCapacity(): UInt64 {
160
+ return this.totalMass.gte(this.maxCapacity)
161
+ ? UInt64.from(0)
162
+ : this.maxCapacity.subtracting(this.totalMass)
163
+ }
164
+
165
+ getCargoForItem(goodId: UInt64Type): EntityInventory | undefined {
166
+ return this.inv.forItem(goodId)
167
+ }
168
+
169
+ get sellableCargo(): EntityInventory[] {
170
+ return this.inv.sellable
171
+ }
172
+
173
+ get hasSellableCargo(): boolean {
174
+ return this.inv.hasSellable
175
+ }
176
+
177
+ get sellableGoodsCount(): number {
178
+ return this.inv.sellableCount
179
+ }
180
+
181
+ get isFull(): boolean {
182
+ return this.totalMass.gte(this.maxCapacity)
183
+ }
184
+
185
+ get energyPercent(): number {
186
+ if (!this.generator || this.energy === undefined) return 0
187
+ return calcEnergyPercent(this as MovementEntity)
188
+ }
189
+
190
+ get needsRecharge(): boolean {
191
+ if (!this.generator || this.energy === undefined) return false
192
+ return calcNeedsRecharge(this as MovementEntity)
193
+ }
194
+
195
+ hasEnergyFor(distance: UInt64): boolean {
196
+ if (!this.engines || !this.generator || this.energy === undefined) return false
197
+ return hasEnergyForDistance(this as MovementEntity, distance)
198
+ }
199
+ }
@@ -0,0 +1,91 @@
1
+ import {UInt64, UInt64Type} from '@wharfkit/antelope'
2
+ import {ServerContract} from '../contracts'
3
+ import {CoordinatesType} from '../types'
4
+ import {Location} from './location'
5
+ import {ScheduleAccessor} from '../scheduling/accessor'
6
+ import {InventoryAccessor} from './inventory-accessor'
7
+ import {EntityInventory} from './entity-inventory'
8
+ import * as schedule from '../scheduling/schedule'
9
+
10
+ export interface WarehouseStateInput {
11
+ id: UInt64Type
12
+ owner: string
13
+ name: string
14
+ coordinates: CoordinatesType | {x: number; y: number; z?: number}
15
+ hullmass?: number
16
+ capacity: number
17
+ loaders?: ServerContract.Types.loader_stats
18
+ schedule?: ServerContract.Types.schedule
19
+ cargo?: ServerContract.Types.cargo_item[]
20
+ }
21
+
22
+ export class Warehouse extends ServerContract.Types.entity_info {
23
+ private _sched?: ScheduleAccessor
24
+ private _inv?: InventoryAccessor
25
+
26
+ get name(): string {
27
+ return this.entity_name
28
+ }
29
+
30
+ get inv(): InventoryAccessor {
31
+ return (this._inv ??= new InventoryAccessor(this))
32
+ }
33
+
34
+ get inventory(): EntityInventory[] {
35
+ return this.inv.items
36
+ }
37
+
38
+ get sched(): ScheduleAccessor {
39
+ return (this._sched ??= new ScheduleAccessor(this))
40
+ }
41
+
42
+ get isIdle(): boolean {
43
+ return this.is_idle
44
+ }
45
+
46
+ isLoading(now: Date): boolean {
47
+ return schedule.isLoading(this, now)
48
+ }
49
+
50
+ isUnloading(now: Date): boolean {
51
+ return schedule.isUnloading(this, now)
52
+ }
53
+
54
+ get location(): Location {
55
+ return Location.from(this.coordinates)
56
+ }
57
+
58
+ get totalCargoMass(): UInt64 {
59
+ return this.inv.totalMass
60
+ }
61
+
62
+ get maxCapacity(): UInt64 {
63
+ return UInt64.from(this.capacity)
64
+ }
65
+
66
+ get availableCapacity(): UInt64 {
67
+ const cargo = this.totalCargoMass
68
+ return cargo.gte(this.maxCapacity) ? UInt64.from(0) : this.maxCapacity.subtracting(cargo)
69
+ }
70
+
71
+ hasSpace(goodMass: UInt64, quantity: number): boolean {
72
+ return this.totalCargoMass.adding(goodMass.multiplying(quantity)).lte(this.maxCapacity)
73
+ }
74
+
75
+ get isFull(): boolean {
76
+ return this.totalCargoMass.gte(this.maxCapacity)
77
+ }
78
+
79
+ getCargoForItem(goodId: UInt64Type): EntityInventory | undefined {
80
+ return this.inv.forItem(goodId)
81
+ }
82
+
83
+ get orbitalAltitude(): number {
84
+ return this.coordinates.z?.toNumber() || 0
85
+ }
86
+
87
+ get totalMass(): UInt64 {
88
+ const hull = this.hullmass ? UInt64.from(this.hullmass) : UInt64.from(0)
89
+ return hull.adding(this.totalCargoMass)
90
+ }
91
+ }
package/src/errors.ts CHANGED
@@ -1,9 +1,46 @@
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 ITEM_NOT_AVAILABLE_AT_LOCATION = 'Item is not tradeable at ship location.'
14
+ export const INSUFFICIENT_BALANCE = 'Insufficient balance.'
15
+ export const INSUFFICIENT_ITEM_QUANTITY = 'Insufficient quantity in cargo.'
16
+ export const INSUFFICIENT_ITEM_SUPPLY = 'Insufficient supply of item at location.'
17
+ export const INVALID_AMOUNT = 'Invalid amount.'
18
+ export const REQUIRES_MORE_THAN_ONE = 'A value greater than one is required.'
19
+ export const REQUIRES_POSITIVE_VALUE = 'Value must be greater than zero.'
20
+ export const PLAYER_ALREADY_JOINED = 'Player has already joined the game.'
21
+ export const PLAYER_NOT_FOUND = 'Cannot find player for given account name.'
22
+ export const SHIP_ALREADY_THERE = 'Ship cannot travel to the location its already at.'
23
+ export const SHIP_ALREADY_TRAVELING = 'Ship is already traveling.'
24
+ export const SHIP_CANNOT_BUY_TRAVELING = 'Ship cannot buy goods while traveling.'
25
+ export const SHIP_CANNOT_UPDATE_TRAVELING = 'Ship cannot be updated while traveling.'
26
+ export const SHIP_INVALID_DESTINATION = 'Ship cannot travel, no system at specified destination.'
27
+ export const SHIP_INVALID_TRAVEL_DURATION =
28
+ 'This trip cannot be made as it would exceed the maximum travel duration.'
29
+ export const SHIP_NOT_ARRIVED = 'Ship has not yet arrived at its destination.'
30
+ export const SHIP_NOT_ENOUGH_ENERGY =
31
+ 'Ship does not have enough energy to travel to the destination.'
32
+ export const SHIP_NOT_ENOUGH_ENERGY_CAPACITY =
33
+ 'Ship does not have enough energy capacity to travel.'
34
+ export const SHIP_NOT_FOUND = 'Cannot find ship for given account.'
35
+ export const SHIP_NOT_OWNED = 'Ship is not owned by this account.'
36
+ export const NO_SCHEDULE = 'No scheduled tasks.'
37
+ export const SHIP_NOT_IDLE = 'Ship must be idle (no active schedule) for this action.'
38
+ export const SHIP_NO_COMPLETED_TASKS = 'No completed tasks to resolve.'
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 WAREHOUSE_NOT_FOUND = 'Cannot find warehouse for given id.'
45
+ export const WAREHOUSE_ALREADY_AT_LOCATION = 'Warehouse already exists at this location.'
46
+ export const WAREHOUSE_CAPACITY_EXCEEDED = 'Warehouse capacity would be exceeded.'