@shipload/sdk 2.0.0-rc2 → 2.0.0-rc4

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 (39) hide show
  1. package/lib/shipload.d.ts +319 -137
  2. package/lib/shipload.js +3253 -1812
  3. package/lib/shipload.js.map +1 -1
  4. package/lib/shipload.m.js +2657 -1131
  5. package/lib/shipload.m.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/capabilities/extraction.ts +14 -21
  8. package/src/capabilities/storage.ts +2 -2
  9. package/src/contracts/server.ts +311 -120
  10. package/src/data/items.json +16 -0
  11. package/src/data/nebula-adjectives.json +211 -0
  12. package/src/data/nebula-nouns.json +151 -0
  13. package/src/data/syllables.json +1386 -780
  14. package/src/derivation/index.ts +25 -0
  15. package/src/derivation/location-size.ts +15 -0
  16. package/src/derivation/resources.ts +141 -0
  17. package/src/derivation/stratum.ts +118 -0
  18. package/src/entities/cargo-utils.ts +8 -8
  19. package/src/entities/entity-inventory.ts +13 -9
  20. package/src/entities/inventory-accessor.ts +2 -2
  21. package/src/entities/location.ts +10 -10
  22. package/src/entities/ship.ts +10 -6
  23. package/src/entities/warehouse.ts +2 -2
  24. package/src/errors.ts +4 -4
  25. package/src/index-module.ts +31 -6
  26. package/src/managers/actions.ts +21 -9
  27. package/src/managers/locations.ts +7 -7
  28. package/src/managers/trades.ts +5 -5
  29. package/src/market/items.ts +31 -0
  30. package/src/market/market.ts +9 -9
  31. package/src/scheduling/projection.ts +7 -7
  32. package/src/trading/collect.ts +25 -25
  33. package/src/trading/deal.ts +8 -8
  34. package/src/trading/trade.ts +9 -9
  35. package/src/travel/travel.ts +6 -6
  36. package/src/types.ts +17 -7
  37. package/src/utils/system.ts +51 -52
  38. package/src/data/goods.json +0 -23
  39. package/src/market/goods.ts +0 -31
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipload/sdk",
3
3
  "description": "SDKs for Shipload",
4
- "version": "2.0.0-rc2",
4
+ "version": "2.0.0-rc4",
5
5
  "homepage": "https://github.com/shipload/sdk",
6
6
  "license": "MIT",
7
7
  "main": "lib/shipload.js",
@@ -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
- loaders: ServerContract.Types.loader_stats,
23
- shipZ: number,
24
- batchMass: number
7
+ cargoMass: number,
8
+ stratum: number,
9
+ richness: number
25
10
  ): UInt32 {
26
- const extractionTime = Math.floor(batchMass / extractor.rate.toNumber())
27
- const loadingTime = calc_load_time_internal(loaders, shipZ, batchMass)
28
- return UInt32.from(Math.max(extractionTime, loadingTime))
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 {getGood} from '../market/goods'
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 = getGood(item.good_id)
21
+ const good = getItem(item.item_id)
22
22
  mass = mass.adding(good.mass.multiplying(item.quantity))
23
23
  }
24
24
  return mass