@shipload/sdk 1.0.0-next.6 → 1.0.0-next.60

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 (155) hide show
  1. package/lib/scan.d.ts +52 -0
  2. package/lib/scan.js +162 -0
  3. package/lib/scan.js.map +1 -0
  4. package/lib/scan.m.js +152 -0
  5. package/lib/scan.m.js.map +1 -0
  6. package/lib/shipload.d.ts +3589 -1363
  7. package/lib/shipload.js +15700 -5454
  8. package/lib/shipload.js.map +1 -1
  9. package/lib/shipload.m.js +15423 -5402
  10. package/lib/shipload.m.js.map +1 -1
  11. package/lib/testing.d.ts +1173 -0
  12. package/lib/testing.js +4947 -0
  13. package/lib/testing.js.map +1 -0
  14. package/lib/testing.m.js +4941 -0
  15. package/lib/testing.m.js.map +1 -0
  16. package/package.json +20 -2
  17. package/src/capabilities/craftable.test.ts +82 -0
  18. package/src/capabilities/craftable.ts +82 -0
  19. package/src/capabilities/crafting.test.ts +35 -0
  20. package/src/capabilities/crafting.ts +34 -7
  21. package/src/capabilities/gathering.test.ts +29 -0
  22. package/src/capabilities/gathering.ts +37 -19
  23. package/src/capabilities/hauling.ts +0 -5
  24. package/src/capabilities/index.ts +0 -1
  25. package/src/capabilities/modules.ts +42 -0
  26. package/src/capabilities/movement.ts +1 -1
  27. package/src/capabilities/storage.ts +16 -1
  28. package/src/contracts/platform.ts +231 -3
  29. package/src/contracts/server.ts +1518 -501
  30. package/src/coordinates/address.ts +88 -0
  31. package/src/coordinates/constants.test.ts +15 -0
  32. package/src/coordinates/constants.ts +23 -0
  33. package/src/coordinates/index.ts +15 -0
  34. package/src/coordinates/memo.test.ts +47 -0
  35. package/src/coordinates/memo.ts +20 -0
  36. package/src/coordinates/permutation.ts +77 -0
  37. package/src/coordinates/regions.ts +48 -0
  38. package/src/coordinates/sectors.ts +115 -0
  39. package/src/data/capabilities.ts +49 -18
  40. package/src/data/capability-formulas.ts +26 -14
  41. package/src/data/catalog.ts +0 -5
  42. package/src/data/colors.ts +13 -47
  43. package/src/data/entities.json +379 -14
  44. package/src/data/item-ids.ts +48 -12
  45. package/src/data/items.json +301 -74
  46. package/src/data/kind-registry.json +195 -0
  47. package/src/data/kind-registry.ts +182 -0
  48. package/src/data/metadata.ts +277 -48
  49. package/src/data/recipes-runtime.ts +6 -23
  50. package/src/data/recipes.json +2074 -173
  51. package/src/derivation/build-methods.test.ts +13 -0
  52. package/src/derivation/build-methods.ts +48 -0
  53. package/src/derivation/capabilities.test.ts +348 -0
  54. package/src/derivation/capabilities.ts +692 -0
  55. package/src/derivation/capability-mappings.ts +60 -16
  56. package/src/derivation/crafting.test.ts +17 -0
  57. package/src/derivation/crafting.ts +56 -33
  58. package/src/derivation/index.ts +27 -2
  59. package/src/derivation/recipe-usage.test.ts +88 -0
  60. package/src/derivation/recipe-usage.ts +141 -0
  61. package/src/derivation/reserve-regen.ts +34 -0
  62. package/src/derivation/resources.ts +9 -1
  63. package/src/derivation/rollups.test.ts +55 -0
  64. package/src/derivation/rollups.ts +72 -0
  65. package/src/derivation/stars.test.ts +67 -0
  66. package/src/derivation/stars.ts +25 -0
  67. package/src/derivation/stat-scaling.ts +12 -0
  68. package/src/derivation/stats.ts +6 -6
  69. package/src/derivation/stratum.ts +26 -22
  70. package/src/derivation/tiers.ts +40 -7
  71. package/src/derivation/upgrades.ts +14 -0
  72. package/src/derivation/wormhole.ts +154 -0
  73. package/src/entities/entity.ts +102 -0
  74. package/src/entities/gamestate.ts +3 -28
  75. package/src/entities/makers.ts +141 -135
  76. package/src/entities/slot-multiplier.ts +43 -0
  77. package/src/errors.ts +12 -16
  78. package/src/format.ts +26 -4
  79. package/src/index-module.ts +333 -35
  80. package/src/managers/actions.ts +668 -103
  81. package/src/managers/base.ts +6 -2
  82. package/src/managers/cluster.test.ts +39 -0
  83. package/src/managers/cluster.ts +53 -0
  84. package/src/managers/construction-types.ts +80 -0
  85. package/src/managers/construction.ts +443 -0
  86. package/src/managers/context.ts +29 -1
  87. package/src/managers/coordinates.ts +14 -0
  88. package/src/managers/entities.ts +27 -66
  89. package/src/managers/epochs.ts +40 -0
  90. package/src/managers/index.ts +20 -1
  91. package/src/managers/locations.ts +25 -29
  92. package/src/managers/nft.test.ts +14 -0
  93. package/src/managers/nft.ts +70 -0
  94. package/src/managers/players.ts +25 -0
  95. package/src/managers/plot.ts +122 -0
  96. package/src/nft/atomicassets.abi.json +1342 -0
  97. package/src/nft/atomicassets.ts +237 -0
  98. package/src/nft/atomicdata.ts +130 -0
  99. package/src/nft/buildImmutableData.ts +385 -0
  100. package/src/nft/description.ts +225 -52
  101. package/src/nft/index.ts +3 -0
  102. package/src/planner/index.ts +242 -0
  103. package/src/planner/planner.test.ts +334 -0
  104. package/src/resolution/describe-module.ts +43 -25
  105. package/src/resolution/display-name.ts +38 -10
  106. package/src/resolution/resolve-item.test.ts +48 -0
  107. package/src/resolution/resolve-item.ts +112 -58
  108. package/src/scan/index.ts +244 -0
  109. package/src/scan/scan-wasm.base64.ts +2 -0
  110. package/src/scheduling/accessor.ts +65 -23
  111. package/src/scheduling/availability.test.ts +204 -0
  112. package/src/scheduling/availability.ts +211 -0
  113. package/src/scheduling/cancel.test.ts +542 -0
  114. package/src/scheduling/cancel.ts +254 -0
  115. package/src/scheduling/cluster-stock.test.ts +31 -0
  116. package/src/scheduling/cluster-stock.ts +15 -0
  117. package/src/scheduling/energy.ts +47 -0
  118. package/src/scheduling/idle-resolve.ts +45 -0
  119. package/src/scheduling/jobs.ts +71 -0
  120. package/src/scheduling/lane-core.ts +128 -0
  121. package/src/scheduling/lanes.test.ts +250 -0
  122. package/src/scheduling/lanes.ts +227 -0
  123. package/src/scheduling/projection.ts +257 -133
  124. package/src/scheduling/schedule.test.ts +119 -0
  125. package/src/scheduling/schedule.ts +257 -117
  126. package/src/scheduling/task-cargo.test.ts +44 -0
  127. package/src/scheduling/task-cargo.ts +46 -0
  128. package/src/scheduling/unwrap.test.ts +86 -0
  129. package/src/scheduling/unwrap.ts +190 -0
  130. package/src/shipload.ts +26 -1
  131. package/src/subscriptions/manager.cluster.test.ts +51 -0
  132. package/src/subscriptions/manager.ts +245 -172
  133. package/src/subscriptions/mappers.ts +5 -8
  134. package/src/subscriptions/types.ts +28 -3
  135. package/src/testing/catalog-hash.ts +19 -0
  136. package/src/testing/index.ts +2 -0
  137. package/src/testing/projection-parity.ts +167 -0
  138. package/src/travel/reach.ts +21 -0
  139. package/src/travel/route-planner.ts +288 -0
  140. package/src/travel/route-simulator.ts +170 -0
  141. package/src/travel/travel.ts +188 -122
  142. package/src/types/capabilities.ts +37 -8
  143. package/src/types/entity.ts +3 -3
  144. package/src/types/index.ts +0 -1
  145. package/src/types.ts +51 -16
  146. package/src/utils/cargo.test.ts +14 -0
  147. package/src/utils/cargo.ts +29 -0
  148. package/src/utils/display-name.ts +70 -0
  149. package/src/utils/system.ts +15 -16
  150. package/src/capabilities/loading.ts +0 -8
  151. package/src/entities/container.ts +0 -123
  152. package/src/entities/ship-deploy.ts +0 -295
  153. package/src/entities/ship.ts +0 -221
  154. package/src/entities/warehouse.ts +0 -127
  155. package/src/types/entity-traits.ts +0 -69
