@shipload/sdk 2.0.0-rc4 → 2.0.0-rc6

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 (45) hide show
  1. package/lib/shipload.d.ts +411 -1025
  2. package/lib/shipload.js +879 -2057
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +852 -2028
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/capabilities/crafting.ts +10 -0
  8. package/src/capabilities/guards.ts +0 -5
  9. package/src/capabilities/index.ts +1 -0
  10. package/src/capabilities/storage.ts +0 -8
  11. package/src/contracts/server.ts +106 -225
  12. package/src/data/items.json +15 -14
  13. package/src/data/recipes.ts +129 -0
  14. package/src/derivation/crafting.ts +120 -0
  15. package/src/derivation/index.ts +9 -6
  16. package/src/derivation/resources.ts +54 -53
  17. package/src/derivation/stats.ts +146 -0
  18. package/src/derivation/stratum.ts +14 -14
  19. package/src/entities/cargo-utils.ts +6 -64
  20. package/src/entities/container.ts +18 -0
  21. package/src/entities/entity-inventory.ts +0 -4
  22. package/src/entities/inventory-accessor.ts +0 -4
  23. package/src/entities/location.ts +2 -197
  24. package/src/entities/player.ts +1 -274
  25. package/src/entities/ship.ts +0 -21
  26. package/src/entities/warehouse.ts +0 -4
  27. package/src/index-module.ts +43 -47
  28. package/src/managers/actions.ts +38 -90
  29. package/src/managers/context.ts +0 -9
  30. package/src/managers/index.ts +0 -1
  31. package/src/managers/locations.ts +2 -85
  32. package/src/market/items.ts +1 -2
  33. package/src/scheduling/projection.ts +0 -10
  34. package/src/shipload.ts +0 -5
  35. package/src/types/capabilities.ts +1 -9
  36. package/src/types/entity-traits.ts +3 -4
  37. package/src/types/entity.ts +0 -1
  38. package/src/types.ts +8 -28
  39. package/src/utils/system.ts +5 -4
  40. package/src/managers/trades.ts +0 -119
  41. package/src/market/market.ts +0 -208
  42. package/src/market/rolls.ts +0 -8
  43. package/src/trading/collect.ts +0 -938
  44. package/src/trading/deal.ts +0 -207
  45. package/src/trading/trade.ts +0 -203
@@ -1,288 +1,15 @@
1
- import {
2
- Int64,
3
- Int64Type,
4
- Name,
5
- NameType,
6
- UInt32,
7
- UInt32Type,
8
- UInt64,
9
- UInt64Type,
10
- } from '@wharfkit/antelope'
1
+ import {Name, NameType} from '@wharfkit/antelope'
11
2
  import {ServerContract} from '../contracts'
12
3
 
13
4
  export interface PlayerStateInput {
14
5
  owner: NameType
15
- balance: UInt64Type
16
- debt: UInt32Type
17
- networth: Int64Type
18
6
  }
19
7
 
