@shipload/sdk 1.0.0-next.0 → 1.0.0-next.10

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 (51) hide show
  1. package/lib/shipload.d.ts +512 -320
  2. package/lib/shipload.js +1960 -1060
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +1920 -1056
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +8 -3
  7. package/src/capabilities/modules.ts +3 -0
  8. package/src/capabilities/storage.ts +1 -1
  9. package/src/contracts/platform.ts +13 -1
  10. package/src/contracts/server.ts +227 -282
  11. package/src/data/capabilities.ts +5 -330
  12. package/src/data/capability-formulas.ts +70 -0
  13. package/src/data/catalog.ts +0 -5
  14. package/src/data/colors.ts +2 -16
  15. package/src/data/entities.json +33 -10
  16. package/src/data/item-ids.ts +3 -1
  17. package/src/data/items.json +258 -0
  18. package/src/data/metadata.ts +57 -1
  19. package/src/data/recipes-runtime.ts +1 -0
  20. package/src/data/recipes.json +82 -11
  21. package/src/derivation/capability-mappings.ts +122 -0
  22. package/src/derivation/index.ts +1 -0
  23. package/src/derivation/resources.ts +116 -37
  24. package/src/derivation/stats.ts +1 -2
  25. package/src/entities/container.ts +25 -10
  26. package/src/entities/extractor.ts +144 -0
  27. package/src/entities/gamestate.ts +0 -9
  28. package/src/entities/makers.ts +71 -20
  29. package/src/entities/ship-deploy.ts +114 -56
  30. package/src/entities/ship.ts +17 -0
  31. package/src/entities/slot-multiplier.ts +21 -0
  32. package/src/entities/warehouse.ts +20 -3
  33. package/src/index-module.ts +67 -26
  34. package/src/managers/actions.ts +53 -80
  35. package/src/managers/entities.ts +31 -17
  36. package/src/managers/locations.ts +2 -20
  37. package/src/nft/atomicdata.ts +125 -0
  38. package/src/nft/description.ts +41 -7
  39. package/src/nft/index.ts +1 -0
  40. package/src/resolution/resolve-item.ts +17 -9
  41. package/src/scheduling/accessor.ts +4 -0
  42. package/src/scheduling/projection.ts +8 -0
  43. package/src/scheduling/schedule.ts +15 -1
  44. package/src/scheduling/task-cargo.ts +47 -0
  45. package/src/subscriptions/connection.ts +50 -2
  46. package/src/subscriptions/manager.ts +81 -2
  47. package/src/travel/travel.ts +61 -2
  48. package/src/types/entity-traits.ts +64 -1
  49. package/src/types.ts +11 -1
  50. package/src/utils/cargo.ts +27 -0
  51. package/src/utils/system.ts +25 -24
@@ -0,0 +1,27 @@
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
+ }): ServerContract.ActionParams.Type.cargo_ref {
8
+ return {
9
+ item_id: src.item_id,
10
+ stats: src.stats,
11
+ modules: src.modules ?? [],
12
+ }
13
+ }
14
+
15
+ export function cargoItem(
16
+ src: {
17
+ item_id: number
18
+ stats: bigint | number
19
+ modules?: ServerContract.Types.module_entry[]
20
+ },
21
+ quantity: bigint | number
22
+ ): ServerContract.ActionParams.Type.cargo_item {
23
+ return {
24
+ ...cargoRef(src),
25
+ quantity,
26
+ }
27
+ }
@@ -8,7 +8,6 @@ import nebulaAdjectives from '../data/nebula-adjectives.json'
8
8
  import nebulaNouns from '../data/nebula-nouns.json'
9
9
 
10
10
  const LOCATION_EXISTS_THRESHOLD = 0x10
11
- const LOCATION_ACTIVE_THRESHOLD = 0x80
12
11
 
13
12
  export function getLocationType(
14
13
  gameSeed: Checksum256Type,
@@ -22,12 +21,10 @@ export function getLocationType(
22
21
  return LocationType.EMPTY
23
22
  }
24
23
 
25
- if (hashResult.array[1] < 96) {
26
- return LocationType.PLANET
27
- } else if (hashResult.array[1] < 176) {
28
- return LocationType.ASTEROID
29
- }
30
- return LocationType.NEBULA
24
+ if (hashResult.array[1] < 96) return LocationType.PLANET
25
+ if (hashResult.array[1] < 149) return LocationType.ASTEROID
26
+ if (hashResult.array[1] < 202) return LocationType.NEBULA
27
+ return LocationType.ICE_FIELD
31
28
  }
