@shipload/sdk 2.0.0-rc2 → 2.0.0-rc20

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 (80) hide show
  1. package/README.md +1 -349
  2. package/lib/shipload.d.ts +1658 -1126
  3. package/lib/shipload.js +6847 -3082
  4. package/lib/shipload.js.map +1 -1
  5. package/lib/shipload.m.js +6468 -2793
  6. package/lib/shipload.m.js.map +1 -1
  7. package/package.json +6 -4
  8. package/src/capabilities/crafting.ts +22 -0
  9. package/src/capabilities/gathering.ts +36 -0
  10. package/src/capabilities/guards.ts +3 -8
  11. package/src/capabilities/hauling.ts +22 -0
  12. package/src/capabilities/index.ts +4 -1
  13. package/src/capabilities/modules.ts +57 -0
  14. package/src/capabilities/storage.ts +101 -9
  15. package/src/contracts/server.ts +717 -293
  16. package/src/data/capabilities.ts +408 -0
  17. package/src/data/categories.ts +55 -0
  18. package/src/data/colors.ts +71 -0
  19. package/src/data/items.json +17 -0
  20. package/src/data/locations.ts +53 -0
  21. package/src/data/nebula-adjectives.json +211 -0
  22. package/src/data/nebula-nouns.json +151 -0
  23. package/src/data/recipes.ts +587 -0
  24. package/src/data/syllables.json +1386 -780
  25. package/src/data/tiers.ts +45 -0
  26. package/src/derivation/crafting.ts +287 -0
  27. package/src/derivation/index.ts +30 -0
  28. package/src/derivation/location-size.ts +15 -0
  29. package/src/derivation/resources.ts +136 -0
  30. package/src/derivation/stats.ts +146 -0
  31. package/src/derivation/stratum.ts +134 -0
  32. package/src/derivation/tiers.ts +54 -0
  33. package/src/entities/cargo-utils.ts +10 -68
  34. package/src/entities/container.ts +37 -0
  35. package/src/entities/entity-inventory.ts +13 -13
  36. package/src/entities/inventory-accessor.ts +2 -6
  37. package/src/entities/location.ts +5 -200
  38. package/src/entities/makers.ts +136 -17
  39. package/src/entities/player.ts +1 -274
  40. package/src/entities/ship-deploy.ts +258 -0
  41. package/src/entities/ship.ts +28 -34
  42. package/src/entities/warehouse.ts +35 -7
  43. package/src/errors.ts +59 -5
  44. package/src/format.ts +12 -0
  45. package/src/index-module.ts +233 -50
  46. package/src/managers/actions.ts +138 -88
  47. package/src/managers/context.ts +19 -9
  48. package/src/managers/index.ts +0 -1
  49. package/src/managers/locations.ts +2 -85
  50. package/src/market/items.ts +93 -0
  51. package/src/nft/description.ts +176 -0
  52. package/src/nft/deserializers.ts +81 -0
  53. package/src/nft/index.ts +2 -0
  54. package/src/resolution/describe-module.ts +165 -0
  55. package/src/resolution/display-name.ts +39 -0
  56. package/src/resolution/resolve-item.ts +343 -0
  57. package/src/scheduling/projection.ts +220 -67
  58. package/src/scheduling/schedule.ts +2 -2
  59. package/src/shipload.ts +10 -5
  60. package/src/subscriptions/connection.ts +154 -0
  61. package/src/subscriptions/debug.ts +17 -0
  62. package/src/subscriptions/index.ts +5 -0
  63. package/src/subscriptions/manager.ts +240 -0
  64. package/src/subscriptions/mappers.ts +28 -0
  65. package/src/subscriptions/types.ts +143 -0
  66. package/src/travel/travel.ts +30 -17
  67. package/src/types/capabilities.ts +11 -14
  68. package/src/types/entity-traits.ts +3 -4
  69. package/src/types/entity.ts +9 -6
  70. package/src/types.ts +61 -55
  71. package/src/utils/system.ts +66 -53
  72. package/src/capabilities/extraction.ts +0 -37
  73. package/src/data/goods.json +0 -23
  74. package/src/managers/trades.ts +0 -119
  75. package/src/market/goods.ts +0 -31
  76. package/src/market/market.ts +0 -208
  77. package/src/market/rolls.ts +0 -8
  78. package/src/trading/collect.ts +0 -938
  79. package/src/trading/deal.ts +0 -207
  80. package/src/trading/trade.ts +0 -203
