@shipload/sdk 2.0.0-rc2 → 2.0.0-rc3
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/lib/shipload.d.ts +271 -137
- package/lib/shipload.js +1375 -1022
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +780 -342
- package/lib/shipload.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/extraction.ts +14 -21
- package/src/capabilities/storage.ts +2 -2
- package/src/contracts/server.ts +239 -120
- package/src/data/items.json +16 -0
- package/src/derivation/index.ts +25 -0
- package/src/derivation/location-size.ts +15 -0
- package/src/derivation/resources.ts +141 -0
- package/src/derivation/stratum.ts +116 -0
- package/src/entities/cargo-utils.ts +8 -8
- package/src/entities/entity-inventory.ts +13 -9
- package/src/entities/inventory-accessor.ts +2 -2
- package/src/entities/location.ts +10 -10
- package/src/entities/ship.ts +10 -6
- package/src/entities/warehouse.ts +2 -2
- package/src/errors.ts +4 -4
- package/src/index-module.ts +31 -6
- package/src/managers/actions.ts +21 -9
- package/src/managers/locations.ts +7 -7
- package/src/managers/trades.ts +5 -5
- package/src/market/items.ts +31 -0
- package/src/market/market.ts +9 -9
- package/src/scheduling/projection.ts +7 -7
- package/src/trading/collect.ts +25 -25
- package/src/trading/deal.ts +8 -8
- package/src/trading/trade.ts +9 -9
- package/src/travel/travel.ts +6 -6
- package/src/types.ts +17 -7
- package/src/utils/system.ts +7 -42
- package/src/data/goods.json +0 -23
- package/src/market/goods.ts +0 -31
package/package.json
CHANGED
|
@@ -2,30 +2,23 @@ import {UInt16, UInt32} from '@wharfkit/antelope'
|
|
|
2
2
|
import {ServerContract} from '../contracts'
|
|
3
3
|
import {PRECISION} from '../types'
|
|
4
4
|
|
|
5
|
-
function calc_load_time_internal(
|
|
6
|
-
loaders: ServerContract.Types.loader_stats,
|
|
7
|
-
shipZ: number,
|
|
8
|
-
cargoMass: number
|
|
9
|
-
): number {
|
|
10
|
-
if (cargoMass === 0 || loaders.quantity.toNumber() === 0 || loaders.thrust.toNumber() === 0) {
|
|
11
|
-
return 0
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const totalMass = cargoMass + loaders.mass.toNumber()
|
|
15
|
-
const acceleration = (loaders.thrust.toNumber() / totalMass) * PRECISION
|
|
16
|
-
const flightTime = Math.floor(2 * Math.sqrt(shipZ / acceleration))
|
|
17
|
-
return Math.floor(flightTime / loaders.quantity.toNumber())
|
|
18
|
-
}
|
|
19
|
-
|
|
20
5
|
export function calc_extraction_duration(
|
|
21
6
|
extractor: ServerContract.Types.extractor_stats,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
cargoMass: number,
|
|
8
|
+
stratum: number,
|
|
9
|
+
richness: number
|
|
25
10
|
): UInt32 {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
11
|
+
const rate = extractor.rate.toNumber()
|
|
12
|
+
const efficiency = extractor.efficiency.toNumber()
|
|
13
|
+
const drill = extractor.drill.toNumber()
|
|
14
|
+
|
|
15
|
+
const rateProduct = Math.floor((rate * richness * efficiency) / PRECISION)
|
|
16
|
+
if (rateProduct === 0) return UInt32.from(0)
|
|
17
|
+
|
|
18
|
+
const extractionTime = Math.floor((cargoMass * PRECISION) / rateProduct)
|
|
19
|
+
const drillTime = Math.floor(stratum / drill)
|
|
20
|
+
|
|
21
|
+
return UInt32.from(extractionTime + drillTime)
|
|
29
22
|
}
|
|
30
23
|
|
|
31
24
|
export function calc_extraction_energy(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {UInt32, UInt64, UInt64Type} from '@wharfkit/antelope'
|
|
2
2
|
import {ServerContract} from '../contracts'
|
|
3
3
|
import {StorageCapability} from '../types/capabilities'
|
|
4
|
-
import {
|
|
4
|
+
import {getItem} from '../market/items'
|
|
5
5
|
|
|
6
6
|
export interface HasCargo {
|
|
7
7
|
cargo: ServerContract.Types.cargo_item[]
|
|
@@ -18,7 +18,7 @@ export interface HasCargomass {
|
|
|
18
18
|
export function calcCargoMass(entity: HasCargo): UInt64 {
|
|
19
19
|
let mass = UInt64.from(0)
|
|
20
20
|
for (const item of entity.cargo) {
|
|
21
|
-
const good =
|
|
21
|
+
const good = getItem(item.item_id)
|
|
22
22
|
mass = mass.adding(good.mass.multiplying(item.quantity))
|
|
23
23
|
}
|
|
24
24
|
return mass
|