package/src/types.ts CHANGED
@@ -1,35 +1,47 @@
1
1
  import {
2
2
  type Int64Type,
3
- Name,
4
3
  type UInt16,
5
4
  type UInt16Type,
6
5
  type UInt32,
7
6
  type UInt32Type,
8
7
  UInt64,
8
+ type UInt64Type,
9
9
  } from '@wharfkit/antelope'
10
10
  import {ServerContract} from './contracts'
11
11
 
12
12
  export const PRECISION = 10000
13
13
  export const CRAFT_ENERGY_DIVISOR = 150000
14
14
 
15
- export const WAREHOUSE_Z = 500
15
+ export const PLANETARY_STRUCTURE_Z = 0
16
16
 
17
17
  export const CONTAINER_Z = 300
18
18
 
19
19
  export const TRAVEL_MAX_DURATION = 86400
20
20
 
21
+ export const BASE_HAUL_PENALTY_MILLI = 300
22
+ export const HAULER_EFFICIENCY_DENOM = 10000
23
+
21
24
  export const MIN_ORBITAL_ALTITUDE = 800
22
25
  export const MAX_ORBITAL_ALTITUDE = 3000
23
26
 
24
27
  export const BASE_ORBITAL_MASS = 100000
25
28
 
29
+ export const MIN_TRANSFER_DISTANCE_PLANETARY_STRUCTURE = 100
30
+ export const MIN_TRANSFER_DISTANCE_ORBITAL_VESSEL = 200
31
+
32
+ export interface ClusterSlotType {
33
+ hub: UInt64Type
34
+ gx: number
35
+ gy: number
36
+ }
37
+
26
38
  export interface ShipLike {
27
39
  coordinates: ServerContract.Types.coordinates
28
40
  hullmass?: UInt32
29
- energy?: UInt16
41
+ energy?: UInt32
30
42
  engines?: ServerContract.Types.movement_stats
31
43
  generator?: ServerContract.Types.energy_stats
32
- loaders?: ServerContract.Types.loader_stats
44
+ loader_lanes?: ServerContract.Types.loader_lane[]
33
45
  hauler?: ServerContract.Types.hauler_stats
34
46
  capacity?: UInt32
35
47
  }