20
- /**
21
- * Player helper class extending player_row with computed financial properties.
22
- * Provides easy access to balance, debt, networth, and loan calculations.
23
- */
24
8
  export class Player extends ServerContract.Types.player_row {
25
- /**
26
- * Construct a Player instance from individual state pieces.
27
- * Used by UI's ReactivePlayer to reconstruct Player from reactive state.
28
- */
29
9
  static fromState(state: PlayerStateInput): Player {
30
10
  const playerRow = ServerContract.Types.player_row.from({
31
11
  owner: Name.from(state.owner),
32
- balance: UInt64.from(state.balance),
33
- debt: UInt32.from(state.debt),
34
- networth: Int64.from(state.networth),
35
12
  })
36
13
  return new Player(playerRow)
37
14
  }
38
- // Constants for game rules (match smart contract)
39
- private static readonly MAX_LOAN = 1000000
40
- // Contract formula: 2500 * pow(5, sequence - 1) = 500 * pow(5, sequence)
41
- private static readonly BASE_SHIP_COST = 500
42
- private static readonly SHIP_COST_MULTIPLIER = 5
43
-
44
- // Optional ship count for nextShipCost calculation
45
- private _shipCount?: number
46
-
47
- /**
48
- * Set the current ship count (needed for nextShipCost calculation)
49
- */
50
- setShipCount(count: number): void {
51
- this._shipCount = count
52
- }
53
-
54
- /**
55
- * Get the current ship count (if set)
56
- */
57
- get shipCount(): number | undefined {
58
- return this._shipCount
59
- }
60
-
61
- /**
62
- * Calculate the cost of the next ship based on current ship count
63
- * Matches contract: pow(5, sequence) * 100
64
- * @param shipCount - Optional ship count (uses cached value if not provided)
65
- */
66
- getNextShipCost(shipCount?: number): UInt64 {
67
- const count = shipCount ?? this._shipCount ?? 0
68
- const cost = Math.pow(Player.SHIP_COST_MULTIPLIER, count) * Player.BASE_SHIP_COST
69
- return UInt64.from(Math.floor(cost))
70
- }
71
-
72
- /**
73
- * Get the cost of the next ship based on cached ship count
74
- */
75
- get nextShipCost(): UInt64 {
76
- return this.getNextShipCost()
77
- }
78
-
79
- /**
80
- * Check if player can afford to buy a ship
81
- * @param shipCount - Optional ship count (uses cached value if not provided)
82
- */
83
- canBuyShip(shipCount?: number): boolean {
84
- return UInt64.from(this.balance).gte(this.getNextShipCost(shipCount))
85
- }
86
-
87
- /**
88
- * Calculate available loan amount (max loan - current debt)
89
- */
90
- get availableLoan(): UInt64 {
91
- const maxLoan = UInt64.from(Player.MAX_LOAN)
92
- if (UInt64.from(this.debt).gte(maxLoan)) {
93
- return UInt64.from(0)
94
- }
95
- return maxLoan.subtracting(this.debt)
96
- }
97
-
98
- /**
99
- * Check if player can take out a loan
100
- */
101
- get canTakeLoan(): boolean {
102
- return this.availableLoan.gt(UInt64.zero)
103
- }
104
-
105
- /**
106
- * Check if player can pay back loan
107
- */
108
- get canPayLoan(): boolean {
109
- return UInt64.from(this.debt).gt(UInt64.zero) && UInt64.from(this.balance).gt(UInt64.zero)
110
- }
111
-
112
- /**
113
- * Calculate maximum payback amount (min of debt and balance)
114
- */
115
- get maxPayback(): UInt64 {
116
- return UInt64.from(this.debt).lt(this.balance) ? this.debt : this.balance
117
- }
118
-
119
- /**
120
- * Get the maximum loan amount (constant)
121
- */
122
- static get MAX_LOAN_LIMIT(): number {
123
- return Player.MAX_LOAN
124
- }
125
-
126
- /**
127
- * Check if player is in debt
128
- */
129
- get hasDebt(): boolean {
130
- return UInt64.from(this.debt).gt(UInt64.zero)
131
- }
132
-
133
- /**
134
- * Check if player is solvent (positive networth)
135
- */
136
- get isSolvent(): boolean {
137
- return this.networth.gte(Int64.zero)
138
- }
139
-
140
- /**
141
- * Create an optimistic update for balance changes
142
- * Uses integer math to match contract
143
- * @param delta - Amount to change (can be negative)
144
- */
145
- withBalanceChange(delta: UInt64 | number): Player {
146
- const newPlayer = Player.from(this)
147
- const amount = typeof delta === 'number' ? UInt64.from(Math.abs(delta)) : delta
148
-
149
- if (typeof delta === 'number' && delta < 0) {
150
- // Subtract, ensuring we don't go below 0
151
- newPlayer.balance = UInt64.from(this.balance).gte(amount)
152
- ? this.balance.subtracting(amount)
153
- : UInt64.from(0)
154
- } else {
155
- // Add
156
- newPlayer.balance = this.balance.adding(amount)
157
- }
158
-
159
- // Calculate networth as Int64 (can be negative)
160
- const balanceInt = Int64.from(newPlayer.balance)
161
- const debtInt = Int64.from(newPlayer.debt)
162
- newPlayer.networth = balanceInt.subtracting(debtInt)
163
- return newPlayer
164
- }
165
-
166
- /**
167
- * Create an optimistic update for debt changes
168
- * Uses integer math to match contract
169
- * @param delta - Amount to change (can be negative)
170
- */
171
- withDebtChange(delta: UInt64 | number): Player {
172
- const newPlayer = Player.from(this)
173
- const amount = typeof delta === 'number' ? UInt64.from(Math.abs(delta)) : delta
174
-
175
- if (typeof delta === 'number' && delta < 0) {
176
- // Subtract, ensuring we don't go below 0
177
- newPlayer.debt = UInt64.from(this.debt).gte(amount)
178
- ? this.debt.subtracting(amount)
179
- : UInt64.from(0)
180
- } else {
181
- // Add
182
- newPlayer.debt = this.debt.adding(amount)
183
- }
184
-
185
- // Calculate networth as Int64 (can be negative)
186
- const balanceInt = Int64.from(newPlayer.balance)
187
- const debtInt = Int64.from(newPlayer.debt)
188
- newPlayer.networth = balanceInt.subtracting(debtInt)
189
- return newPlayer
190
- }
191
-
192
- /**
193
- * Create an optimistic update for taking a loan
194
- */
195
- withLoan(amount: UInt64): Player {
196
- const newPlayer = Player.from(this)
197
- newPlayer.balance = this.balance.adding(amount)
198
- newPlayer.debt = this.debt.adding(amount)
199
- // Calculate networth as Int64 (can be negative)
200
- const balanceInt = Int64.from(newPlayer.balance)
201
- const debtInt = Int64.from(newPlayer.debt)
202
- newPlayer.networth = balanceInt.subtracting(debtInt)
203
- return newPlayer
204
- }
205
-
206
- /**
207
- * Create an optimistic update for paying back a loan
208
- */
209
- withLoanPayment(amount: UInt64): Player {
210
- const actualPayment = this.maxPayback.lt(amount) ? this.maxPayback : amount
211
- const newPlayer = Player.from(this)
212
- newPlayer.balance = this.balance.subtracting(actualPayment)
213
- newPlayer.debt = this.debt.subtracting(actualPayment)
214
- // Calculate networth as Int64 (can be negative)
215
- const balanceInt = Int64.from(newPlayer.balance)
216
- const debtInt = Int64.from(newPlayer.debt)
217
- newPlayer.networth = balanceInt.subtracting(debtInt)
218
- return newPlayer
219
- }
220
-
221
- /**
222
- * Simulate networth update from selling goods.
223
- * Matches contract: networth += (sellPrice - paid * quantity)
224
- * Contract reference: market.cpp:75
225
- *
226
- * @param sellPrice - Total revenue from sale (price * quantity)
227
- * @param paidPerUnit - Average cost per unit paid (from cargo.paid)
228
- * @param quantity - Quantity being sold
229
- * @returns New player with updated networth
230
- *
231
- * @example
232
- * // Sold 10 units at 150 each (revenue=1500), paid 100 per unit
233
- * const newPlayer = player.withSaleNetworth(
234
- * UInt64.from(1500),
235
- * UInt64.from(100),
236
- * UInt32.from(10)
237
- * )
238
- * // Networth increases by: 1500 - (100*10) = 500
239
- */
240
- withSaleNetworth(sellPrice: UInt64, paidPerUnit: UInt64, quantity: UInt64): Player {
241
- // Match contract: price - paid * quantity
242
- const cost = paidPerUnit.multiplying(quantity)
243
- const profit = sellPrice.gte(cost) ? sellPrice.subtracting(cost) : Int64.from(0)
244
-
245
- const newPlayer = Player.from(this)
246
- newPlayer.networth = Int64.from(this.networth).adding(profit)
247
- return newPlayer
248
- }
249
-
250
- /**
251
- * Simulate complete sell goods transaction.
252
- * Updates both balance (adds revenue) and networth (adds profit).
253
- * Matches contract actions: update_balance + update_networth
254
- *
255
- * @param sellPrice - Total revenue from sale (price * quantity)
256
- * @param paidPerUnit - Average cost per unit paid (from cargo.paid)
257
- * @param quantity - Quantity being sold
258
- * @returns New player with updated balance and networth
259
- */
260
- withSellGoods(sellPrice: UInt64, paidPerUnit: UInt64, quantity: UInt64): Player {
261
- const cost = paidPerUnit.multiplying(quantity)
262
- const profit = sellPrice.gte(cost) ? sellPrice.subtracting(cost) : Int64.from(0)
263
-
264
- const newPlayer = Player.from(this)
265
- newPlayer.balance = this.balance.adding(sellPrice)
266
- newPlayer.networth = Int64.from(this.networth).adding(profit)
267
- return newPlayer
268
- }
269
-
270
- /**
271
- * Simulate complete buy goods transaction.
272
- * Updates balance (subtracts cost).
273
- *
274
- * @param purchaseCost - Total cost of purchase (price * quantity)
275
- * @returns New player with updated balance
276
- */
277
- withBuyGoods(purchaseCost: UInt64): Player {
278
- const newPlayer = Player.from(this)
279
- newPlayer.balance = UInt64.from(this.balance).gte(purchaseCost)
280
- ? this.balance.subtracting(purchaseCost)
281
- : UInt64.from(0)
282
- // Calculate networth as Int64 (can be negative)
283
- const balanceInt = Int64.from(newPlayer.balance)
284
- const debtInt = Int64.from(newPlayer.debt)
285
- newPlayer.networth = balanceInt.subtracting(debtInt)
286
- return newPlayer
287
- }
288
15
  }
