@shipload/sdk 2.0.0-rc5 → 2.0.0-rc7
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 +607 -1113
- package/lib/shipload.js +1482 -2077
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +1421 -2038
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/crafting.ts +28 -0
- package/src/capabilities/extraction.ts +14 -8
- package/src/capabilities/guards.ts +0 -5
- package/src/capabilities/index.ts +2 -0
- package/src/capabilities/modules.ts +49 -0
- package/src/capabilities/storage.ts +0 -8
- package/src/contracts/server.ts +231 -313
- package/src/data/colors.ts +28 -0
- package/src/data/items.json +15 -15
- package/src/data/recipes.ts +351 -0
- package/src/derivation/crafting.ts +142 -0
- package/src/derivation/index.ts +1 -0
- package/src/derivation/stats.ts +91 -15
- package/src/derivation/stratum.ts +2 -2
- package/src/entities/cargo-utils.ts +6 -64
- package/src/entities/container.ts +18 -0
- package/src/entities/entity-inventory.ts +0 -4
- package/src/entities/inventory-accessor.ts +0 -4
- package/src/entities/location.ts +2 -197
- package/src/entities/makers.ts +10 -9
- package/src/entities/player.ts +1 -274
- package/src/entities/ship-deploy.ts +89 -0
- package/src/entities/ship.ts +14 -27
- package/src/entities/warehouse.ts +0 -4
- package/src/index-module.ts +66 -41
- package/src/managers/actions.ts +77 -88
- package/src/managers/context.ts +0 -9
- package/src/managers/index.ts +0 -1
- package/src/managers/locations.ts +2 -85
- package/src/market/items.ts +0 -1
- package/src/resolution/resolve-item.ts +242 -0
- package/src/scheduling/projection.ts +0 -10
- package/src/shipload.ts +0 -5
- package/src/travel/travel.ts +3 -3
- package/src/types/capabilities.ts +1 -9
- package/src/types/entity-traits.ts +3 -4
- package/src/types/entity.ts +3 -4
- package/src/types.ts +6 -43
- package/src/utils/system.ts +5 -4
- package/src/managers/trades.ts +0 -119
- package/src/market/market.ts +0 -195
- 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/entities/player.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export function computeShipHullCapabilities(stats: Record<string, number>): {
|
|
2
|
+
hullmass: number
|
|
3
|
+
capacity: number
|
|
4
|
+
} {
|
|
5
|
+
const density = stats.density ?? 500
|
|
6
|
+
const strength = stats.strength ?? 500
|
|
7
|
+
const ductility = stats.ductility ?? 500
|
|
8
|
+
const purity = stats.purity ?? 500
|
|
9
|
+
|
|
10
|
+
const hullmass = 25000 + 75 * density
|
|
11
|
+
const statSum = strength + ductility + purity
|
|
12
|
+
const exponent = statSum / 2997.0
|
|
13
|
+
const capacity = Math.floor(1000000 * Math.pow(10, exponent))
|
|
14
|
+
|
|
15
|
+
return {hullmass, capacity}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function computeEngineCapabilities(stats: Record<string, number>): {
|
|
19
|
+
thrust: number
|
|
20
|
+
drain: number
|
|
21
|
+
} {
|
|
22
|
+
const vol = stats.volatility ?? 500
|
|
23
|
+
const thm = stats.thermal ?? 500
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
thrust: 400 + Math.floor(vol * 3 / 4),
|
|
27
|
+
drain: Math.max(16, 30 - Math.floor(thm / 70)),
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function computeGeneratorCapabilities(stats: Record<string, number>): {
|
|
32
|
+
capacity: number
|
|
33
|
+
recharge: number
|
|
34
|
+
} {
|
|
35
|
+
const res = stats.resonance ?? 500
|
|
36
|
+
const clr = stats.clarity ?? 500
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
capacity: 300 + Math.floor(res / 6),
|
|
40
|
+
recharge: 5 + Math.floor(clr * 15 / 1000),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function computeExtractorCapabilities(stats: Record<string, number>): {
|
|
45
|
+
rate: number
|
|
46
|
+
drain: number
|
|
47
|
+
depth: number
|
|
48
|
+
drill: number
|
|
49
|
+
} {
|
|
50
|
+
const str = stats.strength ?? 500
|
|
51
|
+
const con = stats.conductivity ?? 500
|
|
52
|
+
const ref = stats.reflectivity ?? 500
|
|
53
|
+
const tol = stats.tolerance ?? 500
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
rate: 200 + str,
|
|
57
|
+
drain: Math.max(10, 50 - Math.floor(con / 20)),
|
|
58
|
+
depth: 200 + Math.floor(tol * 3 / 2),
|
|
59
|
+
drill: 100 + Math.floor(ref * 4 / 5),
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function computeLoaderCapabilities(stats: Record<string, number>): {
|
|
64
|
+
mass: number
|
|
65
|
+
thrust: number
|
|
66
|
+
quantity: number
|
|
67
|
+
} {
|
|
68
|
+
const duc = stats.ductility ?? 500
|
|
69
|
+
const pla = stats.plasticity ?? 500
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
mass: Math.max(200, 2000 - Math.floor(duc * 2)),
|
|
73
|
+
thrust: 1 + Math.floor(pla / 500),
|
|
74
|
+
quantity: 1,
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function computeManufacturingCapabilities(stats: Record<string, number>): {
|
|
79
|
+
speed: number
|
|
80
|
+
drain: number
|
|
81
|
+
} {
|
|
82
|
+
const rea = stats.reactivity ?? 500
|
|
83
|
+
const clr = stats.clarity ?? 500
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
speed: 100 + Math.floor(rea * 4 / 5),
|
|
87
|
+
drain: Math.max(5, 30 - Math.floor(clr / 33)),
|
|
88
|
+
}
|
|
89
|
+
}
|
package/src/entities/ship.ts
CHANGED
|
@@ -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 {
|
|
@@ -29,12 +28,12 @@ export interface ShipStateInput {
|
|
|
29
28
|
owner: string
|
|
30
29
|
name: string
|
|
31
30
|
coordinates: CoordinatesType | {x: number; y: number; z?: number}
|
|
32
|
-
hullmass
|
|
33
|
-
capacity
|
|
34
|
-
energy
|
|
35
|
-
engines
|
|
36
|
-
generator
|
|
37
|
-
loaders
|
|
31
|
+
hullmass?: number
|
|
32
|
+
capacity?: number
|
|
33
|
+
energy?: number
|
|
34
|
+
engines?: ServerContract.Types.movement_stats
|
|
35
|
+
generator?: ServerContract.Types.energy_stats
|
|
36
|
+
loaders?: ServerContract.Types.loader_stats
|
|
38
37
|
schedule?: ServerContract.Types.schedule
|
|
39
38
|
cargo?: ServerContract.Types.cargo_item[]
|
|
40
39
|
}
|
|
@@ -109,6 +108,14 @@ export class Ship extends ServerContract.Types.entity_info {
|
|
|
109
108
|
return schedule.isExtracting(this, now)
|
|
110
109
|
}
|
|
111
110
|
|
|
111
|
+
get hasEngines(): boolean {
|
|
112
|
+
return this.engines !== undefined
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get hasGenerator(): boolean {
|
|
116
|
+
return this.generator !== undefined
|
|
117
|
+
}
|
|
118
|
+
|
|
112
119
|
get hasExtractor(): boolean {
|
|
113
120
|
return this.extractor !== undefined
|
|
114
121
|
}
|
|
@@ -133,10 +140,6 @@ export class Ship extends ServerContract.Types.entity_info {
|
|
|
133
140
|
return this.inv.totalMass
|
|
134
141
|
}
|
|
135
142
|
|
|
136
|
-
get cargoValue(): UInt64 {
|
|
137
|
-
return this.inv.totalValue
|
|
138
|
-
}
|
|
139
|
-
|
|
140
143
|
get totalMass(): UInt64 {
|
|
141
144
|
let mass = UInt64.from(this.hullmass ?? 0).adding(this.totalCargoMass)
|
|
142
145
|
if (this.loaders) {
|
|
@@ -193,20 +196,4 @@ export class Ship extends ServerContract.Types.entity_info {
|
|
|
193
196
|
if (!this.engines || !this.generator || this.energy === undefined) return false
|
|
194
197
|
return hasEnergyForDistance(this as MovementEntity, distance)
|
|
195
198
|
}
|
|
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
199
|
}
|
package/src/index-module.ts
CHANGED
|
@@ -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, getRarityMultiplier, Rarities} from './market/market'
|
|
51
|
-
export type {Rarity} from './market/market'
|
|
52
49
|
export {
|
|
53
50
|
getSystemName,
|
|
54
51
|
hasSystem,
|
|
@@ -91,31 +88,6 @@ export type {StatDefinition, NamedStats} from './derivation'
|
|
|
91
88
|
|
|
92
89
|
export {hash, hash512} from './utils/hash'
|
|
93
90
|
|
|
94
|
-
export type {Deal, FindDealsOptions} from './trading/deal'
|
|
95
|
-
export {findDealsForShip, findBestDeal} from './trading/deal'
|
|
96
|
-
|
|
97
|
-
export type {
|
|
98
|
-
CollectActionType,
|
|
99
|
-
CollectOption,
|
|
100
|
-
CollectAnalysis,
|
|
101
|
-
CollectAnalysisOptions,
|
|
102
|
-
CollectAnalysisCallbacks,
|
|
103
|
-
BetterSaleLocation,
|
|
104
|
-
RepositionLocation,
|
|
105
|
-
DiscountedItemInfo,
|
|
106
|
-
PotentialDeal,
|
|
107
|
-
CargoSaleItem,
|
|
108
|
-
} from './trading/collect'
|
|
109
|
-
export {
|
|
110
|
-
analyzeCollectOptions,
|
|
111
|
-
analyzeCargoSale,
|
|
112
|
-
createSellAndTradeOption,
|
|
113
|
-
createTravelToSellOption,
|
|
114
|
-
createSellAndRepositionOption,
|
|
115
|
-
createSellAndStayOption,
|
|
116
|
-
createExploreOption,
|
|
117
|
-
} from './trading/collect'
|
|
118
|
-
|
|
119
91
|
export {
|
|
120
92
|
distanceBetweenCoordinates,
|
|
121
93
|
distanceBetweenPoints,
|
|
@@ -153,19 +125,6 @@ export type {
|
|
|
153
125
|
HasScheduleAndLocation,
|
|
154
126
|
} from './travel/travel'
|
|
155
127
|
|
|
156
|
-
export {
|
|
157
|
-
calculateUpdatedCargoCost,
|
|
158
|
-
calculateMaxTradeQuantity,
|
|
159
|
-
calculateTradeProfit,
|
|
160
|
-
calculateProfitPerMass,
|
|
161
|
-
calculateProfitPerSecond,
|
|
162
|
-
findBestItemToTrade,
|
|
163
|
-
calculateBreakEvenPrice,
|
|
164
|
-
isProfitable,
|
|
165
|
-
calculateROI,
|
|
166
|
-
} from './trading/trade'
|
|
167
|
-
export type {TradeCalculation, TradeProfitResult} from './trading/trade'
|
|
168
|
-
|
|
169
128
|
export * as schedule from './scheduling/schedule'
|
|
170
129
|
export type {Scheduleable, ScheduleData} from './scheduling/schedule'
|
|
171
130
|
export {ScheduleAccessor, createScheduleAccessor} from './scheduling/accessor'
|
|
@@ -181,3 +140,69 @@ export type {Projectable, ProjectedEntity} from './scheduling/projection'
|
|
|
181
140
|
export * from './types/capabilities'
|
|
182
141
|
export * from './types/entity'
|
|
183
142
|
export * from './capabilities'
|
|
143
|
+
|
|
144
|
+
export {categoryColors, tierColors, categoryIcons, componentIcon, moduleIcon} from './data/colors'
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
components,
|
|
148
|
+
entityRecipes,
|
|
149
|
+
moduleRecipes,
|
|
150
|
+
getComponentById,
|
|
151
|
+
getEntityRecipe,
|
|
152
|
+
getEntityRecipeByItemId,
|
|
153
|
+
getModuleRecipe,
|
|
154
|
+
getModuleRecipeByItemId,
|
|
155
|
+
getAllCraftableItems,
|
|
156
|
+
getComponentsForCategory,
|
|
157
|
+
getComponentsForStat,
|
|
158
|
+
ITEM_HULL_PLATES,
|
|
159
|
+
ITEM_CARGO_LINING,
|
|
160
|
+
ITEM_CONTAINER_PACKED,
|
|
161
|
+
ITEM_THRUSTER_CORE,
|
|
162
|
+
ITEM_POWER_CELL,
|
|
163
|
+
ITEM_ENGINE_T1,
|
|
164
|
+
ITEM_GENERATOR_T1,
|
|
165
|
+
ITEM_SHIP_T1_PACKED,
|
|
166
|
+
ITEM_DRILL_SHAFT,
|
|
167
|
+
ITEM_EXTRACTION_PROBE,
|
|
168
|
+
ITEM_CARGO_ARM,
|
|
169
|
+
ITEM_TOOL_BIT,
|
|
170
|
+
ITEM_REACTION_CHAMBER,
|
|
171
|
+
ITEM_EXTRACTOR_T1,
|
|
172
|
+
ITEM_LOADER_T1,
|
|
173
|
+
ITEM_MANUFACTURING_T1,
|
|
174
|
+
} from './data/recipes'
|
|
175
|
+
export type {
|
|
176
|
+
ComponentDefinition,
|
|
177
|
+
ComponentStat,
|
|
178
|
+
RecipeInput,
|
|
179
|
+
EntityRecipe,
|
|
180
|
+
ModuleRecipe,
|
|
181
|
+
CraftableItem,
|
|
182
|
+
} from './data/recipes'
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
encodeStats,
|
|
186
|
+
decodeStats,
|
|
187
|
+
decodeCraftedItemStats,
|
|
188
|
+
blendStacks,
|
|
189
|
+
computeComponentStats,
|
|
190
|
+
blendComponentStacks,
|
|
191
|
+
computeEntityStats,
|
|
192
|
+
blendCargoStacks,
|
|
193
|
+
} from './derivation/crafting'
|
|
194
|
+
export type {StackInput, CategoryStacks} from './derivation/crafting'
|
|
195
|
+
|
|
196
|
+
export {computeContainerCapabilities} from './entities/container'
|
|
197
|
+
|
|
198
|
+
export {
|
|
199
|
+
computeShipHullCapabilities,
|
|
200
|
+
computeEngineCapabilities,
|
|
201
|
+
computeGeneratorCapabilities,
|
|
202
|
+
computeExtractorCapabilities,
|
|
203
|
+
computeLoaderCapabilities,
|
|
204
|
+
computeManufacturingCapabilities,
|
|
205
|
+
} from './entities/ship-deploy'
|
|
206
|
+
|
|
207
|
+
export {resolveItem} from './resolution/resolve-item'
|
|
208
|
+
export type {ResolvedItem, ResolvedItemStat, ResolvedAttributeGroup, ResolvedItemType} from './resolution/resolve-item'
|