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

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.
@@ -90,18 +90,15 @@ export class ActionsManager extends BaseManager {
90
90
  sourceId: UInt64Type,
91
91
  destType: EntityTypeName,
92
92
  destId: UInt64Type,
93
- itemId: UInt64Type,
94
- stats: UInt64Type,
95
- quantity: UInt64Type
93
+ items: ServerContract.ActionParams.Type.cargo_item[]
96
94
  ): Action {
95
+ const cargoItems = items.map((i) => ServerContract.Types.cargo_item.from(i))
97
96
  return this.server.action('transfer', {
98
97
  source_type: sourceType,
99
98
  source_id: UInt64.from(sourceId),
100
99
  dest_type: destType,
101
100
  dest_id: UInt64.from(destId),
102
- item_id: UInt16.from(itemId),
103
- stats: UInt64.from(stats),
104
- quantity: UInt32.from(quantity),
101
+ items: cargoItems,
105
102
  })
106
103
  }
107
104
 
@@ -187,14 +184,12 @@ export class ActionsManager extends BaseManager {
187
184
  deploy(
188
185
  entityType: EntityTypeName,
189
186
  entityId: UInt64Type,
190
- packedItemId: number,
191
- stats: bigint
187
+ ref: ServerContract.ActionParams.Type.cargo_ref
192
188
  ): Action {
193
189
  return this.server.action('deploy', {
194
190
  entity_type: entityType,
195
191
  id: UInt64.from(entityId),
196
- packed_item_id: UInt16.from(packedItemId),
197
- stats: UInt64.from(stats),
192
+ ref: ServerContract.Types.cargo_ref.from(ref),
198
193
  })
199
194
  }
200
195
 
@@ -202,15 +197,15 @@ export class ActionsManager extends BaseManager {
202
197
  entityType: EntityTypeName,
203
198
  entityId: UInt64Type,
204
199
  moduleIndex: number,
205
- moduleCargoId: UInt64Type,
206
- targetCargoId: UInt64Type = UInt64.from(0)
200
+ moduleRef: ServerContract.ActionParams.Type.cargo_ref,
201
+ targetRef: ServerContract.ActionParams.Type.cargo_ref | null = null
207
202
  ): Action {
208
203
  return this.server.action('addmodule', {
209
204
  entity_type: entityType,
210
205
  entity_id: UInt64.from(entityId),
211
206
  module_index: moduleIndex,
212
- module_cargo_id: UInt64.from(moduleCargoId),
213
- target_cargo_id: UInt64.from(targetCargoId),
207
+ module_ref: ServerContract.Types.cargo_ref.from(moduleRef),
208
+ target_ref: targetRef ? ServerContract.Types.cargo_ref.from(targetRef) : null,
214
209
  })
215
210
  }
216
211
 
@@ -218,13 +213,13 @@ export class ActionsManager extends BaseManager {
218
213
  entityType: EntityTypeName,
219
214
  entityId: UInt64Type,
220
215
  moduleIndex: number,
221
- targetCargoId: UInt64Type = UInt64.from(0)
216
+ targetRef: ServerContract.ActionParams.Type.cargo_ref | null = null
222
217
  ): Action {
223
218
  return this.server.action('rmmodule', {
224
219
  entity_type: entityType,
225
220
  entity_id: UInt64.from(entityId),
226
221
  module_index: moduleIndex,
227
- target_cargo_id: UInt64.from(targetCargoId),
222
+ target_ref: targetRef ? ServerContract.Types.cargo_ref.from(targetRef) : null,
228
223
  })
229
224
  }
230
225
 
@@ -232,15 +227,14 @@ export class ActionsManager extends BaseManager {
232
227
  owner: NameType,
233
228
  entityType: EntityTypeName,
234
229
  entityId: UInt64Type,
235
- cargoId: UInt64Type,
236
- quantity: UInt64Type
230
+ items: ServerContract.ActionParams.Type.cargo_item[]
237
231
  ): Action {
232
+ const cargoItems = items.map((i) => ServerContract.Types.cargo_item.from(i))
238
233
  return this.server.action('wrap', {
239
234
  owner: Name.from(owner),
240
235
  entity_type: entityType,
241
236
  entity_id: UInt64.from(entityId),
242
- cargo_id: UInt64.from(cargoId),
243
- quantity: UInt64.from(quantity),
237
+ items: cargoItems,
244
238
  })
245
239
  }
246
240
 
package/src/types.ts CHANGED
@@ -163,3 +163,7 @@ export interface Item {
163
163
  export function formatTier(tier: number): string {
164
164
  return 'T' + tier
165
165
  }
166
+
167
+ export function tierAdjective(tier: number): string {
168
+ return TIER_ADJECTIVES[tier] ?? `T${tier}`
169
+ }
@@ -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,
@@ -151,31 +150,13 @@ export function deriveLocationStatic(
151
150
  return loc
152
151
  }
153
152
 
154
- export function deriveLocationEpoch(
155
- epochSeed: Checksum256Type,
156
- 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
- })
168
- }
169
-
170
153
  export function deriveLocation(
171
154
  gameSeed: Checksum256Type,
172
- epochSeed: Checksum256Type,
173
155
  coordinates: CoordinatesType
174
156
  ): ServerContract.Types.location_derived {
175
157
  const staticProps = deriveLocationStatic(gameSeed, coordinates)
176
158
  return ServerContract.Types.location_derived.from({
177
159
  static_props: staticProps,
178
- epoch_props: deriveLocationEpoch(epochSeed, coordinates),
179
160
  size: deriveLocationSize(staticProps),
180
161
  })
181
162
  }