@shipload/sdk 2.0.0-rc2 → 2.0.0-rc21
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.
- package/README.md +1 -349
- package/lib/shipload.d.ts +1729 -1127
- package/lib/shipload.js +7944 -3165
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +7487 -2840
- package/lib/shipload.m.js.map +1 -1
- package/package.json +6 -4
- package/src/capabilities/crafting.ts +22 -0
- package/src/capabilities/gathering.ts +36 -0
- package/src/capabilities/guards.ts +3 -8
- package/src/capabilities/hauling.ts +22 -0
- package/src/capabilities/index.ts +4 -1
- package/src/capabilities/modules.ts +86 -0
- package/src/capabilities/storage.ts +101 -9
- package/src/contracts/server.ts +785 -293
- package/src/data/capabilities.ts +408 -0
- package/src/data/categories.ts +55 -0
- package/src/data/colors.ts +71 -0
- package/src/data/entities.json +50 -0
- package/src/data/item-ids.ts +75 -0
- package/src/data/items.json +252 -0
- package/src/data/locations.ts +53 -0
- package/src/data/metadata.ts +208 -0
- package/src/data/nebula-adjectives.json +211 -0
- package/src/data/nebula-nouns.json +151 -0
- package/src/data/recipes-runtime.ts +65 -0
- package/src/data/recipes.json +878 -0
- package/src/data/syllables.json +1386 -780
- package/src/data/tiers.ts +45 -0
- package/src/derivation/crafting.ts +348 -0
- package/src/derivation/index.ts +30 -0
- package/src/derivation/location-size.ts +15 -0
- package/src/derivation/resources.ts +112 -0
- package/src/derivation/stats.ts +146 -0
- package/src/derivation/stratum.ts +134 -0
- package/src/derivation/tiers.ts +54 -0
- package/src/entities/cargo-utils.ts +10 -68
- package/src/entities/container.ts +37 -0
- package/src/entities/entity-inventory.ts +13 -13
- package/src/entities/inventory-accessor.ts +2 -6
- package/src/entities/location.ts +5 -200
- package/src/entities/makers.ts +144 -17
- package/src/entities/player.ts +1 -274
- package/src/entities/ship-deploy.ts +258 -0
- package/src/entities/ship.ts +28 -34
- package/src/entities/warehouse.ts +35 -7
- package/src/errors.ts +59 -5
- package/src/format.ts +12 -0
- package/src/index-module.ts +188 -50
- package/src/managers/actions.ts +138 -88
- package/src/managers/context.ts +19 -9
- package/src/managers/index.ts +0 -1
- package/src/managers/locations.ts +2 -85
- package/src/market/items.ts +41 -0
- package/src/nft/description.ts +176 -0
- package/src/nft/deserializers.ts +83 -0
- package/src/nft/index.ts +2 -0
- package/src/resolution/describe-module.ts +165 -0
- package/src/resolution/display-name.ts +43 -0
- package/src/resolution/resolve-item.ts +358 -0
- package/src/scheduling/projection.ts +200 -67
- package/src/scheduling/schedule.ts +2 -2
- package/src/shipload.ts +10 -5
- package/src/subscriptions/connection.ts +154 -0
- package/src/subscriptions/debug.ts +17 -0
- package/src/subscriptions/index.ts +5 -0
- package/src/subscriptions/manager.ts +240 -0
- package/src/subscriptions/mappers.ts +28 -0
- package/src/subscriptions/types.ts +143 -0
- package/src/travel/travel.ts +37 -23
- package/src/types/capabilities.ts +11 -14
- package/src/types/entity-traits.ts +3 -4
- package/src/types/entity.ts +9 -6
- package/src/types.ts +72 -72
- package/src/utils/system.ts +66 -53
- package/src/capabilities/extraction.ts +0 -37
- package/src/data/goods.json +0 -23
- package/src/managers/trades.ts +0 -119
- package/src/market/goods.ts +0 -31
- package/src/market/market.ts +0 -208
- package/src/market/rolls.ts +0 -8
- package/src/trading/collect.ts +0 -938
- package/src/trading/deal.ts +0 -207
- package/src/trading/trade.ts +0 -203
package/src/index-module.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export * from './contracts'
|
|
2
2
|
export * from './errors'
|
|
3
3
|
export * from './types'
|
|
4
|
+
export * from './data/item-ids'
|
|
5
|
+
export * from './data/recipes-runtime'
|
|
4
6
|
|
|
5
7
|
import {ServerContract} from './contracts'
|
|
6
8
|
|
|
7
9
|
export {Shipload} from './shipload'
|
|
8
10
|
export {Ship} from './entities/ship'
|
|
9
|
-
export type {ShipStateInput} from './entities/ship'
|
|
10
|
-
export {Warehouse} from './entities/warehouse'
|
|
11
|
+
export type {ShipStateInput, PackedModuleInput} from './entities/ship'
|
|
12
|
+
export {Warehouse, computeWarehouseCapabilities} from './entities/warehouse'
|
|
11
13
|
export type {WarehouseStateInput} from './entities/warehouse'
|
|
12
14
|
export {Container} from './entities/container'
|
|
13
15
|
export type {ContainerStateInput} from './entities/container'
|
|
@@ -21,9 +23,8 @@ export type task = ServerContract.Types.task
|
|
|
21
23
|
export type cargo_item = ServerContract.Types.cargo_item
|
|
22
24
|
export type warehouse_row = ServerContract.Types.warehouse_row
|
|
23
25
|
export type container_row = ServerContract.Types.container_row
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
export type mixture_component = ServerContract.Types.mixture_component
|
|
26
|
+
export type gatherer_stats = ServerContract.Types.gatherer_stats
|
|
27
|
+
|
|
27
28
|
export type location_static = ServerContract.Types.location_static
|
|
28
29
|
export type location_epoch = ServerContract.Types.location_epoch
|
|
29
30
|
export type location_derived = ServerContract.Types.location_derived
|
|
@@ -38,55 +39,59 @@ export {
|
|
|
38
39
|
EntitiesManager,
|
|
39
40
|
PlayersManager,
|
|
40
41
|
LocationsManager,
|
|
41
|
-
TradesManager,
|
|
42
42
|
EpochsManager,
|
|
43
43
|
ActionsManager,
|
|
44
44
|
} from './managers'
|
|
45
45
|
export type {EntityType} from './managers'
|
|
46
46
|
export type {EntityRefInput} from './managers/actions'
|
|
47
47
|
|
|
48
|
-
export {
|
|
48
|
+
export {getItem, getItems, itemIds} from './market/items'
|
|
49
49
|
export {getCurrentEpoch, getEpochInfo} from './scheduling/epoch'
|
|
50
50
|
export type {EpochInfo} from './scheduling/epoch'
|
|
51
|
-
export {marketPrice, marketPrices, getRarity, Rarities} from './market/market'
|
|
52
|
-
export type {Rarity} from './market/market'
|
|
53
51
|
export {
|
|
54
52
|
getSystemName,
|
|
55
53
|
hasSystem,
|
|
56
54
|
getLocationType,
|
|
57
|
-
|
|
55
|
+
getLocationTypeName,
|
|
56
|
+
isGatherableLocation,
|
|
58
57
|
deriveLocationStatic,
|
|
59
58
|
deriveLocationEpoch,
|
|
60
59
|
deriveLocation,
|
|
61
|
-
deriveLocationMixture,
|
|
62
60
|
} from './utils/system'
|
|
63
61
|
|
|
64
|
-
export {
|
|
62
|
+
export {
|
|
63
|
+
deriveStratum,
|
|
64
|
+
deriveResourceStats,
|
|
65
|
+
deriveLocationSize,
|
|
66
|
+
getEligibleResources,
|
|
67
|
+
getResourceWeight,
|
|
68
|
+
getLocationCandidates,
|
|
69
|
+
getDepthThreshold,
|
|
70
|
+
getResourceTier,
|
|
71
|
+
DEPTH_THRESHOLD_T1,
|
|
72
|
+
DEPTH_THRESHOLD_T2,
|
|
73
|
+
DEPTH_THRESHOLD_T3,
|
|
74
|
+
DEPTH_THRESHOLD_T4,
|
|
75
|
+
DEPTH_THRESHOLD_T5,
|
|
76
|
+
LOCATION_MIN_DEPTH,
|
|
77
|
+
LOCATION_MAX_DEPTH,
|
|
78
|
+
PLANET_SUBTYPE_GAS_GIANT,
|
|
79
|
+
PLANET_SUBTYPE_ROCKY,
|
|
80
|
+
PLANET_SUBTYPE_TERRESTRIAL,
|
|
81
|
+
PLANET_SUBTYPE_ICY,
|
|
82
|
+
PLANET_SUBTYPE_OCEAN,
|
|
83
|
+
PLANET_SUBTYPE_INDUSTRIAL,
|
|
84
|
+
} from './derivation'
|
|
65
85
|
|
|
66
|
-
export type {
|
|
67
|
-
export {findDealsForShip, findBestDeal} from './trading/deal'
|
|
86
|
+
export type {StratumInfo, ResourceStats} from './derivation'
|
|
68
87
|
|
|
69
|
-
export
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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'
|
|
88
|
+
export {RESERVE_TIERS, TIER_ROLL_MAX, rollTier, rollWithinTier} from './derivation'
|
|
89
|
+
export type {ReserveTier, TierRange} from './derivation'
|
|
90
|
+
|
|
91
|
+
export {getStatDefinitions, getStatName, resolveStats} from './derivation'
|
|
92
|
+
export type {StatDefinition, NamedStats} from './derivation'
|
|
93
|
+
|
|
94
|
+
export {hash, hash512} from './utils/hash'
|
|
90
95
|
|
|
91
96
|
export {
|
|
92
97
|
distanceBetweenCoordinates,
|
|
@@ -125,19 +130,6 @@ export type {
|
|
|
125
130
|
HasScheduleAndLocation,
|
|
126
131
|
} from './travel/travel'
|
|
127
132
|
|
|
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
133
|
export * as schedule from './scheduling/schedule'
|
|
142
134
|
export type {Scheduleable, ScheduleData} from './scheduling/schedule'
|
|
143
135
|
export {ScheduleAccessor, createScheduleAccessor} from './scheduling/accessor'
|
|
@@ -147,9 +139,155 @@ export type {HasCargo} from './entities/inventory-accessor'
|
|
|
147
139
|
export * as cargoUtils from './entities/cargo-utils'
|
|
148
140
|
export type {CargoData} from './entities/cargo-utils'
|
|
149
141
|
|
|
150
|
-
export {
|
|
151
|
-
|
|
142
|
+
export {
|
|
143
|
+
createProjectedEntity,
|
|
144
|
+
projectEntity,
|
|
145
|
+
projectEntityAt,
|
|
146
|
+
validateSchedule,
|
|
147
|
+
} from './scheduling/projection'
|
|
148
|
+
export type {Projectable, ProjectedEntity, ProjectionOptions} from './scheduling/projection'
|
|
152
149
|
|
|
153
150
|
export * from './types/capabilities'
|
|
154
151
|
export * from './types/entity'
|
|
155
152
|
export * from './capabilities'
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
categoryColors,
|
|
156
|
+
tierColors,
|
|
157
|
+
tierLabels,
|
|
158
|
+
categoryIcons,
|
|
159
|
+
categoryIconShapes,
|
|
160
|
+
componentIcon,
|
|
161
|
+
moduleIcon,
|
|
162
|
+
itemAbbreviations,
|
|
163
|
+
} from './data/colors'
|
|
164
|
+
export type {CategoryIconShape} from './data/colors'
|
|
165
|
+
|
|
166
|
+
export {itemTier, itemOffset, itemCategory, isRelatedItem, isCraftedItem} from './data/tiers'
|
|
167
|
+
export type {CraftedItemCategory} from './data/tiers'
|
|
168
|
+
|
|
169
|
+
export {getCategoryInfo} from './data/categories'
|
|
170
|
+
export type {CategoryInfo} from './data/categories'
|
|
171
|
+
|
|
172
|
+
export {getPlanetSubtypes, getPlanetSubtype} from './data/locations'
|
|
173
|
+
export type {PlanetSubtypeInfo} from './data/locations'
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
capabilityNames,
|
|
177
|
+
capabilityAttributes,
|
|
178
|
+
statMappings,
|
|
179
|
+
isInvertedAttribute,
|
|
180
|
+
getCapabilityAttributes,
|
|
181
|
+
getStatMappings,
|
|
182
|
+
getStatMappingsForStat,
|
|
183
|
+
getStatMappingsForCapability,
|
|
184
|
+
} from './data/capabilities'
|
|
185
|
+
export type {CapabilityAttribute, StatMapping} from './data/capabilities'
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
encodeStats,
|
|
189
|
+
encodeGatheredCargoStats,
|
|
190
|
+
decodeStat,
|
|
191
|
+
decodeStats,
|
|
192
|
+
decodeCraftedItemStats,
|
|
193
|
+
blendStacks,
|
|
194
|
+
computeComponentStats,
|
|
195
|
+
blendComponentStacks,
|
|
196
|
+
computeEntityStats,
|
|
197
|
+
blendCargoStacks,
|
|
198
|
+
blendCrossGroup,
|
|
199
|
+
computeInputMass,
|
|
200
|
+
computeCraftedOutputStats,
|
|
201
|
+
} from './derivation/crafting'
|
|
202
|
+
export type {StackInput, CategoryStacks, RecipeSlotInput} from './derivation/crafting'
|
|
203
|
+
|
|
204
|
+
export {computeContainerCapabilities, computeContainerT2Capabilities} from './entities/container'
|
|
205
|
+
|
|
206
|
+
export {
|
|
207
|
+
computeShipHullCapabilities,
|
|
208
|
+
computeEngineCapabilities,
|
|
209
|
+
computeGeneratorCapabilities,
|
|
210
|
+
computeGathererCapabilities,
|
|
211
|
+
computeHaulerCapabilities,
|
|
212
|
+
computeLoaderCapabilities,
|
|
213
|
+
computeCrafterCapabilities,
|
|
214
|
+
computeWarehouseHullCapabilities,
|
|
215
|
+
computeStorageCapabilities,
|
|
216
|
+
computeShipCapabilities,
|
|
217
|
+
} from './entities/ship-deploy'
|
|
218
|
+
export type {ShipCapabilities} from './entities/ship-deploy'
|
|
219
|
+
|
|
220
|
+
export {resolveItem} from './resolution/resolve-item'
|
|
221
|
+
export type {
|
|
222
|
+
ResolvedItem,
|
|
223
|
+
ResolvedItemStat,
|
|
224
|
+
ResolvedAttributeGroup,
|
|
225
|
+
ResolvedModuleSlot,
|
|
226
|
+
ResolvedItemType,
|
|
227
|
+
} from './resolution/resolve-item'
|
|
228
|
+
|
|
229
|
+
export {
|
|
230
|
+
describeModule,
|
|
231
|
+
describeModuleForItem,
|
|
232
|
+
describeModuleForSlot,
|
|
233
|
+
renderDescription,
|
|
234
|
+
} from './resolution/describe-module'
|
|
235
|
+
export type {
|
|
236
|
+
TextSpan,
|
|
237
|
+
CapabilityInput,
|
|
238
|
+
ModuleDescription,
|
|
239
|
+
RenderDescriptionOptions,
|
|
240
|
+
} from './resolution/describe-module'
|
|
241
|
+
|
|
242
|
+
export * as NFT from './nft'
|
|
243
|
+
export {
|
|
244
|
+
deserializeAsset,
|
|
245
|
+
deserializeResource,
|
|
246
|
+
deserializeComponent,
|
|
247
|
+
deserializeModule,
|
|
248
|
+
deserializeEntity,
|
|
249
|
+
readCommonBase,
|
|
250
|
+
} from './nft/deserializers'
|
|
251
|
+
export type {
|
|
252
|
+
NFTCargoItem,
|
|
253
|
+
NFTModuleSlot,
|
|
254
|
+
NFTInstalledModule,
|
|
255
|
+
NFTCommonBase,
|
|
256
|
+
} from './nft/deserializers'
|
|
257
|
+
|
|
258
|
+
export {
|
|
259
|
+
buildEntityDescription,
|
|
260
|
+
formatModuleLine,
|
|
261
|
+
entityDisplayName,
|
|
262
|
+
moduleDisplayName,
|
|
263
|
+
computeBaseHullmass,
|
|
264
|
+
computeBaseCapacityShip,
|
|
265
|
+
computeBaseCapacityWarehouse,
|
|
266
|
+
computeEngineThrust,
|
|
267
|
+
computeEngineDrain,
|
|
268
|
+
computeGeneratorCap,
|
|
269
|
+
computeGeneratorRech,
|
|
270
|
+
computeGathererYield,
|
|
271
|
+
computeGathererDrain,
|
|
272
|
+
computeGathererDepth,
|
|
273
|
+
computeGathererSpeed,
|
|
274
|
+
computeLoaderMass,
|
|
275
|
+
computeLoaderThrust,
|
|
276
|
+
computeCrafterSpeed,
|
|
277
|
+
computeCrafterDrain,
|
|
278
|
+
} from './nft/description'
|
|
279
|
+
|
|
280
|
+
export {
|
|
281
|
+
ITEM_TYPE_RESOURCE,
|
|
282
|
+
ITEM_TYPE_COMPONENT,
|
|
283
|
+
ITEM_TYPE_MODULE,
|
|
284
|
+
ITEM_TYPE_ENTITY,
|
|
285
|
+
itemTypeCode,
|
|
286
|
+
} from './data/tiers'
|
|
287
|
+
|
|
288
|
+
export {formatMass, formatMassDelta} from './format'
|
|
289
|
+
|
|
290
|
+
export {displayName, describeItem} from './resolution/display-name'
|
|
291
|
+
export type {DescribeOptions} from './resolution/display-name'
|
|
292
|
+
|
|
293
|
+
export * from './subscriptions'
|
package/src/managers/actions.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import {
|
|
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(
|
|
51
|
-
|
|
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(
|
|
81
|
+
recharge(entityId: UInt64Type, entityType: EntityTypeName = EntityType.SHIP): Action {
|
|
70
82
|
return this.server.action('recharge', {
|
|
71
|
-
entity_type:
|
|
72
|
-
id: UInt64.from(
|
|
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
|
-
|
|
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
|
-
|
|
102
|
+
item_id: UInt16.from(itemId),
|
|
103
|
+
stats: UInt64.from(stats),
|
|
90
104
|
quantity: UInt32.from(quantity),
|
|
91
105
|
})
|
|
92
106
|
}
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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('
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
141
|
+
warp(
|
|
109
142
|
entityId: UInt64Type,
|
|
110
|
-
|
|
111
|
-
quantity: UInt64Type,
|
|
143
|
+
destination: CoordinatesType,
|
|
112
144
|
entityType: EntityTypeName = EntityType.SHIP
|
|
113
145
|
): Action {
|
|
114
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
}
|
package/src/managers/context.ts
CHANGED
|
@@ -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
|
package/src/managers/index.ts
CHANGED
|
@@ -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'
|