@@ -6,8 +6,8 @@ import {ServerContract} from './contracts'
6
6
 
7
7
  export {Shipload} from './shipload'
8
8
  export {Ship} from './entities/ship'
9
- export type {ShipStateInput} from './entities/ship'
10
- export {Warehouse} from './entities/warehouse'
9
+ export type {ShipStateInput, PackedModuleInput} from './entities/ship'
10
+ export {Warehouse, computeWarehouseCapabilities} from './entities/warehouse'
11
11
  export type {WarehouseStateInput} from './entities/warehouse'
12
12
  export {Container} from './entities/container'
13
13
  export type {ContainerStateInput} from './entities/container'
@@ -21,9 +21,8 @@ export type task = ServerContract.Types.task
21
21
  export type cargo_item = ServerContract.Types.cargo_item
22
22
  export type warehouse_row = ServerContract.Types.warehouse_row
23
23
  export type container_row = ServerContract.Types.container_row
24
- export type extractor_stats = ServerContract.Types.extractor_stats
25
- export type mixture_info = ServerContract.Types.mixture_info
26
- export type mixture_component = ServerContract.Types.mixture_component
24
+ export type gatherer_stats = ServerContract.Types.gatherer_stats
25
+
27
26
  export type location_static = ServerContract.Types.location_static
28
27
  export type location_epoch = ServerContract.Types.location_epoch
29
28
  export type location_derived = ServerContract.Types.location_derived
@@ -38,55 +37,59 @@ export {
38
37
  EntitiesManager,
39
38
  PlayersManager,
40
39
  LocationsManager,
41
- TradesManager,
42
40
  EpochsManager,
43
41
  ActionsManager,
44
42
  } from './managers'
45
43
  export type {EntityType} from './managers'
46
44
  export type {EntityRefInput} from './managers/actions'
47
45
 
48
- export {getGood, getGoods, goodIds} from './market/goods'
46
+ export {getItem, getItems, itemIds} from './market/items'
49
47
  export {getCurrentEpoch, getEpochInfo} from './scheduling/epoch'
50
48
  export type {EpochInfo} from './scheduling/epoch'
51
- export {marketPrice, marketPrices, getRarity, Rarities} from './market/market'
52
- export type {Rarity} from './market/market'
53
49
  export {
54
50
  getSystemName,
55
51
  hasSystem,
56
52
  getLocationType,
57
- isExtractableLocation,
53
+ getLocationTypeName,
54
+ isGatherableLocation,
58
55
  deriveLocationStatic,
59
56
  deriveLocationEpoch,
60
57
  deriveLocation,
61
- deriveLocationMixture,
62
58
  } from './utils/system'
63
59
 
64
- export {hash, hash512} from './utils/hash'
60
+ export {
61
+ deriveStratum,
62
+ deriveResourceStats,
63
+ deriveLocationSize,
64
+ getEligibleResources,
65
+ getResourceWeight,
66
+ getLocationCandidates,
67
+ getDepthThreshold,
68
+ getResourceTier,
69
+ DEPTH_THRESHOLD_T1,
70
+ DEPTH_THRESHOLD_T2,
71
+ DEPTH_THRESHOLD_T3,
72
+ DEPTH_THRESHOLD_T4,
73
+ DEPTH_THRESHOLD_T5,
74
+ LOCATION_MIN_DEPTH,
75
+ LOCATION_MAX_DEPTH,
76
+ PLANET_SUBTYPE_GAS_GIANT,
77
+ PLANET_SUBTYPE_ROCKY,
78
+ PLANET_SUBTYPE_TERRESTRIAL,
79
+ PLANET_SUBTYPE_ICY,
80
+ PLANET_SUBTYPE_OCEAN,
81
+ PLANET_SUBTYPE_INDUSTRIAL,
82
+ } from './derivation'
65
83
 