@@ -48,12 +60,32 @@ export enum TaskType {
48
60
  GATHER = 5,
49
61
  WARP = 6,
50
62
  CRAFT = 7,
51
- DEPLOY = 8,
52
- WRAP = 9,
63
+ TRANSIT = 9,
53
64
  UNWRAP = 10,
54
65
  UNDEPLOY = 11,
55
- WRAP_ENTITY = 12,
66
+ LAUNCH = 12,
56
67
  DEMOLISH = 13,
68
+ BUILDPLOT = 15,
69
+ CHARGE = 16,
70
+ UPGRADE = 17,
71
+ SHUTTLE = 18,
72
+ REFIT = 19,
73
+ }
74
+
75
+ export enum RefitOp {
76
+ ADD = 0,
77
+ REMOVE = 1,
78
+ SWAP = 2,
79
+ }
80
+
81
+ export enum HoldKind {
82
+ PULL = 1,
83
+ PUSH = 2,
84
+ GATHER = 3,
85
+ BUILD = 4,
86
+ FLIGHT = 5,
87
+ UPGRADE = 6,
88
+ SOURCE = 7,
57
89
  }
58
90
 
59
91
  export enum LocationType {
@@ -70,14 +102,6 @@ export enum TaskCancelable {
70
102
  ALWAYS = 2,
71
103
  }
72
104
 
73
- export const EntityType = {
74
- SHIP: Name.from('ship'),
75
- WAREHOUSE: Name.from('warehouse'),
76
- CONTAINER: Name.from('container'),
77
- } as const
78
-
79
- export type EntityTypeName = (typeof EntityType)[keyof typeof EntityType]
80
-
81
105
  export type CoordinatesType =
82
106
  | Coordinates
83
107
  | ServerContract.Types.coordinates
@@ -123,11 +147,15 @@ export type ModuleType =
123
147
  | 'loader'
124
148
  | 'warp'
125
149
  | 'crafter'
150
+ | 'builder'
126
151
  | 'launcher'
127
152
  | 'storage'
128
153
  | 'hauler'
154
+ | 'battery'
155
+ | 'catcher'
156
+ | 'aux'
129
157
 
130
- export const TIER_ADJECTIVES: Record<number, string> = {
158
+ export const RESOURCE_TIER_ADJECTIVES: Record<number, string> = {
131
159
  1: 'Crude',
132
160
  2: 'Dense',
133
161
  3: 'Pure',
@@ -140,6 +168,9 @@ export const TIER_ADJECTIVES: Record<number, string> = {
140
168
  10: 'Ascendant',
141
169
  }
142
170
 
171
+ export const COMPONENT_TIER_PREFIXES: Record<number, string> = {}
172
+ export const MODULE_TIER_PREFIXES: Record<number, string> = {}
173
+
143
174
  export const CATEGORY_LABELS: Record<ResourceCategory, string> = {
144
175
  ore: 'Ore',
145
176
  crystal: 'Crystal',
@@ -163,3 +194,7 @@ export interface Item {
163
194
  export function formatTier(tier: number): string {
164
195
  return 'T' + tier
165
196
  }
197
+
198
+ export function tierAdjective(tier: number): string {
199
+ return RESOURCE_TIER_ADJECTIVES[tier] ?? `T${tier}`
200
+ }
@@ -0,0 +1,14 @@
1
+ import {describe, expect, test} from 'bun:test'
2
+ import {cargoRef} from './cargo'
3
+
4
+ describe('cargoRef', () => {
5
+ test('forwards entity_id when provided', () => {
6
+ const ref = cargoRef({item_id: 10201, stats: 196849n, modules: [], entity_id: 42n})
7
+ expect(ref.entity_id).toBe(42n)
8
+ })
9
+
10
+ test('omits entity_id when absent', () => {
11
+ const ref = cargoRef({item_id: 10201, stats: 196849n})
12
+ expect(ref.entity_id).toBeUndefined()
13
+ })
14
+ })
@@ -0,0 +1,29 @@
1
+ import type {ServerContract} from '../contracts'
2
+
3
+ export function cargoRef(src: {
4
+ item_id: number
5
+ stats: bigint | number
6
+ modules?: ServerContract.Types.module_entry[]
7
+ entity_id?: bigint | number
8
+ }): ServerContract.ActionParams.Type.cargo_ref {
9
+ return {
10
+ item_id: src.item_id,
11
+ stats: src.stats,
12
+ modules: src.modules ?? [],
13
+ entity_id: src.entity_id,
14
+ }
15
+ }
16
+
17
+ export function cargoItem(
18
+ src: {
19
+ item_id: number
20
+ stats: bigint | number
21
+ modules?: ServerContract.Types.module_entry[]
22
+ },
23
+ quantity: bigint | number
24
+ ): ServerContract.ActionParams.Type.cargo_item {
25
+ return {
26
+ ...cargoRef(src),
27
+ quantity,
28
+ }
29
+ }
@@ -0,0 +1,70 @@
1
+ export interface DisplayNameResult {
2
+ valid: boolean
3
+ reason?: string
4
+ name: string
5
+ }
6
+
7
+ const MAX_DISPLAY_NAME_BYTES = 32
8
+ const ASCII_SPACE = 0x20
9
+ const ZERO_WIDTH_CODE_POINTS = new Set([0x200b, 0x200c, 0x200d, 0x2060, 0xfeff])
10
+ const textEncoder = new TextEncoder()
11
+
12
+ function isControlCharacter(codePoint: number): boolean {
13
+ return codePoint <= 0x1f || codePoint === 0x7f || (codePoint >= 0x80 && codePoint <= 0x9f)
14
+ }
15
+
16
+ function isLoneSurrogate(codePoint: number): boolean {
17
+ return codePoint >= 0xd800 && codePoint <= 0xdfff
18
+ }
19
+
20
+ function isBidiControl(codePoint: number): boolean {
21
+ return (
22
+ (codePoint >= 0x202a && codePoint <= 0x202e) || (codePoint >= 0x2066 && codePoint <= 0x2069)
23
+ )
24
+ }
25
+
26
+ function isInvalidDisplayNameCodePoint(codePoint: number): boolean {
27
+ return (
28
+ isControlCharacter(codePoint) ||
29
+ isLoneSurrogate(codePoint) ||
30
+ ZERO_WIDTH_CODE_POINTS.has(codePoint) ||
31
+ isBidiControl(codePoint)
32
+ )
33
+ }
34
+
35
+ export function normalizeDisplayName(input: string): string {
36
+ let start = 0
37
+ let end = input.length
38
+
39
+ while (start < end && input.charCodeAt(start) === ASCII_SPACE) start++
40
+ while (end > start && input.charCodeAt(end - 1) === ASCII_SPACE) end--
41
+
42
+ return input.slice(start, end)
43
+ }
44
+
45
+ export interface ValidateDisplayNameOptions {
46
+ allowEmpty?: boolean
47
+ }
48
+
49
+ export function validateDisplayName(
50
+ input: string,
51
+ opts: ValidateDisplayNameOptions = {}
52
+ ): DisplayNameResult {
53
+ const name = normalizeDisplayName(input)
54
+
55
+ if (name.length === 0) {
56
+ return opts.allowEmpty ? {valid: true, name} : {valid: false, reason: 'empty', name}
57
+ }
58
+ if (textEncoder.encode(name).length > MAX_DISPLAY_NAME_BYTES) {
59
+ return {valid: false, reason: 'too_long', name}
60
+ }
61
+
62
+ for (const character of name) {
63
+ const codePoint = character.codePointAt(0)!
64
+ if (isInvalidDisplayNameCodePoint(codePoint)) {
65
+ return {valid: false, reason: 'invalid_char', name}
66
+ }
67
+ }
68
+
69
+ return {valid: true, name}
70
+ }
@@ -3,12 +3,12 @@ import {hash512} from './hash'
3
3
  import {Coordinates, type CoordinatesType, LocationType} from '../types'
4
4
  import {ServerContract} from '../contracts'
5
5
  import {deriveLocationSize} from '../derivation/location-size'
6
+ import {wormholeAt} from '../derivation/wormhole'
6
7
  import syllables from '../data/syllables.json'
7
8
  import nebulaAdjectives from '../data/nebula-adjectives.json'
8
9
  import nebulaNouns from '../data/nebula-nouns.json'
9
10
 
10
11
  const LOCATION_EXISTS_THRESHOLD = 0x10
11
- const LOCATION_ACTIVE_THRESHOLD = 0x80
12
12
 
13
13
  export function getLocationType(
14
14
  gameSeed: Checksum256Type,
@@ -111,6 +111,16 @@ export function hasSystem(gameSeed: Checksum256Type, coordinates: CoordinatesTyp
111
111
  return getLocationType(gameSeed, coordinates) !== LocationType.EMPTY
112
112
  }
113
113
 
114
+ export function getLocationKind(
115
+ gameSeed: Checksum256Type,
116
+ x: number,
117
+ y: number
118
+ ): 'wormhole' | 'system' | 'empty' {
119
+ if (wormholeAt(gameSeed, x, y)) return 'wormhole'
120
+ if (hasSystem(gameSeed, {x, y})) return 'system'
121
+ return 'empty'
122
+ }
123
+
114
124
  export function deriveLocationStatic(
115
125
  gameSeed: Checksum256Type,
116
126
  coordinates: CoordinatesType
@@ -151,31 +161,20 @@ export function deriveLocationStatic(
151
161
  return loc
152
162
  }
153
163
 
154
- export function deriveLocationEpoch(
155
- epochSeed: Checksum256Type,
164
+ export function isLocationBuildable(
165
+ gameSeed: Checksum256Type,
156
166
  coordinates: CoordinatesType
157
- ): ServerContract.Types.location_epoch {
158
- const seed = Checksum256.from(epochSeed)
159
- const coords = Coordinates.from(coordinates)
160
- const str = `system-epoch-${coords.x}-${coords.y}`
161
- const hashResult = hash512(seed, str)
162
-
163
- return ServerContract.Types.location_epoch.from({
164
- active: hashResult.array[0] < LOCATION_ACTIVE_THRESHOLD,
165
- seed0: hashResult.array[1],
166
- seed1: hashResult.array[2],
167
- })
167
+ ): boolean {
168
+ return getLocationType(gameSeed, coordinates) === LocationType.PLANET
168
169
  }
169
170
 
170
171
  export function deriveLocation(
171
172
  gameSeed: Checksum256Type,
172
- epochSeed: Checksum256Type,
173
173
  coordinates: CoordinatesType
174
174
  ): ServerContract.Types.location_derived {
175
175
  const staticProps = deriveLocationStatic(gameSeed, coordinates)
176
176
  return ServerContract.Types.location_derived.from({
177
177
  static_props: staticProps,
178
- epoch_props: deriveLocationEpoch(epochSeed, coordinates),
179
178
  size: deriveLocationSize(staticProps),
180
179
  })
181
180
  }
@@ -1,8 +0,0 @@
1
- import {UInt32, type UInt64} from '@wharfkit/antelope'
2
- import type {LoaderCapability} from '../types/capabilities'
3
-
4
- export function calcLoadDuration(entity: LoaderCapability, cargoMass: UInt64): UInt32 {
5
- const totalThrust = entity.loaders.thrust.toNumber() * entity.loaders.quantity.toNumber()
6
- if (totalThrust === 0) return UInt32.from(0)
7
- return UInt32.from(Math.ceil(Number(cargoMass) / totalThrust))
8
- }
@@ -1,123 +0,0 @@
1
- import {UInt64, type UInt64Type} from '@wharfkit/antelope'
2
- import {ServerContract} from '../contracts'
3
- import type {CoordinatesType} from '../types'
4
- import {type FloatPosition, getInterpolatedPosition} from '../travel/travel'
5
- import {Location} from './location'
6
- import {ScheduleAccessor} from '../scheduling/accessor'
7
- import * as schedule from '../scheduling/schedule'
8
-
9
- export interface ContainerStateInput {
10
- id: UInt64Type
11
- owner: string
12
- name: string
13
- coordinates: CoordinatesType | {x: number; y: number; z?: number}
14
- hullmass: number
15
- capacity: number
16
- cargomass?: number
17
- cargo?: ServerContract.Types.cargo_item[]
18
- schedule?: ServerContract.Types.schedule
19
- }
20
-
21
- export class Container extends ServerContract.Types.entity_info {
22
- private _sched?: ScheduleAccessor
23
-
24
- get name(): string {
25
- return this.entity_name
26
- }
27
-
28
- get entityClass(): 'mobile' {
29
- return 'mobile'
30
- }
31
-
32
- get canUndeploy(): boolean {
33
- return true
34
- }
35
-
36
- get sched(): ScheduleAccessor {
37
- this._sched ??= new ScheduleAccessor(this)
38
- return this._sched
39
- }
40
-
41
- get isIdle(): boolean {
42
- return this.is_idle
43
- }
44
-
45
- interpolatedPositionAt(now: Date): FloatPosition {
46
- const taskIndex = this.sched.currentTaskIndex(now)
47
- const progress = this.sched.currentTaskProgressFloat(now)
48
- return getInterpolatedPosition(this, taskIndex, progress)
49
- }
50
-
51
- isLoading(now: Date): boolean {
52
- return schedule.isLoading(this, now)
53
- }
54
-
55
- isUnloading(now: Date): boolean {
56
- return schedule.isUnloading(this, now)
57
- }
58
-
59
- get location(): Location {
60
- return Location.from(this.coordinates)
61
- }
62
-
63
- get totalMass(): UInt64 {
64
- return UInt64.from(this.hullmass ?? 0).adding(this.cargomass)
65
- }
66
-
67
- get maxCapacity(): UInt64 {
68
- return UInt64.from(this.capacity)
69
- }
70
-
71
- get availableCapacity(): UInt64 {
72
- const cargo = UInt64.from(this.cargomass)
73
- return cargo.gte(this.maxCapacity) ? UInt64.from(0) : this.maxCapacity.subtracting(cargo)
74
- }
75
-
76
- hasSpace(additionalMass: UInt64): boolean {
77
- return UInt64.from(this.cargomass).adding(additionalMass).lte(this.maxCapacity)
78
- }
79
-
80
- get isFull(): boolean {
81
- return UInt64.from(this.cargomass).gte(this.maxCapacity)
82
- }
83
-
84
- get orbitalAltitude(): number {
85
- return this.coordinates.z?.toNumber() || 0
86
- }
87
- }
88
-
89
- export function computeContainerCapabilities(stats: Record<string, number>): {
90
- hullmass: number
91
- capacity: number
92
- } {
93
- const density = stats.density
94
- const strength = stats.strength
95
- const hardness = stats.hardness
96
- const saturation = stats.saturation
97
-
98
- const hullmass = 25000 + 75 * density
99
-
100
- const statSum = strength + hardness + saturation
101
- const exponent = statSum / 2997
102
- const capacity = Math.floor(1000000 * 10 ** exponent)
103
-
104
- return {hullmass, capacity}
105
- }
106
-
107
- export function computeContainerT2Capabilities(stats: Record<string, number>): {
108
- hullmass: number
109
- capacity: number
110
- } {
111
- const strength = stats.strength
112
- const density = stats.density
113
- const hardness = stats.hardness
114
- const saturation = stats.saturation
115
-
116
- const hullmass = 20000 + 50 * density
117
-
118
- const statSum = strength + hardness + saturation
119
- const exponent = statSum / 2500
120
- const capacity = Math.floor(1500000 * 10 ** exponent)
121
-
122
- return {hullmass, capacity}
123
- }