32
29
 
33
30
  export function isGatherableLocation(locationType: LocationType): boolean {
@@ -44,6 +41,8 @@ export function getLocationTypeName(type: LocationType): string {
44
41
  return 'Asteroid'
45
42
  case LocationType.NEBULA:
46
43
  return 'Nebula'
44
+ case LocationType.ICE_FIELD:
45
+ return 'Ice Field'
47
46
  }
48
47
  }
49
48
 
@@ -76,6 +75,15 @@ function generateNebulaName(hashResult: Checksum512): string {
76
75
  return `${nebulaAdjectives[adjIdx]} ${nebulaNouns[nounIdx]}`
77
76
  }
78
77
 
78
+ function generateIceFieldName(hashResult: Checksum512): string {
79
+ const A = 65
80
+ const letter1 = String.fromCharCode(A + (hashResult.array[0] % 26))
81
+ const letter2 = String.fromCharCode(A + (hashResult.array[1] % 26))
82
+ const subId = (hashResult.array[2] % 9) + 1
83
+ const num = (uint16(hashResult, 3) % 9000) + 1000
84
+ return `${letter1}${letter2}-${subId}/${num}`
85
+ }
86
+
79
87
  export function getSystemName(gameSeed: Checksum256Type, location: CoordinatesType): string {
80
88
  const seed = Checksum256.from(gameSeed)
81
89
  const locationType = getLocationType(seed, location)
@@ -91,6 +99,8 @@ export function getSystemName(gameSeed: Checksum256Type, location: CoordinatesTy
91
99
  return generateAsteroidName(hashResult)
92
100
  case LocationType.NEBULA:
93
101
  return generateNebulaName(hashResult)
102
+ case LocationType.ICE_FIELD:
103
+ return generateIceFieldName(hashResult)
94
104
  default:
95
105
  return generatePlanetName(hashResult)
96
106
  }
@@ -123,10 +133,12 @@ export function deriveLocationStatic(
123
133
 
124
134
  if (hashResult.array[1] < 96) {
125
135
  loc.type = UInt8.from(LocationType.PLANET)
126
- } else if (hashResult.array[1] < 176) {
136
+ } else if (hashResult.array[1] < 149) {
127
137
  loc.type = UInt8.from(LocationType.ASTEROID)
128
- } else {
138
+ } else if (hashResult.array[1] < 202) {
129
139
  loc.type = UInt8.from(LocationType.NEBULA)
140
+ } else {
141
+ loc.type = UInt8.from(LocationType.ICE_FIELD)
130
142
  }
131
143
 
132
144
  loc.subtype = UInt8.from(
@@ -138,31 +150,20 @@ export function deriveLocationStatic(
138
150
  return loc
139
151
  }
140
152
 
141
- export function deriveLocationEpoch(
142
- epochSeed: Checksum256Type,
153
+ export function isLocationBuildable(
154
+ gameSeed: Checksum256Type,
143
155
  coordinates: CoordinatesType
144
- ): ServerContract.Types.location_epoch {
145
- const seed = Checksum256.from(epochSeed)
146
- const coords = Coordinates.from(coordinates)
147
- const str = `system-epoch-${coords.x}-${coords.y}`
148
- const hashResult = hash512(seed, str)
149
-
150
- return ServerContract.Types.location_epoch.from({
151
- active: hashResult.array[0] < LOCATION_ACTIVE_THRESHOLD,
152
- seed0: hashResult.array[1],
153
- seed1: hashResult.array[2],
154
- })
156
+ ): boolean {
157
+ return getLocationType(gameSeed, coordinates) === LocationType.PLANET
155
158
  }
156
159
 
157
160
  export function deriveLocation(
158
161
  gameSeed: Checksum256Type,
159
- epochSeed: Checksum256Type,
160
162
  coordinates: CoordinatesType
161
163
  ): ServerContract.Types.location_derived {
162
164
  const staticProps = deriveLocationStatic(gameSeed, coordinates)
163
165
  return ServerContract.Types.location_derived.from({
164
166
  static_props: staticProps,
165
- epoch_props: deriveLocationEpoch(epochSeed, coordinates),
166
167
  size: deriveLocationSize(staticProps),
167
168
  })
168
169
  }