66
- export type {Deal, FindDealsOptions} from './trading/deal'
67
- export {findDealsForShip, findBestDeal} from './trading/deal'
84
+ export type {StratumInfo, ResourceStats} from './derivation'
68
85
 
69
- export type {
70
- CollectActionType,
71
- CollectOption,
72
- CollectAnalysis,
73
- CollectAnalysisOptions,
74
- CollectAnalysisCallbacks,
75
- BetterSaleLocation,
76
- RepositionLocation,
77
- DiscountedGoodInfo,
78
- PotentialDeal,
79
- CargoSaleItem,
80
- } from './trading/collect'
81
- export {
82
- analyzeCollectOptions,
83
- analyzeCargoSale,
84
- createSellAndTradeOption,
85
- createTravelToSellOption,
86
- createSellAndRepositionOption,
87
- createSellAndStayOption,
88
- createExploreOption,
89
- } from './trading/collect'
86
+ export {RESERVE_TIERS, TIER_ROLL_MAX, rollTier, rollWithinTier} from './derivation'
87
+ export type {ReserveTier, TierRange} from './derivation'
88
+
89
+ export {getStatDefinitions, getStatName, resolveStats} from './derivation'
90
+ export type {StatDefinition, NamedStats} from './derivation'
91
+
92
+ export {hash, hash512} from './utils/hash'
90
93
 