@@ -21,7 +21,6 @@ import {
21
21
  hasEnergyForDistance,
22
22
  maxTravelDistance,
23
23
  } from '../capabilities/movement'
24
- import * as cargoUtils from './cargo-utils'
25
24
  import * as schedule from '../scheduling/schedule'
26
25
 
27
26
  export interface ShipStateInput {
@@ -133,10 +132,6 @@ export class Ship extends ServerContract.Types.entity_info {
133
132
  return this.inv.totalMass
134
133
  }
135
134
 
136
- get cargoValue(): UInt64 {
137
- return this.inv.totalValue
138
- }
139
-
140
135
  get totalMass(): UInt64 {
141
136
  let mass = UInt64.from(this.hullmass ?? 0).adding(this.totalCargoMass)
142
137
  if (this.loaders) {
@@ -193,20 +188,4 @@ export class Ship extends ServerContract.Types.entity_info {
193
188
  if (!this.engines || !this.generator || this.energy === undefined) return false
194
189
  return hasEnergyForDistance(this as MovementEntity, distance)
195
190
  }
196
-
197
- calculateSaleValue(prices: Map<number, UInt64>): cargoUtils.SaleValue {
198
- return cargoUtils.calculateSaleValue(this.cargo, prices)
199
- }
200
-
201
- calculateSaleValueFromArray(prices: UInt64[]): cargoUtils.SaleValue {
202
- return cargoUtils.calculateSaleValueFromArray(this.cargo, prices)
203
- }
204
-
205
- afterSellItems(goodsToSell: Array<{goodId: number; quantity: number}>): EntityInventory[] {
206
- return cargoUtils.afterSellItems(this.cargo, goodsToSell)
207
- }
208
-
209
- afterSellAllItems(): EntityInventory[] {
210
- return cargoUtils.afterSellAllItems(this.cargo)
211
- }
212
191
  }
@@ -58,10 +58,6 @@ export class Warehouse extends ServerContract.Types.entity_info {
58
58
  return this.inv.totalMass
59
59
  }
60
60
 
61
- get cargoValue(): UInt64 {
62
- return this.inv.totalValue
63
- }
64
-
65
61
  get maxCapacity(): UInt64 {
66
62
  return UInt64.from(this.capacity)
67
63
  }
@@ -37,7 +37,6 @@ export {
37
37
  EntitiesManager,
38
38
  PlayersManager,
39
39
  LocationsManager,
40
- TradesManager,
41
40
  EpochsManager,
42
41
  ActionsManager,
43
42
  } from './managers'
@@ -47,8 +46,6 @@ export type {EntityRefInput} from './managers/actions'
47
46
  export {getItem, getItems, itemIds} from './market/items'
48
47
  export {getCurrentEpoch, getEpochInfo} from './scheduling/epoch'
49
48
  export type {EpochInfo} from './scheduling/epoch'
50
- export {marketPrice, marketPrices, getRarity, Rarities} from './market/market'
51
- export type {Rarity} from './market/market'
52
49
  export {
53
50
  getSystemName,
54
51
  hasSystem,
@@ -67,13 +64,13 @@ export {
67
64
  getResourceWeight,
68
65
  getLocationCandidates,
69
66
  getDepthThreshold,
70
- getResourceRarity,
67
+ getResourceTier,
71
68
  depthScaleFactor,
72
- DEPTH_THRESHOLD_COMMON,
73
- DEPTH_THRESHOLD_UNCOMMON,
74
- DEPTH_THRESHOLD_RARE,
75
- DEPTH_THRESHOLD_EPIC,
76
- DEPTH_THRESHOLD_LEGENDARY,
69
+ DEPTH_THRESHOLD_T1,
70
+ DEPTH_THRESHOLD_T2,
71
+ DEPTH_THRESHOLD_T3,
72
+ DEPTH_THRESHOLD_T4,
73
+ DEPTH_THRESHOLD_T5,
77
74
  LOCATION_MIN_DEPTH,
78
75
  LOCATION_MAX_DEPTH,
79
76
  PLANET_SUBTYPE_GAS_GIANT,
@@ -86,32 +83,10 @@ export {
86
83
 
87
84
  export type {StratumInfo, ResourceStats} from './derivation'
88
85
 
89
- export {hash, hash512} from './utils/hash'
90
-
91
- export type {Deal, FindDealsOptions} from './trading/deal'
92
- export {findDealsForShip, findBestDeal} from './trading/deal'
86
+ export {getStatDefinitions, getStatName, resolveStats} from './derivation'
87
+ export type {StatDefinition, NamedStats} from './derivation'
93
88
 
94
- export type {
95
- CollectActionType,
96
- CollectOption,
97
- CollectAnalysis,
98
- CollectAnalysisOptions,
99
- CollectAnalysisCallbacks,
100
- BetterSaleLocation,
101
- RepositionLocation,
102
- DiscountedItemInfo,
103
- PotentialDeal,
104
- CargoSaleItem,
105
- } from './trading/collect'
106
- export {
107
- analyzeCollectOptions,
108
- analyzeCargoSale,
109
- createSellAndTradeOption,
110
- createTravelToSellOption,
111
- createSellAndRepositionOption,
112
- createSellAndStayOption,
113
- createExploreOption,
114
- } from './trading/collect'
89
+ export {hash, hash512} from './utils/hash'
115
90
 
116
91
  export {
117
92
  distanceBetweenCoordinates,
@@ -150,19 +125,6 @@ export type {
150
125
  HasScheduleAndLocation,
151
126
  } from './travel/travel'
152
127
 
153
- export {
154
- calculateUpdatedCargoCost,
155
- calculateMaxTradeQuantity,
156
- calculateTradeProfit,
157
- calculateProfitPerMass,
158
- calculateProfitPerSecond,
159
- findBestItemToTrade,
160
- calculateBreakEvenPrice,
161
- isProfitable,
162
- calculateROI,
163
- } from './trading/trade'
164
- export type {TradeCalculation, TradeProfitResult} from './trading/trade'
165
-
166
128
  export * as schedule from './scheduling/schedule'
167
129
  export type {Scheduleable, ScheduleData} from './scheduling/schedule'
168
130
  export {ScheduleAccessor, createScheduleAccessor} from './scheduling/accessor'
@@ -178,3 +140,37 @@ export type {Projectable, ProjectedEntity} from './scheduling/projection'
178
140
  export * from './types/capabilities'
179
141
  export * from './types/entity'
180
142
  export * from './capabilities'
143
+
144
+ export {
145
+ components,
146
+ entityRecipes,
147
+ getComponentById,
148
+ getEntityRecipe,
149
+ getEntityRecipeByItemId,
150
+ getAllCraftableItems,
151
+ getComponentsForCategory,
152
+ getComponentsForStat,
153
+ ITEM_HULL_PLATES,
154
+ ITEM_CARGO_LINING,
155
+ ITEM_CONTAINER_PACKED,
156
+ } from './data/recipes'
157
+ export type {
158
+ ComponentDefinition,
159
+ ComponentStat,
160
+ RecipeInput,
161
+ EntityRecipe,
162
+ CraftableItem,
163
+ } from './data/recipes'
164
+
165
+ export {
166
+ encodeStats,
167
+ decodeStats,
168
+ decodeCraftedItemStats,
169
+ blendStacks,
170
+ computeComponentStats,
171
+ blendComponentStacks,
172
+ computeEntityStats,
173
+ } from './derivation/crafting'
174
+ export type {StackInput, CategoryStacks} from './derivation/crafting'
175
+
176
+ export {computeContainerCapabilities} from './entities/container'
@@ -1,15 +1,8 @@
1
1
  import {Action, Int64, Name, NameType, UInt16, UInt32, UInt64, UInt64Type} from '@wharfkit/antelope'
2
2
  import {BaseManager} from './base'
3
- import {Ship} from '../entities/ship'
4
3
  import {CoordinatesType, EntityType, EntityTypeName} from '../types'
5
4
  import {ServerContract} from '../contracts'
6
5
 
7
- interface SellableCargo {
8
- item_id: {toNumber(): number} | number
9
- quantity: {toNumber(): number} | number
10
- hasCargo: boolean
11
- }
12
-
13
6
  export type EntityRefInput = {
14
7
  entityType: EntityTypeName
15
8
  entityId: UInt64Type
@@ -91,71 +84,6 @@ export class ActionsManager extends BaseManager {
91
84
  })
92
85
  }
93
86
 
94
- buyItems(
95
- entityId: UInt64Type,
96
- goodId: UInt64Type,
97
- quantity: UInt64Type,
98
- entityType: EntityTypeName = EntityType.SHIP
99
- ): Action {
100
- return this.server.action('buyitems', {
101
- entity_type: entityType,
102
- id: UInt64.from(entityId),
103
- item_id: UInt16.from(goodId),
104
- quantity: UInt32.from(quantity),
105
- })
106
- }
107
-
108
- sellItems(
109
- entityId: UInt64Type,
110
- goodId: UInt64Type,
111
- quantity: UInt64Type,
112
- entityType: EntityTypeName = EntityType.SHIP
113
- ): Action {
114
- return this.server.action('sellitems', {
115
- entity_type: entityType,
116
- id: UInt64.from(entityId),
117
- item_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,
134
- })
135
- }
136
-
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,
142
- })
143
- }
144
-
145
- takeLoan(account: NameType, amount: UInt64Type): Action {
146
- return this.server.action('takeloan', {
147
- account: Name.from(account),
148
- amount: UInt64.from(amount),
149
- })
150
- }
151
-
152
- payLoan(account: NameType, amount: UInt64Type): Action {
153
- return this.server.action('payloan', {
154
- account: Name.from(account),
155
- amount: UInt64.from(amount),
156
- })
157
- }
158
-
159
87
  foundCompany(account: NameType, name: string): Action {
160
88
  return this.platform.action('foundcompany', {
161
89
  account: Name.from(account),
@@ -187,26 +115,46 @@ export class ActionsManager extends BaseManager {
187
115
  })
188
116
  }
189
117
 
190
- joinGame(account: NameType, companyName: string): Action[] {
191
- return [this.foundCompany(account, companyName), this.join(account)]
118
+ craft(
119
+ entityType: EntityTypeName,
120
+ entityId: UInt64Type,
121
+ recipeId: number,
122
+ quantity: number,
123
+ inputs: {itemId: number; quantity: number; seed?: bigint}[]
124
+ ): Action {
125
+ const cargoInputs = inputs.map((i) =>
126
+ ServerContract.Types.cargo_item.from({
127
+ item_id: UInt16.from(i.itemId),
128
+ quantity: UInt32.from(i.quantity),
129
+ seed: i.seed !== undefined ? UInt64.from(i.seed) : null,
130
+ })
131
+ )
132
+ return this.server.action('craft', {
133
+ entity_type: entityType,
134
+ id: UInt64.from(entityId),
135
+ recipe_id: UInt16.from(recipeId),
136
+ quantity: UInt32.from(quantity),
137
+ inputs: cargoInputs,
138
+ })
192
139
  }
193
140
 
194
- sellAllCargo(ship: Ship | UInt64Type, cargo?: SellableCargo[]): Action[] {
195
- let shipCargo: SellableCargo[]
196
-
197
- if (ship instanceof Ship) {
198
- shipCargo = cargo || ship.inventory
199
- } else {
200
- if (!cargo) {
201
- throw new Error('cargo parameter required when ship is a UInt64Type')
202
- }
203
- shipCargo = cargo
204
- }
205
-
206
- const shipId = ship instanceof Ship ? ship.id : UInt64.from(ship)
141
+ deploy(
142
+ entityType: EntityTypeName,
143
+ entityId: UInt64Type,
144
+ packedItemId: number,
145
+ seed: bigint,
146
+ entityName: string
147
+ ): Action {
148
+ return this.server.action('deploy', {
149
+ entity_type: entityType,
150
+ id: UInt64.from(entityId),
151
+ packed_item_id: UInt16.from(packedItemId),
152
+ seed: UInt64.from(seed),
153
+ entity_name: entityName,
154
+ })
155
+ }
207
156
 
208
- return shipCargo
209
- .filter((c) => c.hasCargo)
210
- .map((c) => this.sellItems(shipId, c.item_id, c.quantity, EntityType.SHIP))
157
+ joinGame(account: NameType, companyName: string): Action[] {
158
+ return [this.foundCompany(account, companyName), this.join(account)]
211
159
  }
212
160
  }
@@ -6,7 +6,6 @@ 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'
12
11
 
@@ -14,7 +13,6 @@ export class GameContext {
14
13
  private _entities?: EntitiesManager
15
14
  private _players?: PlayersManager
16
15
  private _locations?: LocationsManager
17
- private _trades?: TradesManager
18
16
  private _epochs?: EpochsManager
19
17
  private _actions?: ActionsManager
20
18
 
@@ -48,13 +46,6 @@ export class GameContext {
48
46
  return this._locations
49
47
  }
50
48
 
51
- get trades(): TradesManager {
52
- if (!this._trades) {
53
- this._trades = new TradesManager(this)
54
- }
55
- return this._trades
56
- }
57
-
58
49
  get epochs(): EpochsManager {
59
50
  if (!this._epochs) {
60
51
  this._epochs = new EpochsManager(this)
@@ -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'