91
94
  export {
92
95
  distanceBetweenCoordinates,
@@ -125,19 +128,6 @@ export type {
125
128
  HasScheduleAndLocation,
126
129
  } from './travel/travel'
127
130
 
128
- export {
129
- calculateUpdatedCargoCost,
130
- calculateMaxTradeQuantity,
131
- calculateTradeProfit,
132
- calculateProfitPerMass,
133
- calculateProfitPerSecond,
134
- findBestGoodToTrade,
135
- calculateBreakEvenPrice,
136
- isProfitable,
137
- calculateROI,
138
- } from './trading/trade'
139
- export type {TradeCalculation, TradeProfitResult} from './trading/trade'
140
-
141
131
  export * as schedule from './scheduling/schedule'
142
132
  export type {Scheduleable, ScheduleData} from './scheduling/schedule'
143
133
  export {ScheduleAccessor, createScheduleAccessor} from './scheduling/accessor'
@@ -147,9 +137,202 @@ export type {HasCargo} from './entities/inventory-accessor'
147
137
  export * as cargoUtils from './entities/cargo-utils'
148
138
  export type {CargoData} from './entities/cargo-utils'
149
139
 
150
- export {projectEntity, projectEntityAt, createProjectedEntity} from './scheduling/projection'
151
- export type {Projectable, ProjectedEntity} from './scheduling/projection'
140
+ export {
141
+ createProjectedEntity,
142
+ projectEntity,
143
+ projectEntityAt,
144
+ validateSchedule,
145
+ } from './scheduling/projection'
146
+ export type {Projectable, ProjectedEntity, ProjectionOptions} from './scheduling/projection'
152
147
 
153
148
  export * from './types/capabilities'
154
149
  export * from './types/entity'
155
150
  export * from './capabilities'
151
+
152
+ export {
153
+ categoryColors,
154
+ tierColors,
155
+ tierLabels,
156
+ categoryIcons,
157
+ categoryIconShapes,
158
+ componentIcon,
159
+ moduleIcon,
160
+ itemAbbreviations,
161
+ } from './data/colors'
162
+ export type {CategoryIconShape} from './data/colors'
163
+
164
+ export {itemTier, itemOffset, itemCategory, isRelatedItem, isCraftedItem} from './data/tiers'
165
+ export type {CraftedItemCategory} from './data/tiers'
166
+
167
+ export {getCategoryInfo} from './data/categories'
168
+ export type {CategoryInfo} from './data/categories'
169
+
170
+ export {getPlanetSubtypes, getPlanetSubtype} from './data/locations'
171
+ export type {PlanetSubtypeInfo} from './data/locations'
172
+
173
+ export {
174
+ capabilityNames,
175
+ capabilityAttributes,
176
+ statMappings,
177
+ isInvertedAttribute,
178
+ getCapabilityAttributes,
179
+ getStatMappings,
180
+ getStatMappingsForStat,
181
+ getStatMappingsForCapability,
182
+ } from './data/capabilities'
183
+ export type {CapabilityAttribute, StatMapping} from './data/capabilities'
184
+
185
+ export {
186
+ components,
187
+ entityRecipes,
188
+ moduleRecipes,
189
+ getComponentById,
190
+ getEntityRecipe,
191
+ getEntityRecipeByItemId,
192
+ getModuleRecipe,
193
+ getModuleRecipeByItemId,
194
+ getAllCraftableItems,
195
+ getComponentsForCategory,
196
+ getComponentsForStat,
197
+ ITEM_HULL_PLATES,
198
+ ITEM_CARGO_LINING,
199
+ ITEM_CONTAINER_T1_PACKED,
200
+ ITEM_THRUSTER_CORE,
201
+ ITEM_POWER_CELL,
202
+ ITEM_ENGINE_T1,
203
+ ITEM_GENERATOR_T1,
204
+ ITEM_SHIP_T1_PACKED,
205
+ ITEM_WAREHOUSE_T1_PACKED,
206
+ ITEM_MATTER_CONDUIT,
207
+ ITEM_SURVEY_PROBE,
208
+ ITEM_CARGO_ARM,
209
+ ITEM_TOOL_BIT,
210
+ ITEM_REACTION_CHAMBER,
211
+ ITEM_GATHERER_T1,
212
+ ITEM_LOADER_T1,
213
+ ITEM_CRAFTER_T1,
214
+ ITEM_STORAGE_T1,
215
+ ITEM_HULL_PLATES_T2,
216
+ ITEM_CARGO_LINING_T2,
217
+ ITEM_CONTAINER_T2_PACKED,
218
+ ITEM_FOCUSING_ARRAY,
219
+ } from './data/recipes'
220
+ export type {
221
+ ComponentDefinition,
222
+ ComponentStat,
223
+ RecipeInput,
224
+ EntityRecipe,
225
+ ModuleRecipe,
226
+ ModuleSlot,
227
+ CraftableItem,
228
+ } from './data/recipes'
229
+
230
+ export {
231
+ encodeStats,
232
+ encodeGatheredCargoStats,
233
+ decodeStat,
234
+ decodeStats,
235
+ decodeCraftedItemStats,
236
+ blendStacks,
237
+ computeComponentStats,
238
+ blendComponentStacks,
239
+ computeEntityStats,
240
+ blendCargoStacks,
241
+ blendCrossGroup,
242
+ categoryItemMass,
243
+ computeInputMass,
244
+ computeCraftedOutputStats,
245
+ } from './derivation/crafting'
246
+ export type {StackInput, CategoryStacks, RecipeSlotInput} from './derivation/crafting'
247
+
248
+ export {computeContainerCapabilities, computeContainerT2Capabilities} from './entities/container'
249
+
250
+ export {
251
+ computeShipHullCapabilities,
252
+ computeEngineCapabilities,
253
+ computeGeneratorCapabilities,
254
+ computeGathererCapabilities,
255
+ computeHaulerCapabilities,
256
+ computeLoaderCapabilities,
257
+ computeCrafterCapabilities,
258
+ computeWarehouseHullCapabilities,
259
+ computeStorageCapabilities,
260
+ computeShipCapabilities,
261
+ } from './entities/ship-deploy'
262
+ export type {ShipCapabilities} from './entities/ship-deploy'
263
+
264
+ export {resolveItem} from './resolution/resolve-item'
265
+ export type {
266
+ ResolvedItem,
267
+ ResolvedItemStat,
268
+ ResolvedAttributeGroup,
269
+ ResolvedModuleSlot,
270
+ ResolvedItemType,
271
+ } from './resolution/resolve-item'
272
+
273
+ export {
274
+ describeModule,
275
+ describeModuleForItem,
276
+ describeModuleForSlot,
277
+ renderDescription,
278
+ } from './resolution/describe-module'
279
+ export type {
280
+ TextSpan,
281
+ CapabilityInput,
282
+ ModuleDescription,
283
+ RenderDescriptionOptions,
284
+ } from './resolution/describe-module'
285
+
286
+ export * as NFT from './nft'
287
+ export {
288
+ deserializeAsset,
289
+ deserializeResource,
290
+ deserializeComponent,
291
+ deserializeModule,
292
+ deserializeEntity,
293
+ readCommonBase,
294
+ } from './nft/deserializers'
295
+ export type {
296
+ NFTCargoItem,
297
+ NFTModuleSlot,
298
+ NFTInstalledModule,
299
+ NFTCommonBase,
300
+ } from './nft/deserializers'
301
+
302
+ export {
303
+ buildEntityDescription,
304
+ formatModuleLine,
305
+ entityDisplayName,
306
+ moduleDisplayName,
307
+ computeBaseHullmass,
308
+ computeBaseCapacityShip,
309
+ computeBaseCapacityWarehouse,
310
+ computeEngineThrust,
311
+ computeEngineDrain,
312
+ computeGeneratorCap,
313
+ computeGeneratorRech,
314
+ computeGathererYield,
315
+ computeGathererDrain,
316
+ computeGathererDepth,
317
+ computeGathererSpeed,
318
+ computeLoaderMass,
319
+ computeLoaderThrust,
320
+ computeCrafterSpeed,
321
+ computeCrafterDrain,
322
+ } from './nft/description'
323
+
324
+ export {getEntitySlotLayout} from './data/recipes'
325
+ export {
326
+ ITEM_TYPE_RESOURCE,
327
+ ITEM_TYPE_COMPONENT,
328
+ ITEM_TYPE_MODULE,
329
+ ITEM_TYPE_ENTITY,
330
+ itemTypeCode,
331
+ } from './data/tiers'
332
+
333
+ export {formatMass, formatMassDelta} from './format'
334
+
335
+ export {displayName, describeItem} from './resolution/display-name'
336
+ export type {DescribeOptions} from './resolution/display-name'
337
+
338
+ export * from './subscriptions'
@@ -1,15 +1,19 @@
1
- import {Action, Int64, Name, NameType, UInt16, UInt32, UInt64, UInt64Type} from '@wharfkit/antelope'
1
+ import {
2
+ Action,
3
+ Int64,
4
+ Name,
5
+ NameType,
6
+ UInt16,
7
+ UInt16Type,
8
+ UInt32,
9
+ UInt32Type,
10
+ UInt64,
11
+ UInt64Type,
12
+ } from '@wharfkit/antelope'
2
13
  import {BaseManager} from './base'
3
- import {Ship} from '../entities/ship'
4
14
  import {CoordinatesType, EntityType, EntityTypeName} from '../types'
5
15
  import {ServerContract} from '../contracts'
6
16
 
7
- interface SellableCargo {
8
- good_id: {toNumber(): number} | number
9
- quantity: {toNumber(): number} | number
10
- hasCargo: boolean
11
- }
12
-
13
17
  export type EntityRefInput = {
14
18
  entityType: EntityTypeName
15
19
  entityId: UInt64Type
@@ -47,11 +51,19 @@ export class ActionsManager extends BaseManager {
47
51
  })
48
52
  }
49
53
 
50
- resolve(entityId: UInt64Type, entityType: EntityTypeName = EntityType.SHIP): Action {
51
- return this.server.action('resolve', {
54
+ resolve(
55
+ entityId: UInt64Type,
56
+ entityType: EntityTypeName = EntityType.SHIP,
57
+ count?: UInt64Type
58
+ ): Action {
59
+ const params: ServerContract.ActionParams.resolve = {
52
60
  entity_type: entityType,
53
61
  id: UInt64.from(entityId),
54
- })
62
+ }
63
+ if (count !== undefined) {
64
+ params.count = UInt64.from(count)
65
+ }
66
+ return this.server.action('resolve', params)
55
67
  }
56
68
 
57
69
  cancel(
@@ -66,10 +78,10 @@ export class ActionsManager extends BaseManager {
66
78
  })
67
79
  }
68
80
 
69
- recharge(shipId: UInt64Type): Action {
81
+ recharge(entityId: UInt64Type, entityType: EntityTypeName = EntityType.SHIP): Action {
70
82
  return this.server.action('recharge', {
71
- entity_type: EntityType.SHIP,
72
- id: UInt64.from(shipId),
83
+ entity_type: entityType,
84
+ id: UInt64.from(entityId),
73
85
  })
74
86
  }
75
87
 
@@ -78,7 +90,8 @@ export class ActionsManager extends BaseManager {
78
90
  sourceId: UInt64Type,
79
91
  destType: EntityTypeName,
80
92
  destId: UInt64Type,
81
- goodId: UInt64Type,
93
+ itemId: UInt64Type,
94
+ stats: UInt64Type,
82
95
  quantity: UInt64Type
83
96
  ): Action {
84
97
  return this.server.action('transfer', {
@@ -86,115 +99,152 @@ export class ActionsManager extends BaseManager {
86
99
  source_id: UInt64.from(sourceId),
87
100
  dest_type: destType,
88
101
  dest_id: UInt64.from(destId),
89
- good_id: UInt16.from(goodId),
102
+ item_id: UInt16.from(itemId),
103
+ stats: UInt64.from(stats),
90
104
  quantity: UInt32.from(quantity),
91
105
  })
92
106
  }
93
107
 
94
- buyGoods(
95
- entityId: UInt64Type,
96
- goodId: UInt64Type,
97
- quantity: UInt64Type,
98
- entityType: EntityTypeName = EntityType.SHIP
108
+ foundCompany(account: NameType, name: string): Action {
109
+ return this.platform.action('foundcompany', {
110
+ account: Name.from(account),
111
+ name,
112
+ })
113
+ }
114
+
115
+ join(account: NameType): Action {
116
+ return this.server.action('join', {
117
+ account: Name.from(account),
118
+ })
119
+ }
120
+
121
+ gather(
122
+ source: EntityRefInput,
123
+ destination: EntityRefInput,
124
+ stratum: UInt16Type,
125
+ quantity: UInt32Type
99
126
  ): Action {
100
- return this.server.action('buygoods', {
101
- entity_type: entityType,
102
- id: UInt64.from(entityId),
103
- good_id: UInt16.from(goodId),
127
+ return this.server.action('gather', {
128
+ source: ServerContract.Types.entity_ref.from({
129
+ entity_type: source.entityType,
130
+ entity_id: UInt64.from(source.entityId),
131
+ }),
132
+ destination: ServerContract.Types.entity_ref.from({
133
+ entity_type: destination.entityType,
134
+ entity_id: UInt64.from(destination.entityId),
135
+ }),
136
+ stratum: UInt16.from(stratum),
104
137
  quantity: UInt32.from(quantity),
105
138
  })
106
139
  }
107
140
 
108
- sellGoods(
141
+ warp(
109
142
  entityId: UInt64Type,
110
- goodId: UInt64Type,
111
- quantity: UInt64Type,
143
+ destination: CoordinatesType,
112
144
  entityType: EntityTypeName = EntityType.SHIP
113
145
  ): Action {
114
- return this.server.action('sellgoods', {
146
+ const x = Int64.from(destination.x)
147
+ const y = Int64.from(destination.y)
148
+
149
+ return this.server.action('warp', {
115
150
  entity_type: entityType,
116
151
  id: UInt64.from(entityId),
117
- good_id: UInt16.from(goodId),
118
- quantity: UInt32.from(quantity),
119
- })
120
- }
121
-
122
- buyShip(account: NameType, name: string): Action {
123
- return this.server.action('buyship', {
124
- account: Name.from(account),
125
- name,
126
- })
127
- }
128
-
129
- buyWarehouse(account: NameType, shipId: UInt64Type, name: string): Action {
130
- return this.server.action('buywarehouse', {
131
- account: Name.from(account),
132
- ship_id: UInt64.from(shipId),
133
- name,
152
+ x,
153
+ y,
134
154
  })
135
155
  }
136
156
 
137
- buyContainer(account: NameType, shipId: UInt64Type, name: string): Action {
138
- return this.server.action('buycontainer', {
139
- account: Name.from(account),
140
- ship_id: UInt64.from(shipId),
141
- name,
157
+ craft(
158
+ entityType: EntityTypeName,
159
+ entityId: UInt64Type,
160
+ recipeId: number,
161
+ quantity: number,
162
+ inputs: ServerContract.ActionParams.Type.cargo_item[]
163
+ ): Action {
164
+ const cargoInputs = inputs.map((i) => ServerContract.Types.cargo_item.from(i))
165
+ return this.server.action('craft', {
166
+ entity_type: entityType,
167
+ id: UInt64.from(entityId),
168
+ recipe_id: UInt16.from(recipeId),
169
+ quantity: UInt32.from(quantity),
170
+ inputs: cargoInputs,
142
171
  })
143
172
  }
144
173
 
145
- takeLoan(account: NameType, amount: UInt64Type): Action {
146
- return this.server.action('takeloan', {
147
- account: Name.from(account),
148
- amount: UInt64.from(amount),
174
+ blend(
175
+ entityType: EntityTypeName,
176
+ entityId: UInt64Type,
177
+ inputs: ServerContract.ActionParams.Type.cargo_item[]
178
+ ): Action {
179
+ const cargoInputs = inputs.map((i) => ServerContract.Types.cargo_item.from(i))
180
+ return this.server.action('blend', {
181
+ entity_type: entityType,
182
+ id: UInt64.from(entityId),
183
+ inputs: cargoInputs,
149
184
  })
150
185
  }
151
186
 
152
- payLoan(account: NameType, amount: UInt64Type): Action {
153
- return this.server.action('payloan', {
154
- account: Name.from(account),
155
- amount: UInt64.from(amount),
187
+ deploy(
188
+ entityType: EntityTypeName,
189
+ entityId: UInt64Type,
190
+ packedItemId: number,
191
+ stats: bigint
192
+ ): Action {
193
+ return this.server.action('deploy', {
194
+ entity_type: entityType,
195
+ id: UInt64.from(entityId),
196
+ packed_item_id: UInt16.from(packedItemId),
197
+ stats: UInt64.from(stats),
156
198
  })
157
199
  }
158
200
 
159
- foundCompany(account: NameType, name: string): Action {
160
- return this.platform.action('foundcompany', {
161
- account: Name.from(account),
162
- name,
201
+ addmodule(
202
+ entityType: EntityTypeName,
203
+ entityId: UInt64Type,
204
+ moduleIndex: number,
205
+ moduleCargoId: UInt64Type,
206
+ targetCargoId: UInt64Type = UInt64.from(0)
207
+ ): Action {
208
+ return this.server.action('addmodule', {
209
+ entity_type: entityType,
210
+ entity_id: UInt64.from(entityId),
211
+ module_index: moduleIndex,
212
+ module_cargo_id: UInt64.from(moduleCargoId),
213
+ target_cargo_id: UInt64.from(targetCargoId),
163
214
  })
164
215
  }
165
216
 
166
- join(account: NameType): Action {
167
- return this.server.action('join', {
168
- account: Name.from(account),
217
+ rmmodule(
218
+ entityType: EntityTypeName,
219
+ entityId: UInt64Type,
220
+ moduleIndex: number,
221
+ targetCargoId: UInt64Type = UInt64.from(0)
222
+ ): Action {
223
+ return this.server.action('rmmodule', {
224
+ entity_type: entityType,
225
+ entity_id: UInt64.from(entityId),
226
+ module_index: moduleIndex,
227
+ target_cargo_id: UInt64.from(targetCargoId),
169
228
  })
170
229
  }
171
230
 
172
- extract(shipId: UInt64Type): Action {
173
- return this.server.action('extract', {
174
- ship_id: UInt64.from(shipId),
231
+ wrap(
232
+ owner: NameType,
233
+ entityType: EntityTypeName,
234
+ entityId: UInt64Type,
235
+ cargoId: UInt64Type,
236
+ quantity: UInt64Type
237
+ ): Action {
238
+ return this.server.action('wrap', {
239
+ owner: Name.from(owner),
240
+ entity_type: entityType,
241
+ entity_id: UInt64.from(entityId),
242
+ cargo_id: UInt64.from(cargoId),
243
+ quantity: UInt64.from(quantity),
175
244
  })
176
245
  }
177
246
 
178
247
  joinGame(account: NameType, companyName: string): Action[] {
179
248
  return [this.foundCompany(account, companyName), this.join(account)]
180
249
  }
181
-
182
- sellAllCargo(ship: Ship | UInt64Type, cargo?: SellableCargo[]): Action[] {
183
- let shipCargo: SellableCargo[]
184
-
185
- if (ship instanceof Ship) {
186
- shipCargo = cargo || ship.inventory
187
- } else {
188
- if (!cargo) {
189
- throw new Error('cargo parameter required when ship is a UInt64Type')
190
- }
191
- shipCargo = cargo
192
- }
193
-
194
- const shipId = ship instanceof Ship ? ship.id : UInt64.from(ship)
195
-
196
- return shipCargo
197
- .filter((c) => c.hasCargo)
198
- .map((c) => this.sellGoods(shipId, c.good_id, c.quantity, EntityType.SHIP))
199
- }
200
250
  }
@@ -6,17 +6,18 @@ import {GameState} from '../entities/gamestate'
6
6
  import {EntitiesManager} from './entities'
7
7
  import {PlayersManager} from './players'
8
8
  import {LocationsManager} from './locations'
9
- import {TradesManager} from './trades'
10
9
  import {EpochsManager} from './epochs'
11
10
  import {ActionsManager} from './actions'
11
+ import {SubscriptionsManager} from '../subscriptions/manager'
12
12
 
13
13
  export class GameContext {
14
14
  private _entities?: EntitiesManager
15
15
  private _players?: PlayersManager
16
16
  private _locations?: LocationsManager
17
- private _trades?: TradesManager
18
17
  private _epochs?: EpochsManager
19
18
  private _actions?: ActionsManager
19
+ private _subscriptions?: SubscriptionsManager
20
+ private _subscriptionsUrl?: string
20
21
 
21
22
  private _gameCache?: PlatformContract.Types.game_row
22
23
  private _stateCache?: GameState
@@ -48,13 +49,6 @@ export class GameContext {
48
49
  return this._locations
49
50
  }
50
51
 
51
- get trades(): TradesManager {
52
- if (!this._trades) {
53
- this._trades = new TradesManager(this)
54
- }
55
- return this._trades
56
- }
57
-
58
52
  get epochs(): EpochsManager {
59
53
  if (!this._epochs) {
60
54
  this._epochs = new EpochsManager(this)
@@ -69,6 +63,22 @@ export class GameContext {
69
63
  return this._actions
70
64
  }
71
65
 
66
+ setSubscriptionsUrl(url: string) {
67
+ this._subscriptionsUrl = url
68
+ }
69
+
70
+ get subscriptions(): SubscriptionsManager {
71
+ if (!this._subscriptions) {
72
+ if (!this._subscriptionsUrl) {
73
+ throw new Error(
74
+ 'subscriptions requires a subscriptionsUrl passed to Shipload constructor'
75
+ )
76
+ }
77
+ this._subscriptions = new SubscriptionsManager({url: this._subscriptionsUrl})
78
+ }
79
+ return this._subscriptions
80
+ }
81
+
72
82
  async getGame(reload = false): Promise<PlatformContract.Types.game_row> {
73
83
  if (!reload && this._gameCache) {
74
84
  return this._gameCache
@@ -4,6 +4,5 @@ export {EntitiesManager} from './entities'
4
4
  export type {EntityType} from './entities'
5
5
  export {PlayersManager} from './players'
6
6
  export {LocationsManager} from './locations'
7
- export {TradesManager} from './trades'
8
7
  export {EpochsManager} from './epochs'
9
8
  export {ActionsManager} from './actions'