@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.
Files changed (52) hide show
  1. package/README.md +1 -349
  2. package/lib/shipload.d.ts +607 -1113
  3. package/lib/shipload.js +1482 -2077
  4. package/lib/shipload.js.map +1 -1
  5. package/lib/shipload.m.js +1421 -2038
  6. package/lib/shipload.m.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/capabilities/crafting.ts +28 -0
  9. package/src/capabilities/extraction.ts +14 -8
  10. package/src/capabilities/guards.ts +0 -5
  11. package/src/capabilities/index.ts +2 -0
  12. package/src/capabilities/modules.ts +49 -0
  13. package/src/capabilities/storage.ts +0 -8
  14. package/src/contracts/server.ts +231 -313
  15. package/src/data/colors.ts +28 -0
  16. package/src/data/items.json +15 -15
  17. package/src/data/recipes.ts +351 -0
  18. package/src/derivation/crafting.ts +142 -0
  19. package/src/derivation/index.ts +1 -0
  20. package/src/derivation/stats.ts +91 -15
  21. package/src/derivation/stratum.ts +2 -2
  22. package/src/entities/cargo-utils.ts +6 -64
  23. package/src/entities/container.ts +18 -0
  24. package/src/entities/entity-inventory.ts +0 -4
  25. package/src/entities/inventory-accessor.ts +0 -4
  26. package/src/entities/location.ts +2 -197
  27. package/src/entities/makers.ts +10 -9
  28. package/src/entities/player.ts +1 -274
  29. package/src/entities/ship-deploy.ts +89 -0
  30. package/src/entities/ship.ts +14 -27
  31. package/src/entities/warehouse.ts +0 -4
  32. package/src/index-module.ts +66 -41
  33. package/src/managers/actions.ts +77 -88
  34. package/src/managers/context.ts +0 -9
  35. package/src/managers/index.ts +0 -1
  36. package/src/managers/locations.ts +2 -85
  37. package/src/market/items.ts +0 -1
  38. package/src/resolution/resolve-item.ts +242 -0
  39. package/src/scheduling/projection.ts +0 -10
  40. package/src/shipload.ts +0 -5
  41. package/src/travel/travel.ts +3 -3
  42. package/src/types/capabilities.ts +1 -9
  43. package/src/types/entity-traits.ts +3 -4
  44. package/src/types/entity.ts +3 -4
  45. package/src/types.ts +6 -43
  46. package/src/utils/system.ts +5 -4
  47. package/src/managers/trades.ts +0 -119
  48. package/src/market/market.ts +0 -195
  49. package/src/market/rolls.ts +0 -8
  50. package/src/trading/collect.ts +0 -938
  51. package/src/trading/deal.ts +0 -207
  52. package/src/trading/trade.ts +0 -203
package/lib/shipload.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _wharfkit_antelope from '@wharfkit/antelope';
2
- import { Blob, ABI, Struct, Name, UInt64, Checksum256, UInt32, TimePointSec, Checksum256Type, UInt32Type, NameType, UInt64Type, Action, UInt16, UInt8, TimePoint, Int64, UInt16Type, UInt8Type, TimePointType, Int64Type, Checksum512, APIClient } from '@wharfkit/antelope';
2
+ import { Blob, ABI, Struct, Name, UInt64, Checksum256, UInt32, TimePointSec, Checksum256Type, UInt32Type, NameType, UInt64Type, Action, UInt8, UInt16, TimePoint, Int64, UInt16Type, UInt8Type, TimePointType, Int64Type, Checksum512, APIClient } from '@wharfkit/antelope';
3
3
  import * as _wharfkit_contract from '@wharfkit/contract';
4
4
  import { Contract as Contract$2, PartialBy, ContractArgs, ActionOptions, Table } from '@wharfkit/contract';
5
5
  import { ChainDefinition } from '@wharfkit/session';
@@ -158,29 +158,35 @@ declare namespace platform {
158
158
  declare const abiBlob: Blob;
159
159
  declare const abi: ABI;
160
160
  declare namespace Types {
161
+ class addmodule extends Struct {
162
+ entity_type: Name;
163
+ entity_id: UInt64;
164
+ module_index: UInt8;
165
+ module_cargo_id: UInt64;
166
+ target_cargo_id: UInt64;
167
+ }
161
168
  class advance extends Struct {
162
169
  reveal: string;
163
170
  commit: Checksum256;
164
171
  }
165
- class buycontainer extends Struct {
166
- account: Name;
167
- ship_id: UInt64;
168
- name: string;
172
+ class cargo_seed extends Struct {
173
+ item_id: UInt16;
174
+ seed: UInt64;
169
175
  }
170
- class buyitems extends Struct {
171
- entity_type: Name;
172
- id: UInt64;
176
+ class module_entry extends Struct {
177
+ type: UInt8;
178
+ installed?: cargo_seed;
179
+ }
180
+ class cargo_item extends Struct {
173
181
  item_id: UInt16;
174
182
  quantity: UInt32;
183
+ seed?: UInt64;
184
+ modules: module_entry[];
175
185
  }
176
- class buyship extends Struct {
177
- account: Name;
178
- name: string;
179
- }
180
- class buywarehouse extends Struct {
181
- account: Name;
182
- ship_id: UInt64;
183
- name: string;
186
+ class blend extends Struct {
187
+ entity_type: Name;
188
+ id: UInt64;
189
+ inputs: cargo_item[];
184
190
  }
185
191
  class cancel extends Struct {
186
192
  entity_type: Name;
@@ -199,19 +205,13 @@ declare namespace Types {
199
205
  entitygroup?: UInt64;
200
206
  group_members?: entity_ref[];
201
207
  }
202
- class cargo_item extends Struct {
203
- item_id: UInt16;
204
- quantity: UInt32;
205
- unit_cost: UInt64;
206
- seed?: UInt64;
207
- }
208
208
  class cargo_row extends Struct {
209
209
  id: UInt64;
210
210
  entity_id: UInt64;
211
211
  item_id: UInt64;
212
212
  quantity: UInt64;
213
- unit_cost: UInt64;
214
213
  seed: UInt64;
214
+ modules: module_entry[];
215
215
  }
216
216
  class cleanrsvp extends Struct {
217
217
  epoch: UInt64;
@@ -225,43 +225,12 @@ declare namespace Types {
225
225
  class commit extends Struct {
226
226
  commit: Checksum256;
227
227
  }
228
- class movement_stats extends Struct {
229
- thrust: UInt32;
230
- drain: UInt16;
231
- }
232
- class energy_stats extends Struct {
233
- capacity: UInt16;
234
- recharge: UInt16;
235
- }
236
228
  class loader_stats extends Struct {
237
229
  mass: UInt32;
238
230
  thrust: UInt16;
239
231
  quantity: UInt8;
240
232
  }
241
- class trade_stats extends Struct {
242
- margin: UInt16;
243
- }
244
- class extractor_stats extends Struct {
245
- rate: UInt16;
246
- drain: UInt16;
247
- efficiency: UInt16;
248
- depth: UInt16;
249
- drill: UInt16;
250
- }
251
- class warp_stats extends Struct {
252
- range: UInt32;
253
- }
254
233
  class entity_defaults extends Struct {
255
- ship_hullmass: UInt32;
256
- ship_capacity: UInt32;
257
- ship_energy: UInt16;
258
- ship_z: UInt16;
259
- ship_engines: movement_stats;
260
- ship_generator: energy_stats;
261
- ship_loaders: loader_stats;
262
- ship_trade: trade_stats;
263
- ship_extractor: extractor_stats;
264
- ship_warp: warp_stats;
265
234
  warehouse_capacity: UInt32;
266
235
  warehouse_z: UInt16;
267
236
  warehouse_loaders: loader_stats;
@@ -271,7 +240,6 @@ declare namespace Types {
271
240
  }
272
241
  class item_def extends Struct {
273
242
  id: UInt16;
274
- base_price: UInt32;
275
243
  mass: UInt32;
276
244
  }
277
245
  class game_config extends Struct {
@@ -295,7 +263,6 @@ declare namespace Types {
295
263
  cargo: cargo_item[];
296
264
  entitytarget?: entity_ref;
297
265
  entitygroup?: UInt64;
298
- credits?: Int64;
299
266
  energy_cost?: UInt16;
300
267
  }
301
268
  class schedule extends Struct {
@@ -312,13 +279,55 @@ declare namespace Types {
312
279
  cargomass: UInt32;
313
280
  schedule?: schedule;
314
281
  }
282
+ class craft extends Struct {
283
+ entity_type: Name;
284
+ id: UInt64;
285
+ recipe_id: UInt16;
286
+ quantity: UInt32;
287
+ inputs: cargo_item[];
288
+ }
289
+ class crafter_stats extends Struct {
290
+ speed: UInt16;
291
+ drain: UInt16;
292
+ }
293
+ class createentity extends Struct {
294
+ owner: Name;
295
+ entity_type: Name;
296
+ entity_name: string;
297
+ x: Int64;
298
+ y: Int64;
299
+ }
300
+ class deploy extends Struct {
301
+ entity_type: Name;
302
+ id: UInt64;
303
+ packed_item_id: UInt16;
304
+ seed: UInt64;
305
+ entity_name: string;
306
+ }
315
307
  class enable extends Struct {
316
308
  enabled: boolean;
317
309
  }
310
+ class energy_stats extends Struct {
311
+ capacity: UInt16;
312
+ recharge: UInt16;
313
+ }
318
314
  class entity_current_state extends Struct {
319
315
  coordinates: coordinates;
320
316
  energy: UInt16;
321
317
  }
318
+ class movement_stats extends Struct {
319
+ thrust: UInt32;
320
+ drain: UInt16;
321
+ }
322
+ class extractor_stats extends Struct {
323
+ rate: UInt16;
324
+ drain: UInt16;
325
+ depth: UInt16;
326
+ drill: UInt16;
327
+ }
328
+ class warp_stats extends Struct {
329
+ range: UInt32;
330
+ }
322
331
  class entity_info extends Struct {
323
332
  type: Name;
324
333
  id: UInt64;
@@ -335,6 +344,7 @@ declare namespace Types {
335
344
  capacity?: UInt32;
336
345
  extractor?: extractor_stats;
337
346
  warp?: warp_stats;
347
+ crafter?: crafter_stats;
338
348
  is_idle: boolean;
339
349
  current_task?: task;
340
350
  current_task_elapsed: UInt32;
@@ -397,8 +407,6 @@ declare namespace Types {
397
407
  class getplayer extends Struct {
398
408
  account: Name;
399
409
  }
400
- class getstarter extends Struct {
401
- }
402
410
  class getstratum extends Struct {
403
411
  x: Int64;
404
412
  y: Int64;
@@ -446,17 +454,9 @@ declare namespace Types {
446
454
  epoch_props: location_epoch;
447
455
  size: UInt16;
448
456
  }
449
- class location_item extends Struct {
450
- id: UInt16;
451
- price: UInt32;
452
- supply: UInt16;
453
- rarity_multiplier: UInt32;
454
- location_multiplier: UInt32;
455
- }
456
457
  class location_info extends Struct {
457
458
  coords: coordinates;
458
459
  is_system: boolean;
459
- items: location_item[];
460
460
  }
461
461
  class location_row extends Struct {
462
462
  id: UInt64;
@@ -493,33 +493,16 @@ declare namespace Types {
493
493
  class notify extends Struct {
494
494
  event: task_event;
495
495
  }
496
- class payloan extends Struct {
497
- account: Name;
498
- amount: UInt64;
499
- }
500
496
  class player_info extends Struct {
501
497
  owner: Name;
502
498
  is_player: boolean;
503
499
  company_name: string;
504
- balance: UInt64;
505
- debt: UInt32;
506
- networth: Int64;
507
- available_loan: UInt64;
508
- next_ship_price: UInt64;
509
- next_warehouse_price: UInt64;
510
- next_container_price: UInt64;
511
500
  ship_count: UInt64;
512
501
  warehouse_count: UInt64;
513
502
  container_count: UInt64;
514
503
  }
515
504
  class player_row extends Struct {
516
505
  owner: Name;
517
- balance: UInt64;
518
- debt: UInt32;
519
- networth: Int64;
520
- }
521
- class purgesupply extends Struct {
522
- max_rows?: UInt64;
523
506
  }
524
507
  class recharge extends Struct {
525
508
  entity_type: Name;
@@ -547,15 +530,15 @@ declare namespace Types {
547
530
  stat2: UInt16;
548
531
  stat3: UInt16;
549
532
  }
533
+ class rmmodule extends Struct {
534
+ entity_type: Name;
535
+ entity_id: UInt64;
536
+ module_index: UInt8;
537
+ target_cargo_id: UInt64;
538
+ }
550
539
  class salt extends Struct {
551
540
  salt: UInt64;
552
541
  }
553
- class sellitems extends Struct {
554
- entity_type: Name;
555
- id: UInt64;
556
- item_id: UInt16;
557
- quantity: UInt32;
558
- }
559
542
  class sequence_row extends Struct {
560
543
  key: Name;
561
544
  value: UInt64;
@@ -565,22 +548,29 @@ declare namespace Types {
565
548
  owner: Name;
566
549
  name: string;
567
550
  coordinates: coordinates;
568
- hullmass: UInt32;
569
- capacity: UInt32;
570
- energy: UInt16;
551
+ hullmass?: UInt32;
552
+ capacity?: UInt32;
553
+ energy?: UInt16;
571
554
  cargomass: UInt32;
572
- engines: movement_stats;
573
- generator: energy_stats;
574
- loaders: loader_stats;
575
- trade?: trade_stats;
555
+ engines?: movement_stats;
556
+ generator?: energy_stats;
557
+ loaders?: loader_stats;
576
558
  extractor?: extractor_stats;
577
559
  warp?: warp_stats;
560
+ crafter?: crafter_stats;
561
+ modules: module_entry[];
578
562
  schedule?: schedule;
579
563
  }
580
- class starter_info extends Struct {
581
- balance: UInt64;
582
- debt: UInt64;
583
- ship: entity_info;
564
+ class spawncargo extends Struct {
565
+ entity_id: UInt64;
566
+ item_id: UInt64;
567
+ quantity: UInt64;
568
+ }
569
+ class spawnseeded extends Struct {
570
+ entity_id: UInt64;
571
+ item_id: UInt64;
572
+ quantity: UInt64;
573
+ seed: UInt64;
584
574
  }
585
575
  class state_row extends Struct {
586
576
  enabled: boolean;
@@ -600,17 +590,6 @@ declare namespace Types {
600
590
  stratum: stratum_info;
601
591
  stats: resource_stats;
602
592
  }
603
- class supply_row extends Struct {
604
- id: UInt64;
605
- coordinates: coordinates;
606
- epoch: UInt64;
607
- item_id: UInt16;
608
- supply: UInt16;
609
- }
610
- class takeloan extends Struct {
611
- account: Name;
612
- amount: UInt64;
613
- }
614
593
  class task_results extends Struct {
615
594
  entities: entity_task_info[];
616
595
  }
@@ -632,17 +611,8 @@ declare namespace Types {
632
611
  class types_row extends Struct {
633
612
  id: UInt64;
634
613
  entity_summary_type: entity_summary;
635
- starter_info_type: starter_info;
636
614
  game_config_type: game_config;
637
615
  }
638
- class updatecredit extends Struct {
639
- account: Name;
640
- amount: Int64;
641
- }
642
- class updatedebt extends Struct {
643
- account: Name;
644
- amount: Int64;
645
- }
646
616
  class warehouse_row extends Struct {
647
617
  id: UInt64;
648
618
  owner: Name;
@@ -674,7 +644,6 @@ declare const TableMap: {
674
644
  sequence: typeof Types.sequence_row;
675
645
  ship: typeof Types.ship_row;
676
646
  state: typeof Types.state_row;
677
- supply: typeof Types.supply_row;
678
647
  types: typeof Types.types_row;
679
648
  warehouse: typeof Types.warehouse_row;
680
649
  };
@@ -688,7 +657,6 @@ interface TableTypes {
688
657
  sequence: Types.sequence_row;
689
658
  ship: Types.ship_row;
690
659
  state: Types.state_row;
691
- supply: Types.supply_row;
692
660
  types: Types.types_row;
693
661
  warehouse: Types.warehouse_row;
694
662
  }
@@ -696,22 +664,26 @@ type RowType<T> = T extends keyof TableTypes ? TableTypes[T] : any;
696
664
  type TableNames = keyof TableTypes;
697
665
  declare namespace ActionParams {
698
666
  namespace Type {
667
+ interface cargo_item {
668
+ item_id: UInt16Type;
669
+ quantity: UInt32Type;
670
+ seed?: UInt64Type;
671
+ modules: Type.module_entry[];
672
+ }
673
+ interface module_entry {
674
+ type: UInt8Type;
675
+ installed?: Type.cargo_seed;
676
+ }
677
+ interface cargo_seed {
678
+ item_id: UInt16Type;
679
+ seed: UInt64Type;
680
+ }
699
681
  interface game_config {
700
682
  version: UInt32Type;
701
683
  defaults: Type.entity_defaults;
702
684
  items: Type.item_def[];
703
685
  }
704
686
  interface entity_defaults {
705
- ship_hullmass: UInt32Type;
706
- ship_capacity: UInt32Type;
707
- ship_energy: UInt16Type;
708
- ship_z: UInt16Type;
709
- ship_engines: Type.movement_stats;
710
- ship_generator: Type.energy_stats;
711
- ship_loaders: Type.loader_stats;
712
- ship_trade: Type.trade_stats;
713
- ship_extractor: Type.extractor_stats;
714
- ship_warp: Type.warp_stats;
715
687
  warehouse_capacity: UInt32Type;
716
688
  warehouse_z: UInt16Type;
717
689
  warehouse_loaders: Type.loader_stats;
@@ -719,35 +691,13 @@ declare namespace ActionParams {
719
691
  container_capacity: UInt32Type;
720
692
  container_z: UInt16Type;
721
693
  }
722
- interface movement_stats {
723
- thrust: UInt32Type;
724
- drain: UInt16Type;
725
- }
726
- interface energy_stats {
727
- capacity: UInt16Type;
728
- recharge: UInt16Type;
729
- }
730
694
  interface loader_stats {
731
695
  mass: UInt32Type;
732
696
  thrust: UInt16Type;
733
697
  quantity: UInt8Type;
734
698
  }
735
- interface trade_stats {
736
- margin: UInt16Type;
737
- }
738
- interface extractor_stats {
739
- rate: UInt16Type;
740
- drain: UInt16Type;
741
- efficiency: UInt16Type;
742
- depth: UInt16Type;
743
- drill: UInt16Type;
744
- }
745
- interface warp_stats {
746
- range: UInt32Type;
747
- }
748
699
  interface item_def {
749
700
  id: UInt16Type;
750
- base_price: UInt32Type;
751
701
  mass: UInt32Type;
752
702
  }
753
703
  interface entity_ref {
@@ -773,7 +723,6 @@ declare namespace ActionParams {
773
723
  cargo: Type.cargo_item[];
774
724
  entitytarget?: Type.entity_ref;
775
725
  entitygroup?: UInt64Type;
776
- credits?: Int64Type;
777
726
  energy_cost?: UInt16Type;
778
727
  }
779
728
  interface coordinates {
@@ -781,36 +730,22 @@ declare namespace ActionParams {
781
730
  y: Int64Type;
782
731
  z?: UInt16Type;
783
732
  }
784
- interface cargo_item {
785
- item_id: UInt16Type;
786
- quantity: UInt32Type;
787
- unit_cost: UInt64Type;
788
- seed?: UInt64Type;
789
- }
733
+ }
734
+ interface addmodule {
735
+ entity_type: NameType;
736
+ entity_id: UInt64Type;
737
+ module_index: UInt8Type;
738
+ module_cargo_id: UInt64Type;
739
+ target_cargo_id: UInt64Type;
790
740
  }
791
741
  interface advance {
792
742
  reveal: string;
793
743
  commit: Checksum256Type;
794
744
  }
795
- interface buycontainer {
796
- account: NameType;
797
- ship_id: UInt64Type;
798
- name: string;
799
- }
800
- interface buyitems {
745
+ interface blend {
801
746
  entity_type: NameType;
802
747
  id: UInt64Type;
803
- item_id: UInt16Type;
804
- quantity: UInt32Type;
805
- }
806
- interface buyship {
807
- account: NameType;
808
- name: string;
809
- }
810
- interface buywarehouse {
811
- account: NameType;
812
- ship_id: UInt64Type;
813
- name: string;
748
+ inputs: Type.cargo_item[];
814
749
  }
815
750
  interface cancel {
816
751
  entity_type: NameType;
@@ -832,6 +767,27 @@ declare namespace ActionParams {
832
767
  interface configlog {
833
768
  config: Type.game_config;
834
769
  }
770
+ interface craft {
771
+ entity_type: NameType;
772
+ id: UInt64Type;
773
+ recipe_id: UInt16Type;
774
+ quantity: UInt32Type;
775
+ inputs: Type.cargo_item[];
776
+ }
777
+ interface createentity {
778
+ owner: NameType;
779
+ entity_type: NameType;
780
+ entity_name: string;
781
+ x: Int64Type;
782
+ y: Int64Type;
783
+ }
784
+ interface deploy {
785
+ entity_type: NameType;
786
+ id: UInt64Type;
787
+ packed_item_id: UInt16Type;
788
+ seed: UInt64Type;
789
+ entity_name: string;
790
+ }
835
791
  interface enable {
836
792
  enabled: boolean;
837
793
  }
@@ -869,8 +825,6 @@ declare namespace ActionParams {
869
825
  interface getplayer {
870
826
  account: NameType;
871
827
  }
872
- interface getstarter {
873
- }
874
828
  interface getstratum {
875
829
  x: Int64Type;
876
830
  y: Int64Type;
@@ -901,13 +855,6 @@ declare namespace ActionParams {
901
855
  interface notify {
902
856
  event: Type.task_event;
903
857
  }
904
- interface payloan {
905
- account: NameType;
906
- amount: UInt64Type;
907
- }
908
- interface purgesupply {
909
- max_rows?: UInt64Type;
910
- }
911
858
  interface recharge {
912
859
  entity_type: NameType;
913
860
  id: UInt64Type;
@@ -917,18 +864,25 @@ declare namespace ActionParams {
917
864
  id: UInt64Type;
918
865
  count?: UInt64Type;
919
866
  }
867
+ interface rmmodule {
868
+ entity_type: NameType;
869
+ entity_id: UInt64Type;
870
+ module_index: UInt8Type;
871
+ target_cargo_id: UInt64Type;
872
+ }
920
873
  interface salt {
921
874
  salt: UInt64Type;
922
875
  }
923
- interface sellitems {
924
- entity_type: NameType;
925
- id: UInt64Type;
926
- item_id: UInt16Type;
927
- quantity: UInt32Type;
876
+ interface spawncargo {
877
+ entity_id: UInt64Type;
878
+ item_id: UInt64Type;
879
+ quantity: UInt64Type;
928
880
  }
929
- interface takeloan {
930
- account: NameType;
931
- amount: UInt64Type;
881
+ interface spawnseeded {
882
+ entity_id: UInt64Type;
883
+ item_id: UInt64Type;
884
+ quantity: UInt64Type;
885
+ seed: UInt64Type;
932
886
  }
933
887
  interface transfer {
934
888
  source_type: NameType;
@@ -945,14 +899,6 @@ declare namespace ActionParams {
945
899
  y: Int64Type;
946
900
  recharge: boolean;
947
901
  }
948
- interface updatecredit {
949
- account: NameType;
950
- amount: Int64Type;
951
- }
952
- interface updatedebt {
953
- account: NameType;
954
- amount: Int64Type;
955
- }
956
902
  interface warp {
957
903
  entity_type: NameType;
958
904
  id: UInt64Type;
@@ -965,16 +911,17 @@ declare namespace ActionParams {
965
911
  }
966
912
  }
967
913
  interface ActionNameParams {
914
+ addmodule: ActionParams.addmodule;
968
915
  advance: ActionParams.advance;
969
- buycontainer: ActionParams.buycontainer;
970
- buyitems: ActionParams.buyitems;
971
- buyship: ActionParams.buyship;
972
- buywarehouse: ActionParams.buywarehouse;
916
+ blend: ActionParams.blend;
973
917
  cancel: ActionParams.cancel;
974
918
  cleanrsvp: ActionParams.cleanrsvp;
975
919
  cleartable: ActionParams.cleartable;
976
920
  commit: ActionParams.commit;
977
921
  configlog: ActionParams.configlog;
922
+ craft: ActionParams.craft;
923
+ createentity: ActionParams.createentity;
924
+ deploy: ActionParams.deploy;
978
925
  enable: ActionParams.enable;
979
926
  extract: ActionParams.extract;
980
927
  getconfig: ActionParams.getconfig;
@@ -985,7 +932,6 @@ interface ActionNameParams {
985
932
  getlocdata: ActionParams.getlocdata;
986
933
  getnearby: ActionParams.getnearby;
987
934
  getplayer: ActionParams.getplayer;
988
- getstarter: ActionParams.getstarter;
989
935
  getstratum: ActionParams.getstratum;
990
936
  getsummaries: ActionParams.getsummaries;
991
937
  grouptravel: ActionParams.grouptravel;
@@ -994,25 +940,23 @@ interface ActionNameParams {
994
940
  init: ActionParams.init;
995
941
  join: ActionParams.join;
996
942
  notify: ActionParams.notify;
997
- payloan: ActionParams.payloan;
998
- purgesupply: ActionParams.purgesupply;
999
943
  recharge: ActionParams.recharge;
1000
944
  resolve: ActionParams.resolve;
945
+ rmmodule: ActionParams.rmmodule;
1001
946
  salt: ActionParams.salt;
1002
- sellitems: ActionParams.sellitems;
1003
- takeloan: ActionParams.takeloan;
947
+ spawncargo: ActionParams.spawncargo;
948
+ spawnseeded: ActionParams.spawnseeded;
1004
949
  transfer: ActionParams.transfer;
1005
950
  travel: ActionParams.travel;
1006
- updatecredit: ActionParams.updatecredit;
1007
- updatedebt: ActionParams.updatedebt;
1008
951
  warp: ActionParams.warp;
1009
952
  wipe: ActionParams.wipe;
1010
953
  wipesequence: ActionParams.wipesequence;
1011
954
  }
1012
955
  type ActionNames = keyof ActionNameParams;
1013
956
  interface ActionReturnValues {
1014
- buyitems: Types.task_results;
1015
957
  cancel: Types.cancel_results;
958
+ craft: Types.task_results;
959
+ deploy: Types.task_results;
1016
960
  extract: Types.task_results;
1017
961
  getconfig: Types.game_config;
1018
962
  getentities: Types.entity_info[];
@@ -1022,7 +966,6 @@ interface ActionReturnValues {
1022
966
  getlocdata: Types.location_derived;
1023
967
  getnearby: Types.nearby_info;
1024
968
  getplayer: Types.player_info;
1025
- getstarter: Types.starter_info;
1026
969
  getstratum: Types.stratum_data;
1027
970
  getsummaries: Types.entity_summary[];
1028
971
  grouptravel: Types.task_results;
@@ -1030,7 +973,6 @@ interface ActionReturnValues {
1030
973
  hash512: Checksum512;
1031
974
  recharge: Types.task_results;
1032
975
  resolve: Types.resolve_results;
1033
- sellitems: Types.task_results;
1034
976
  transfer: Types.task_results;
1035
977
  travel: Types.task_results;
1036
978
  warp: Types.task_results;
@@ -1120,17 +1062,6 @@ declare const WAREHOUSE_ALREADY_AT_LOCATION = "Warehouse already exists at this
1120
1062
  declare const WAREHOUSE_CAPACITY_EXCEEDED = "Warehouse capacity would be exceeded.";
1121
1063
 
1122
1064
  declare const PRECISION = 10000;
1123
- declare const INITIAL_SHIP_GENERATOR_CAPACITY = 350;
1124
- declare const INITIAL_SHIP_DRAIN = 25;
1125
- declare const INITIAL_SHIP_ENERGY = 350;
1126
- declare const INITIAL_SHIP_HULLMASS = 100000;
1127
- declare const INITIAL_SHIP_CAPACITY = 500000;
1128
- declare const INITIAL_SHIP_Z = 800;
1129
- declare const INITIAL_SHIP_RECHARGE = 10;
1130
- declare const INITIAL_SHIP_THRUST = 250;
1131
- declare const INITIAL_LOADER_MASS = 1000;
1132
- declare const INITIAL_LOADER_QUANTITY = 1;
1133
- declare const INITIAL_LOADER_THRUST = 1;
1134
1065
  declare const WAREHOUSE_Z = 500;
1135
1066
  declare const INITIAL_WAREHOUSE_CAPACITY = 10000000;
1136
1067
  declare const CONTAINER_Z = 300;
@@ -1139,10 +1070,7 @@ declare const INITIAL_CONTAINER_CAPACITY = 2000000;
1139
1070
  declare const TRAVEL_MAX_DURATION = 86400;
1140
1071
  declare const MIN_ORBITAL_ALTITUDE = 800;
1141
1072
  declare const MAX_ORBITAL_ALTITUDE = 3000;
1142
- declare const INITIAL_SHIP_MASS = 500000;
1143
- declare const INITIAL_EXTRACTOR_RATE = 700;
1144
- declare const INITIAL_EXTRACTOR_DRAIN = 2500;
1145
- declare const INITIAL_EXTRACTOR_EFFICIENCY = 5000;
1073
+ declare const BASE_ORBITAL_MASS = 100000;
1146
1074
  interface ShipLike {
1147
1075
  coordinates: Types.coordinates;
1148
1076
  hullmass: UInt32;
@@ -1163,7 +1091,9 @@ declare enum TaskType {
1163
1091
  LOAD = 3,
1164
1092
  UNLOAD = 4,
1165
1093
  EXTRACT = 5,
1166
- WARP = 6
1094
+ WARP = 6,
1095
+ CRAFT = 7,
1096
+ DEPLOY = 8
1167
1097
  }
1168
1098
  declare enum LocationType {
1169
1099
  EMPTY = 0,
@@ -1203,18 +1133,11 @@ declare class Item extends Struct {
1203
1133
  id: UInt16;
1204
1134
  name: string;
1205
1135
  description: string;
1206
- base_price: UInt32;
1207
1136
  mass: UInt32;
1208
1137
  category: ResourceCategory;
1209
1138
  tier: ResourceTier;
1210
1139
  color: string;
1211
1140
  }
1212
- declare class ItemPrice extends Struct {
1213
- id: UInt16;
1214
- item: Item;
1215
- price: UInt32;
1216
- supply: UInt16;
1217
- }
1218
1141
 
1219
1142
  interface EpochInfo {
1220
1143
  epoch: UInt64;
@@ -1302,265 +1225,88 @@ declare class GameState extends Types.state_row {
1302
1225
 
1303
1226
  interface PlayerStateInput {
1304
1227
  owner: NameType;
1305
- balance: UInt64Type;
1306
- debt: UInt32Type;
1307
- networth: Int64Type;
1308
1228
  }
1309
- /**
1310
- * Player helper class extending player_row with computed financial properties.
1311
- * Provides easy access to balance, debt, networth, and loan calculations.
1312
- */
1313
1229
  declare class Player extends Types.player_row {
1314
- /**
1315
- * Construct a Player instance from individual state pieces.
1316
- * Used by UI's ReactivePlayer to reconstruct Player from reactive state.
1317
- */
1318
1230
  static fromState(state: PlayerStateInput): Player;
1319
- private static readonly MAX_LOAN;
1320
- private static readonly BASE_SHIP_COST;
1321
- private static readonly SHIP_COST_MULTIPLIER;
1322
- private _shipCount?;
1323
- /**
1324
- * Set the current ship count (needed for nextShipCost calculation)
1325
- */
1326
- setShipCount(count: number): void;
1327
- /**
1328
- * Get the current ship count (if set)
1329
- */
1330
- get shipCount(): number | undefined;
1331
- /**
1332
- * Calculate the cost of the next ship based on current ship count
1333
- * Matches contract: pow(5, sequence) * 100
1334
- * @param shipCount - Optional ship count (uses cached value if not provided)
1335
- */
1336
- getNextShipCost(shipCount?: number): UInt64;
1337
- /**
1338
- * Get the cost of the next ship based on cached ship count
1339
- */
1340
- get nextShipCost(): UInt64;
1341
- /**
1342
- * Check if player can afford to buy a ship
1343
- * @param shipCount - Optional ship count (uses cached value if not provided)
1344
- */
1345
- canBuyShip(shipCount?: number): boolean;
1346
- /**
1347
- * Calculate available loan amount (max loan - current debt)
1348
- */
1349
- get availableLoan(): UInt64;
1350
- /**
1351
- * Check if player can take out a loan
1352
- */
1353
- get canTakeLoan(): boolean;
1354
- /**
1355
- * Check if player can pay back loan
1356
- */
1357
- get canPayLoan(): boolean;
1358
- /**
1359
- * Calculate maximum payback amount (min of debt and balance)
1360
- */
1361
- get maxPayback(): UInt64;
1362
- /**
1363
- * Get the maximum loan amount (constant)
1364
- */
1365
- static get MAX_LOAN_LIMIT(): number;
1366
- /**
1367
- * Check if player is in debt
1368
- */
1369
- get hasDebt(): boolean;
1370
- /**
1371
- * Check if player is solvent (positive networth)
1372
- */
1373
- get isSolvent(): boolean;
1374
- /**
1375
- * Create an optimistic update for balance changes
1376
- * Uses integer math to match contract
1377
- * @param delta - Amount to change (can be negative)
1378
- */
1379
- withBalanceChange(delta: UInt64 | number): Player;
1380
- /**
1381
- * Create an optimistic update for debt changes
1382
- * Uses integer math to match contract
1383
- * @param delta - Amount to change (can be negative)
1384
- */
1385
- withDebtChange(delta: UInt64 | number): Player;
1386
- /**
1387
- * Create an optimistic update for taking a loan
1388
- */
1389
- withLoan(amount: UInt64): Player;
1390
- /**
1391
- * Create an optimistic update for paying back a loan
1392
- */
1393
- withLoanPayment(amount: UInt64): Player;
1394
- /**
1395
- * Simulate networth update from selling goods.
1396
- * Matches contract: networth += (sellPrice - paid * quantity)
1397
- * Contract reference: market.cpp:75
1398
- *
1399
- * @param sellPrice - Total revenue from sale (price * quantity)
1400
- * @param paidPerUnit - Average cost per unit paid (from cargo.paid)
1401
- * @param quantity - Quantity being sold
1402
- * @returns New player with updated networth
1403
- *
1404
- * @example
1405
- * // Sold 10 units at 150 each (revenue=1500), paid 100 per unit
1406
- * const newPlayer = player.withSaleNetworth(
1407
- * UInt64.from(1500),
1408
- * UInt64.from(100),
1409
- * UInt32.from(10)
1410
- * )
1411
- * // Networth increases by: 1500 - (100*10) = 500
1412
- */
1413
- withSaleNetworth(sellPrice: UInt64, paidPerUnit: UInt64, quantity: UInt64): Player;
1414
- /**
1415
- * Simulate complete sell goods transaction.
1416
- * Updates both balance (adds revenue) and networth (adds profit).
1417
- * Matches contract actions: update_balance + update_networth
1418
- *
1419
- * @param sellPrice - Total revenue from sale (price * quantity)
1420
- * @param paidPerUnit - Average cost per unit paid (from cargo.paid)
1421
- * @param quantity - Quantity being sold
1422
- * @returns New player with updated balance and networth
1423
- */
1424
- withSellGoods(sellPrice: UInt64, paidPerUnit: UInt64, quantity: UInt64): Player;
1425
- /**
1426
- * Simulate complete buy goods transaction.
1427
- * Updates balance (subtracts cost).
1428
- *
1429
- * @param purchaseCost - Total cost of purchase (price * quantity)
1430
- * @returns New player with updated balance
1431
- */
1432
- withBuyGoods(purchaseCost: UInt64): Player;
1433
1231
  }
1434
1232
 
1435
1233
  declare class PlayersManager extends BaseManager {
1436
1234
  getPlayer(account: NameType): Promise<Player | undefined>;
1437
1235
  }
1438
1236
 
1439
- /**
1440
- * Location helper class for working with game coordinates.
1441
- * Provides system detection, market price caching, nearby planet finding, and supply tracking.
1442
- */
1443
- declare class Location {
1444
- readonly coordinates: Coordinates;
1445
- private _marketPrices?;
1446
- private _gameSeed?;
1447
- private _hasSystem?;
1448
- private _locationRows?;
1449
- private _epoch?;
1450
- constructor(coordinates: CoordinatesType);
1451
- /**
1452
- * Create a Location from coordinates
1453
- */
1454
- static from(coordinates: CoordinatesType): Location;
1455
- /**
1456
- * Check if this location has a system (planet, asteroid, or nebula)
1457
- */
1458
- hasSystemAt(gameSeed: Checksum256Type): boolean;
1459
- /**
1460
- * Get the location type (EMPTY, PLANET, ASTEROID, or NEBULA)
1461
- */
1462
- getLocationTypeAt(gameSeed: Checksum256Type): LocationType;
1463
- /**
1464
- * Check if this location is extractable (asteroid or nebula)
1465
- */
1466
- isExtractableAt(gameSeed: Checksum256Type): boolean;
1467
- /**
1468
- * Set cached market prices for this location
1469
- */
1470
- setMarketPrices(prices: ItemPrice[]): void;
1471
- /**
1472
- * Get cached market prices (returns undefined if not cached)
1473
- */
1474
- get marketPrices(): ItemPrice[] | undefined;
1475
- /**
1476
- * Get price for a specific good (from cache)
1477
- */
1478
- getPrice(goodId: UInt16Type): ItemPrice | undefined;
1479
- /**
1480
- * Find nearby planets from this location
1481
- */
1482
- findNearby(gameSeed: Checksum256Type, maxDistance?: UInt16Type): Distance[];
1483
- /**
1484
- * Check if this location equals another location
1485
- */
1486
- equals(other: CoordinatesType | Location): boolean;
1487
- /**
1488
- * Set location rows (supply data) for this location
1489
- */
1490
- setLocationRows(rows: Types.supply_row[], epoch: UInt64): void;
1491
- /**
1492
- * Get cached location rows (supply data)
1493
- */
1494
- get locationRows(): Types.supply_row[] | undefined;
1495
- /**
1496
- * Get supply for a specific good at this location
1497
- * Returns undefined if location rows not cached or good not found
1498
- */
1499
- getSupply(goodId: UInt16Type): UInt16 | undefined;
1500
- /**
1501
- * Get all available goods at this location (goods with supply > 0)
1502
- * Returns undefined if location rows not cached
1503
- */
1504
- get availableGoods(): Types.supply_row[] | undefined;
1505
- /**
1506
- * Check if a specific good is available (has supply)
1507
- * Returns false if location rows not cached
1508
- */
1509
- hasGood(goodId: UInt16Type): boolean;
1510
- /**
1511
- * Get the epoch for cached location data
1512
- */
1513
- get epoch(): UInt64 | undefined;
1514
- /**
1515
- * Check if cached data exists
1516
- */
1517
- get hasCachedData(): boolean;
1518
- /**
1519
- * Check if supply data is cached
1520
- */
1521
- get hasSupplyData(): boolean;
1522
- /**
1523
- * Clear all cached data
1524
- */
1525
- clearCache(): void;
1526
- /**
1527
- * Create optimistic Location with updated supply after purchase/sale.
1528
- * Matches contract: update_location_supply (delta can be positive or negative)
1529
- * Contract reference: market.cpp:53, 123-151
1530
- *
1531
- * @param goodId - Good ID to update supply for
1532
- * @param quantityDelta - Change in supply (negative for purchase, positive for sale)
1533
- * @returns New Location with updated supply in cached data
1534
- *
1535
- * @example
1536
- * // After buying 10 units (supply decreases)
1537
- * const newLocation = location.withUpdatedSupply(1, -10)
1538
- *
1539
- * // After selling 5 units (supply increases)
1540
- * const newLocation = location.withUpdatedSupply(1, 5)
1541
- */
1542
- withUpdatedSupply(goodId: UInt16Type, quantityDelta: number): Location;
1543
- }
1544
- /**
1545
- * Helper function to convert various coordinate types to Location
1546
- */
1547
- declare function toLocation(coords: CoordinatesType | Location): Location;
1548
-
1549
1237
  declare class LocationsManager extends BaseManager {
1550
- getMarketPrice(location: CoordinatesType, goodId: number): Promise<ItemPrice>;
1551
- getMarketPrices(location: CoordinatesType): Promise<ItemPrice[]>;
1552
- getMarketPricesWithSupply(location: CoordinatesType): Promise<ItemPrice[]>;
1553
1238
  hasSystem(location: CoordinatesType): Promise<boolean>;
1554
1239
  findNearbyPlanets(origin: CoordinatesType, maxDistance?: UInt16Type): Promise<Distance[]>;
1555
- getSupplyRows(location: CoordinatesType): Promise<any[]>;
1556
- getLocationWithPrices(coords: CoordinatesType): Promise<Location>;
1557
- getLocationWithSupply(coords: CoordinatesType): Promise<Location>;
1558
- getLocationComplete(coords: CoordinatesType): Promise<Location>;
1559
1240
  getLocationEntity(id: UInt64Type): Promise<Types.location_row | undefined>;
1560
1241
  getLocationEntityAt(coords: CoordinatesType): Promise<Types.location_row | undefined>;
1561
1242
  getAllLocationEntities(): Promise<Types.location_row[]>;
1562
1243
  }
1563
1244
 
1245
+ declare class EpochsManager extends BaseManager {
1246
+ getCurrentHeight(): Promise<UInt64>;
1247
+ getCurrent(): Promise<EpochInfo>;
1248
+ getByHeight(height: UInt64Type): Promise<EpochInfo>;
1249
+ getTimeRemaining(): Promise<number>;
1250
+ getProgress(): Promise<number>;
1251
+ fitsInCurrentEpoch(durationMs: number): Promise<boolean>;
1252
+ }
1253
+
1254
+ type EntityRefInput = {
1255
+ entityType: EntityTypeName;
1256
+ entityId: UInt64Type;
1257
+ };
1258
+ declare class ActionsManager extends BaseManager {
1259
+ travel(shipId: UInt64Type, destination: CoordinatesType, recharge?: boolean): Action;
1260
+ grouptravel(entities: EntityRefInput[], destination: CoordinatesType, recharge?: boolean): Action;
1261
+ resolve(entityId: UInt64Type, entityType?: EntityTypeName): Action;
1262
+ cancel(entityId: UInt64Type, count: UInt64Type, entityType?: EntityTypeName): Action;
1263
+ recharge(shipId: UInt64Type): Action;
1264
+ transfer(sourceType: EntityTypeName, sourceId: UInt64Type, destType: EntityTypeName, destId: UInt64Type, goodId: UInt64Type, quantity: UInt64Type): Action;
1265
+ foundCompany(account: NameType, name: string): Action;
1266
+ join(account: NameType): Action;
1267
+ extract(shipId: UInt64Type): Action;
1268
+ warp(shipId: UInt64Type, destination: CoordinatesType): Action;
1269
+ craft(entityType: EntityTypeName, entityId: UInt64Type, recipeId: number, quantity: number, inputs: ActionParams.Type.cargo_item[]): Action;
1270
+ blend(entityType: EntityTypeName, entityId: UInt64Type, inputs: ActionParams.Type.cargo_item[]): Action;
1271
+ deploy(entityType: EntityTypeName, entityId: UInt64Type, packedItemId: number, seed: bigint, entityName: string): Action;
1272
+ addmodule(entityType: EntityTypeName, entityId: UInt64Type, moduleIndex: number, moduleCargoId: UInt64Type, targetCargoId?: UInt64Type): Action;
1273
+ rmmodule(entityType: EntityTypeName, entityId: UInt64Type, moduleIndex: number, targetCargoId?: UInt64Type): Action;
1274
+ joinGame(account: NameType, companyName: string): Action[];
1275
+ }
1276
+
1277
+ declare class GameContext {
1278
+ readonly client: APIClient;
1279
+ readonly server: Contract$2;
1280
+ readonly platform: Contract$2;
1281
+ private _entities?;
1282
+ private _players?;
1283
+ private _locations?;
1284
+ private _epochs?;
1285
+ private _actions?;
1286
+ private _gameCache?;
1287
+ private _stateCache?;
1288
+ constructor(client: APIClient, server: Contract$2, platform: Contract$2);
1289
+ get entities(): EntitiesManager;
1290
+ get players(): PlayersManager;
1291
+ get locations(): LocationsManager;
1292
+ get epochs(): EpochsManager;
1293
+ get actions(): ActionsManager;
1294
+ getGame(reload?: boolean): Promise<Types$1.game_row>;
1295
+ getState(reload?: boolean): Promise<GameState>;
1296
+ get cachedGame(): Types$1.game_row | undefined;
1297
+ get cachedState(): GameState | undefined;
1298
+ }
1299
+
1300
+ declare abstract class BaseManager {
1301
+ protected readonly context: GameContext;
1302
+ constructor(context: GameContext);
1303
+ protected get client(): _wharfkit_antelope.APIClient;
1304
+ protected get server(): _wharfkit_contract.Contract;
1305
+ protected get platform(): _wharfkit_contract.Contract;
1306
+ protected getGame(): Promise<Types$1.game_row>;
1307
+ protected getState(): Promise<GameState>;
1308
+ }
1309
+
1564
1310
  interface MovementCapability {
1565
1311
  engines: Types.movement_stats;
1566
1312
  generator: Types.energy_stats;
@@ -1576,9 +1322,6 @@ interface StorageCapability {
1576
1322
  interface LoaderCapability {
1577
1323
  loaders: Types.loader_stats;
1578
1324
  }
1579
- interface TradeCapability {
1580
- trade: Types.trade_stats;
1581
- }
1582
1325
  interface ExtractorCapability {
1583
1326
  extractor: Types.extractor_stats;
1584
1327
  }
@@ -1594,8 +1337,8 @@ interface EntityCapabilities {
1594
1337
  engines?: Types.movement_stats;
1595
1338
  generator?: Types.energy_stats;
1596
1339
  loaders?: Types.loader_stats;
1597
- trade?: Types.trade_stats;
1598
1340
  extractor?: Types.extractor_stats;
1341
+ crafter?: Types.crafter_stats;
1599
1342
  }
1600
1343
  interface EntityState {
1601
1344
  owner: Name;
@@ -1607,7 +1350,6 @@ interface EntityState {
1607
1350
  declare function capsHasMovement(caps: EntityCapabilities): boolean;
1608
1351
  declare function capsHasStorage(caps: EntityCapabilities): boolean;
1609
1352
  declare function capsHasLoaders(caps: EntityCapabilities): boolean;
1610
- declare function capsHasTrade(caps: EntityCapabilities): boolean;
1611
1353
  declare function capsHasExtractor(caps: EntityCapabilities): boolean;
1612
1354
  declare function capsHasMass(caps: EntityCapabilities): boolean;
1613
1355
 
@@ -1722,12 +1464,10 @@ interface ProjectedEntity {
1722
1464
  engines?: Types.movement_stats;
1723
1465
  loaders?: Types.loader_stats;
1724
1466
  generator?: Types.energy_stats;
1725
- trade?: Types.trade_stats;
1726
1467
  readonly totalMass: UInt64;
1727
1468
  hasMovement(): boolean;
1728
1469
  hasStorage(): boolean;
1729
1470
  hasLoaders(): boolean;
1730
- hasTrade(): boolean;
1731
1471
  capabilities(): EntityCapabilities;
1732
1472
  state(): EntityState;
1733
1473
  }
@@ -1738,7 +1478,6 @@ interface Projectable extends ScheduleData {
1738
1478
  generator?: Types.energy_stats;
1739
1479
  engines?: Types.movement_stats;
1740
1480
  loaders?: Types.loader_stats;
1741
- trade?: Types.trade_stats;
1742
1481
  capacity?: UInt32;
1743
1482
  cargo: Types.cargo_item[];
1744
1483
  cargomass: UInt32;
@@ -1748,6 +1487,23 @@ declare function createProjectedEntity(entity: Projectable): ProjectedEntity;
1748
1487
  declare function projectEntity(entity: Projectable): ProjectedEntity;
1749
1488
  declare function projectEntityAt(entity: Projectable, now: Date): ProjectedEntity;
1750
1489
 
1490
+ declare class Location {
1491
+ readonly coordinates: Coordinates;
1492
+ private _gameSeed?;
1493
+ private _hasSystem?;
1494
+ private _epoch?;
1495
+ constructor(coordinates: CoordinatesType);
1496
+ static from(coordinates: CoordinatesType): Location;
1497
+ hasSystemAt(gameSeed: Checksum256Type): boolean;
1498
+ getLocationTypeAt(gameSeed: Checksum256Type): LocationType;
1499
+ isExtractableAt(gameSeed: Checksum256Type): boolean;
1500
+ findNearby(gameSeed: Checksum256Type, maxDistance?: UInt16Type): Distance[];
1501
+ equals(other: CoordinatesType | Location): boolean;
1502
+ get epoch(): UInt64 | undefined;
1503
+ clearCache(): void;
1504
+ }
1505
+ declare function toLocation(coords: CoordinatesType | Location): Location;
1506
+
1751
1507
  type Task = Types.task;
1752
1508
  declare class ScheduleAccessor {
1753
1509
  private entity;
@@ -1779,7 +1535,6 @@ declare class EntityInventory extends Types.cargo_item {
1779
1535
  get name(): string;
1780
1536
  get unitMass(): UInt32;
1781
1537
  get totalMass(): UInt64;
1782
- get totalCost(): UInt64;
1783
1538
  get hasCargo(): boolean;
1784
1539
  get isEmpty(): boolean;
1785
1540
  }
@@ -1794,7 +1549,6 @@ interface HasCargomass {
1794
1549
  cargomass: UInt32;
1795
1550
  }
1796
1551
  declare function calcCargoMass(entity: HasCargo): UInt64;
1797
- declare function calcCargoValue(entity: HasCargo): UInt64;
1798
1552
  declare function availableCapacity$1(entity: StorageCapability): UInt64;
1799
1553
  declare function availableCapacityFromMass(capacity: UInt64Type, cargoMass: UInt64Type): UInt64;
1800
1554
  declare function hasSpace$1(entity: StorageCapability, goodMass: UInt64, quantity: number): boolean;
@@ -1808,7 +1562,6 @@ declare class InventoryAccessor {
1808
1562
  constructor(entity: HasCargo);
1809
1563
  get items(): EntityInventory[];
1810
1564
  get totalMass(): UInt64;
1811
- get totalValue(): UInt64;
1812
1565
  forItem(goodId: UInt64Type): EntityInventory | undefined;
1813
1566
  get sellable(): EntityInventory[];
1814
1567
  get hasSellable(): boolean;
@@ -1816,57 +1569,6 @@ declare class InventoryAccessor {
1816
1569
  }
1817
1570
  declare function createInventoryAccessor(entity: HasCargo): InventoryAccessor;
1818
1571
 
1819
- interface CargoData {
1820
- cargo: EntityInventory[];
1821
- }
1822
- declare function totalCargoMass(cargo: EntityInventory[]): UInt64;
1823
- declare function cargoValue(cargo: EntityInventory[]): UInt64;
1824
- declare function getCargoForItem(cargo: EntityInventory[], goodId: UInt64Type): EntityInventory | undefined;
1825
- declare function hasSpace(currentMass: UInt64, maxCapacity: UInt64, goodMass: UInt64, quantity: number): boolean;
1826
- declare function availableCapacity(currentMass: UInt64, maxCapacity: UInt64): UInt64;
1827
- declare function isFull(currentMass: UInt64, maxCapacity: UInt64): boolean;
1828
- interface SaleValue {
1829
- revenue: UInt64;
1830
- profit: UInt64;
1831
- cost: UInt64;
1832
- }
1833
- declare function calculateSaleValue(cargo: Types.cargo_item[], prices: Map<number, UInt64>): SaleValue;
1834
- declare function calculateSaleValueFromArray(cargo: Types.cargo_item[], prices: UInt64[]): SaleValue;
1835
- declare function afterSellItems(cargo: Types.cargo_item[], goodsToSell: Array<{
1836
- goodId: number;
1837
- quantity: number;
1838
- }>): EntityInventory[];
1839
- declare function afterSellAllItems(cargo: Types.cargo_item[]): EntityInventory[];
1840
-
1841
- type cargoUtils_CargoData = CargoData;
1842
- declare const cargoUtils_totalCargoMass: typeof totalCargoMass;
1843
- declare const cargoUtils_cargoValue: typeof cargoValue;
1844
- declare const cargoUtils_getCargoForItem: typeof getCargoForItem;
1845
- declare const cargoUtils_hasSpace: typeof hasSpace;
1846
- declare const cargoUtils_availableCapacity: typeof availableCapacity;
1847
- declare const cargoUtils_isFull: typeof isFull;
1848
- type cargoUtils_SaleValue = SaleValue;
1849
- declare const cargoUtils_calculateSaleValue: typeof calculateSaleValue;
1850
- declare const cargoUtils_calculateSaleValueFromArray: typeof calculateSaleValueFromArray;
1851
- declare const cargoUtils_afterSellItems: typeof afterSellItems;
1852
- declare const cargoUtils_afterSellAllItems: typeof afterSellAllItems;
1853
- declare namespace cargoUtils {
1854
- export {
1855
- cargoUtils_CargoData as CargoData,
1856
- cargoUtils_totalCargoMass as totalCargoMass,
1857
- cargoUtils_cargoValue as cargoValue,
1858
- cargoUtils_getCargoForItem as getCargoForItem,
1859
- cargoUtils_hasSpace as hasSpace,
1860
- cargoUtils_availableCapacity as availableCapacity,
1861
- cargoUtils_isFull as isFull,
1862
- cargoUtils_SaleValue as SaleValue,
1863
- cargoUtils_calculateSaleValue as calculateSaleValue,
1864
- cargoUtils_calculateSaleValueFromArray as calculateSaleValueFromArray,
1865
- cargoUtils_afterSellItems as afterSellItems,
1866
- cargoUtils_afterSellAllItems as afterSellAllItems,
1867
- };
1868
- }
1869
-
1870
1572
  interface ShipStateInput {
1871
1573
  id: UInt64Type;
1872
1574
  owner: string;
@@ -1876,12 +1578,12 @@ interface ShipStateInput {
1876
1578
  y: number;
1877
1579
  z?: number;
1878
1580
  };
1879
- hullmass: number;
1880
- capacity: number;
1881
- energy: number;
1882
- engines: Types.movement_stats;
1883
- generator: Types.energy_stats;
1884
- loaders: Types.loader_stats;
1581
+ hullmass?: number;
1582
+ capacity?: number;
1583
+ energy?: number;
1584
+ engines?: Types.movement_stats;
1585
+ generator?: Types.energy_stats;
1586
+ loaders?: Types.loader_stats;
1885
1587
  schedule?: Types.schedule;
1886
1588
  cargo?: Types.cargo_item[];
1887
1589
  }
@@ -1902,13 +1604,14 @@ declare class Ship extends Types.entity_info {
1902
1604
  isLoading(now: Date): boolean;
1903
1605
  isUnloading(now: Date): boolean;
1904
1606
  isExtracting(now: Date): boolean;
1607
+ get hasEngines(): boolean;
1608
+ get hasGenerator(): boolean;
1905
1609
  get hasExtractor(): boolean;
1906
1610
  get hasWarp(): boolean;
1907
1611
  project(): ProjectedEntity;
1908
1612
  projectAt(now: Date): ProjectedEntity;
1909
1613
  get location(): Location;
1910
1614
  get totalCargoMass(): UInt64;
1911
- get cargoValue(): UInt64;
1912
1615
  get totalMass(): UInt64;
1913
1616
  get maxCapacity(): UInt64;
1914
1617
  hasSpace(goodMass: UInt64, quantity: number): boolean;
@@ -1921,476 +1624,41 @@ declare class Ship extends Types.entity_info {
1921
1624
  get energyPercent(): number;
1922
1625
  get needsRecharge(): boolean;
1923
1626
  hasEnergyFor(distance: UInt64): boolean;
1924
- calculateSaleValue(prices: Map<number, UInt64>): SaleValue;
1925
- calculateSaleValueFromArray(prices: UInt64[]): SaleValue;
1926
- afterSellItems(goodsToSell: Array<{
1927
- goodId: number;
1928
- quantity: number;
1929
- }>): EntityInventory[];
1930
- afterSellAllItems(): EntityInventory[];
1931
1627
  }
1932
1628
 
1933
- /**
1934
- * Travel calculations for ship movement, energy usage, and flight times.
1935
- *
1936
- * Functions prefixed with `calc_` are contract-parity functions that mirror
1937
- * the C++ implementation in the server contract (schedule.cpp, ship.cpp).
1938
- * These use snake_case intentionally to match the contract naming convention
1939
- * and signal that they must produce identical results to the on-chain code.
1940
- *
1941
- * Functions prefixed with `calculate` are higher-level SDK helpers that may
1942
- * combine multiple contract calculations for convenience.
1943
- */
1944
-
1945
- declare function calc_orbital_altitude(mass: number): number;
1946
- declare function distanceBetweenCoordinates(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): UInt64;
1947
- declare function distanceBetweenPoints(x1: Int64Type, y1: Int64Type, x2: Int64Type, y2: Int64Type): UInt64;
1948
- declare function lerp(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates, time: number): ActionParams.Type.coordinates;
1949
- declare function rotation(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): number;
1950
- declare function findNearbyPlanets(seed: Checksum256, origin: ActionParams.Type.coordinates, maxDistance?: UInt64Type): Distance[];
1951
- declare function calc_rechargetime(capacity: UInt32Type, energy: UInt32Type, recharge: UInt32Type): UInt32;
1952
- declare function calc_ship_rechargetime(ship: ShipLike): UInt32;
1953
- declare function calc_flighttime(distance: UInt64Type, acceleration: number): UInt32;
1954
- declare function calc_loader_flighttime(ship: ShipLike, mass: UInt64, altitude?: number): UInt32;
1955
- declare function calc_loader_acceleration(ship: ShipLike, mass: UInt64): number;
1956
- declare function calc_ship_flighttime(ship: ShipLike, mass: UInt64, distance: UInt64): UInt32;
1957
- declare function calc_ship_acceleration(ship: ShipLike, mass: UInt64): number;
1958
- declare function calc_acceleration(thrust: number, mass: number): number;
1959
- declare function calc_ship_mass(ship: ShipLike, cargos: CargoMassInfo[]): UInt64;
1960
- declare function calc_energyusage(distance: UInt64Type, drain: UInt32Type): UInt32;
1961
- declare function calculateTransferTime(ship: ShipLike, cargos: CargoMassInfo[], quantities?: Map<number, number>): UInt32;
1962
- declare function calculateRefuelingTime(ship: ShipLike): UInt32;
1963
- declare function calculateFlightTime(ship: ShipLike, cargos: CargoMassInfo[], distance: UInt64Type): UInt32;
1964
- interface LoadTimeBreakdown {
1965
- unloadTime: number;
1966
- loadTime: number;
1967
- totalTime: number;
1968
- unloadMass: number;
1969
- loadMass: number;
1970
- }
1971
- declare function calculateLoadTimeBreakdown(ship: ShipLike, cargos: CargoMassInfo[], loadQuantities?: Map<number, number>, unloadQuantities?: Map<number, number>): LoadTimeBreakdown;
1972
- interface EstimatedTravelTime {
1973
- flightTime: UInt32;
1974
- rechargeTime: UInt32;
1975
- loadTime: UInt32;
1976
- unloadTime: UInt32;
1977
- total: UInt32;
1978
- }
1979
- interface EstimateTravelTimeOptions {
1980
- needsRecharge?: boolean;
1981
- loadMass?: UInt32Type;
1982
- unloadMass?: UInt32Type;
1983
- }
1984
- declare function estimateTravelTime(ship: ShipLike, travelMass: UInt64Type, distance: UInt64Type, options?: EstimateTravelTimeOptions): EstimatedTravelTime;
1985
- declare function estimateDealTravelTime(ship: ShipLike, shipMass: UInt64Type, distance: UInt64Type, loadMass: UInt32Type): UInt32;
1986
- declare function hasEnergyForDistance(ship: ShipLike, distance: UInt64Type): boolean;
1987
- interface TransferEntity {
1988
- location: {
1989
- z?: {
1990
- toNumber(): number;
1991
- } | number;
1992
- };
1993
- loaders?: {
1994
- thrust: {
1995
- toNumber(): number;
1996
- } | number;
1997
- mass: {
1998
- toNumber(): number;
1999
- } | number;
2000
- quantity: {
2001
- toNumber(): number;
2002
- } | number;
1629
+ interface WarehouseStateInput {
1630
+ id: UInt64Type;
1631
+ owner: string;
1632
+ name: string;
1633
+ coordinates: CoordinatesType | {
1634
+ x: number;
1635
+ y: number;
1636
+ z?: number;
2003
1637
  };
2004
- }
2005
- interface HasScheduleAndLocation {
2006
- coordinates: ActionParams.Type.coordinates;
1638
+ capacity: number;
1639
+ loaders: Types.loader_stats;
2007
1640
  schedule?: Types.schedule;
1641
+ cargo?: Types.cargo_item[];
1642
+ }
1643
+ declare class Warehouse extends Types.entity_info {
1644
+ private _sched?;
1645
+ private _inv?;
1646
+ get name(): string;
1647
+ get inv(): InventoryAccessor;
1648
+ get inventory(): EntityInventory[];
1649
+ get sched(): ScheduleAccessor;
1650
+ get isIdle(): boolean;
1651
+ isLoading(now: Date): boolean;
1652
+ isUnloading(now: Date): boolean;
1653
+ get location(): Location;
1654
+ get totalCargoMass(): UInt64;
1655
+ get maxCapacity(): UInt64;
1656
+ get availableCapacity(): UInt64;
1657
+ hasSpace(goodMass: UInt64, quantity: number): boolean;
1658
+ get isFull(): boolean;
1659
+ getCargoForItem(goodId: UInt64Type): EntityInventory | undefined;
1660
+ get orbitalAltitude(): number;
2008
1661
  }
2009
- declare function getFlightOrigin(entity: HasScheduleAndLocation, flightTaskIndex: number): ActionParams.Type.coordinates;
2010
- declare function getDestinationLocation(entity: HasScheduleAndLocation): ActionParams.Type.coordinates | undefined;
2011
- declare function getPositionAt(entity: HasScheduleAndLocation, taskIndex: number, taskProgress: number): ActionParams.Type.coordinates;
2012
- declare function calc_transfer_duration(source: TransferEntity, dest: TransferEntity, cargoMass: number): number;
2013
-
2014
- /**
2015
- * Trading deal interface representing a profitable trade opportunity
2016
- */
2017
- interface Deal {
2018
- /** Origin location */
2019
- origin: Location;
2020
- /** Destination location */
2021
- destination: Location;
2022
- /** Item to trade */
2023
- item: ItemPrice;
2024
- /** Distance between origin and destination */
2025
- distance: UInt64;
2026
- /** Available supply at origin */
2027
- supply: UInt16;
2028
- /** Buy price at origin */
2029
- buyPrice: UInt32;
2030
- /** Sell price at destination */
2031
- sellPrice: UInt32;
2032
- /** Profit per unit */
2033
- profitPerUnit: UInt32;
2034
- /** Maximum quantity that can be traded */
2035
- maxQuantity: UInt32;
2036
- /** Total profit for max quantity */
2037
- totalProfit: Int64;
2038
- /** Estimated travel time in seconds */
2039
- travelTime: UInt32;
2040
- /** Detailed breakdown of travel time components */
2041
- travelTimeBreakdown: EstimatedTravelTime;
2042
- /** Profit per second (floating point for UI display) */
2043
- profitPerSecond: number;
2044
- /** Profit margin percentage (floating point for UI display) */
2045
- marginPercent: number;
2046
- }
2047
- /**
2048
- * Options for finding deals
2049
- */
2050
- interface FindDealsOptions {
2051
- /** Maximum number of deals to return */
2052
- maxDeals?: number;
2053
- /** Maximum search distance */
2054
- maxDistance?: number;
2055
- /** Player's current balance (for affordability filtering) */
2056
- playerBalance?: UInt64Type;
2057
- /** Minimum profit per second threshold */
2058
- minProfitPerSecond?: number;
2059
- /** Minimum profit margin percentage */
2060
- minMarginPercent?: number;
2061
- /** Override available cargo space (in mass units). If provided, uses this instead of calculating from ship's current cargo. */
2062
- availableSpace?: number;
2063
- }
2064
- /**
2065
- * Calculate deals for a ship from a specific origin location
2066
- */
2067
- declare function findDealsForShip(ship: Ship, originLocation: Coordinates, getNearbyLocations: (origin: Coordinates, maxDistance: number) => Promise<Location[]>, getMarketPrices: (location: Coordinates) => Promise<ItemPrice[]>, options?: FindDealsOptions): Promise<Deal[]>;
2068
- /**
2069
- * Find the single best deal for a ship from a specific origin location
2070
- */
2071
- declare function findBestDeal(ship: Ship, originLocation: Coordinates, getNearbyLocations: (origin: Coordinates, maxDistance: number) => Promise<Location[]>, getMarketPrices: (location: Coordinates) => Promise<ItemPrice[]>, options?: FindDealsOptions): Promise<Deal | undefined>;
2072
-
2073
- /**
2074
- * Types of collect actions available to the player
2075
- */
2076
- type CollectActionType = 'sell-and-trade' | 'sell-and-reposition' | 'travel-to-sell' | 'sell-and-stay' | 'explore' | 'orbit';
2077
- /**
2078
- * Represents a single collect option presented to the player
2079
- */
2080
- interface CollectOption {
2081
- /** Unique identifier for this option */
2082
- id: string;
2083
- /** Type of action sequence */
2084
- type: CollectActionType;
2085
- /** Human-readable title */
2086
- title: string;
2087
- /** Detailed description of what will happen */
2088
- description: string;
2089
- /** Brief explanation of why this option is worth considering */
2090
- reason: string;
2091
- /** Whether this is the recommended option (best profitPerSecond with quality threshold) */
2092
- recommended: boolean;
2093
- /** Whether this option has the highest absolute profit (may differ from recommended) */
2094
- highestProfit: boolean;
2095
- /** Estimated profit/loss from this action */
2096
- estimatedProfit: UInt64;
2097
- /** Revenue from selling cargo (if applicable) */
2098
- saleRevenue?: UInt64;
2099
- /** Cost of purchasing new cargo (if applicable) */
2100
- purchaseCost?: UInt64;
2101
- /** Expected profit from the next trade (if applicable) */
2102
- nextTradeProfit?: UInt64;
2103
- /** Profit per second for this option (floating point for display) */
2104
- profitPerSecond?: number;
2105
- /** Margin percentage for the deal (floating point for display) */
2106
- marginPercent?: number;
2107
- /** Destination location (if traveling) */
2108
- destination?: Location;
2109
- /** Deal to execute (if buying goods) */
2110
- deal?: Deal;
2111
- /** Sale location if different from current */
2112
- saleLocation?: Location;
2113
- /** Price per unit at sale location */
2114
- salePrice?: UInt32;
2115
- /** Price per unit at current location (for comparison) */
2116
- currentPrice?: UInt32;
2117
- /** Estimated travel time in seconds (undefined = instant/no travel) */
2118
- travelTime?: UInt32;
2119
- /** Detailed breakdown of travel time components */
2120
- travelTimeBreakdown?: EstimatedTravelTime;
2121
- /** Info about a discounted good at the destination (for explore options) */
2122
- discountedGood?: DiscountedItemInfo;
2123
- /** Top potential deals available at destination (for explore options) */
2124
- potentialDeals?: PotentialDeal[];
2125
- /** Details of cargo being sold (if selling cargo) */
2126
- cargoSale?: CargoSaleItem[];
2127
- /** Total profit/loss from selling cargo */
2128
- cargoProfitLoss?: Int64;
2129
- }
2130
- /**
2131
- * Analysis result for collect options
2132
- */
2133
- interface CollectAnalysis {
2134
- /** Current location where ship arrived */
2135
- arrivedAt: Coordinates;
2136
- /** Ship being analyzed */
2137
- ship: Ship;
2138
- /** Current cargo on ship */
2139
- cargo: EntityInventory[];
2140
- /** Value of cargo if sold at current location */
2141
- cargoValueHere: UInt64;
2142
- /** All available options, sorted by estimated profit */
2143
- options: CollectOption[];
2144
- /** Whether any profitable options exist */
2145
- hasProfitableOptions: boolean;
2146
- }
2147
- /**
2148
- * Options for analyzing collect choices
2149
- */
2150
- interface CollectAnalysisOptions {
2151
- /** Player's current balance (defaults to Infinity) */
2152
- playerBalance?: number;
2153
- /** Maximum distance to search (defaults to ship's max range) */
2154
- maxDistance?: number;
2155
- /** Minimum profit improvement to suggest traveling elsewhere to sell */
2156
- minSaleImprovement?: number;
2157
- }
2158
- /**
2159
- * Find locations where current cargo could be sold for more
2160
- */
2161
- interface BetterSaleLocation {
2162
- location: Location;
2163
- /** Price per unit at this location */
2164
- price: UInt32;
2165
- /** Total revenue if sold here */
2166
- revenue: UInt64;
2167
- /** Difference vs selling at current location */
2168
- improvement: Int64;
2169
- /** Best deal available at this location after selling */
2170
- bestDealAfterSale?: Deal;
2171
- /** Distance to this location */
2172
- distance: UInt64;
2173
- /** Estimated travel time */
2174
- travelTime: UInt32;
2175
- /** Detailed breakdown of travel time components */
2176
- travelTimeBreakdown?: EstimatedTravelTime;
2177
- }
2178
- /**
2179
- * Find locations with good deals when current location has none
2180
- */
2181
- interface RepositionLocation {
2182
- location: Location;
2183
- /** Best deal available at this location */
2184
- bestDeal: Deal;
2185
- /** Distance to this location */
2186
- distance: UInt64;
2187
- /** Estimated travel time */
2188
- travelTime: UInt32;
2189
- /** Detailed breakdown of travel time components */
2190
- travelTimeBreakdown?: EstimatedTravelTime;
2191
- }
2192
- /**
2193
- * Analyze cargo sale value at a specific location
2194
- */
2195
- declare function analyzeCargoSale(cargo: EntityInventory[], prices: Map<number, UInt64>): {
2196
- revenue: UInt64;
2197
- cost: UInt64;
2198
- profit: Int64;
2199
- };
2200
- /**
2201
- * Create a "Sell & Trade" option (full loop)
2202
- */
2203
- declare function createSellAndTradeOption(saleRevenue: UInt64, saleCost: UInt64, deal: Deal, cargoSale?: CargoSaleItem[], unloadTime?: UInt32): CollectOption;
2204
- /**
2205
- * Create a "Travel to Sell" option (better market elsewhere)
2206
- */
2207
- declare function createTravelToSellOption(currentRevenue: UInt64, cargoCost: UInt64, betterSale: BetterSaleLocation, cargo: EntityInventory[], destPrices?: Map<number, UInt64>): CollectOption;
2208
- /**
2209
- * Create a "Sell & Reposition" option (sell here, travel empty to deals)
2210
- */
2211
- declare function createSellAndRepositionOption(saleRevenue: UInt64, saleCost: UInt64, reposition: RepositionLocation, cargoSale?: CargoSaleItem[]): CollectOption;
2212
- /**
2213
- * Create a "Sell & Stay" option (just sell, stay idle)
2214
- */
2215
- declare function createSellAndStayOption(saleRevenue: UInt64, saleCost: UInt64, cargoSale?: CargoSaleItem[], unloadTime?: UInt32): CollectOption;
2216
- /**
2217
- * Details about a cargo item being sold
2218
- */
2219
- interface CargoSaleItem {
2220
- goodId: UInt16;
2221
- goodName: string;
2222
- quantity: UInt32;
2223
- /** Price per unit at sale location */
2224
- pricePerUnit: UInt32;
2225
- /** Total revenue from this item */
2226
- revenue: UInt64;
2227
- /** Original cost (paid) per unit */
2228
- costPerUnit: UInt64;
2229
- /** Profit/loss on this item */
2230
- profit: Int64;
2231
- }
2232
- /**
2233
- * Info about a discounted good for explore options
2234
- */
2235
- interface DiscountedItemInfo {
2236
- goodId: number;
2237
- name: string;
2238
- rarity: string;
2239
- discountPercent: number;
2240
- }
2241
- /**
2242
- * A potential deal available at a destination (for explore options)
2243
- */
2244
- interface PotentialDeal {
2245
- goodId: number;
2246
- goodName: string;
2247
- destinationCoords: Coordinates;
2248
- marginPercent: number;
2249
- profitPerSecond: number;
2250
- }
2251
- /**
2252
- * Create an "Explore" option (travel to find opportunities)
2253
- */
2254
- declare function createExploreOption(destination: Location, travelTime?: UInt32, discountedGood?: DiscountedItemInfo, travelTimeBreakdown?: EstimatedTravelTime, potentialDeals?: PotentialDeal[]): CollectOption;
2255
- /**
2256
- * Callbacks for collect analysis (provided by manager)
2257
- */
2258
- interface CollectAnalysisCallbacks {
2259
- getNearbyLocations: (origin: Coordinates, maxDistance: number) => Promise<Location[]>;
2260
- getMarketPrices: (location: Coordinates) => Promise<ItemPrice[]>;
2261
- getGameSeed?: () => Checksum256Type;
2262
- getState?: () => Types.state_row;
2263
- }
2264
- /**
2265
- * Analyze all collect options for a ship that has arrived at its destination.
2266
- * Returns all available options sorted by estimated profit.
2267
- */
2268
- declare function analyzeCollectOptions(ship: Ship, arrivedAt: Coordinates, callbacks: CollectAnalysisCallbacks, options?: CollectAnalysisOptions): Promise<CollectAnalysis>;
2269
-
2270
- declare class TradesManager extends BaseManager {
2271
- private priceCache;
2272
- private priceCacheEpoch;
2273
- private makePriceCacheKey;
2274
- private createCallbacks;
2275
- clearPriceCache(): void;
2276
- findDeals(ship: Ship, originLocation?: Coordinates, options?: FindDealsOptions): Promise<Deal[]>;
2277
- findBestDeal(ship: Ship, originLocation?: Coordinates, options?: FindDealsOptions): Promise<Deal | undefined>;
2278
- getCollectOptions(ship: Ship, arrivedAt?: Coordinates, options?: CollectAnalysisOptions): Promise<CollectAnalysis>;
2279
- }
2280
-
2281
- declare class EpochsManager extends BaseManager {
2282
- getCurrentHeight(): Promise<UInt64>;
2283
- getCurrent(): Promise<EpochInfo>;
2284
- getByHeight(height: UInt64Type): Promise<EpochInfo>;
2285
- getTimeRemaining(): Promise<number>;
2286
- getProgress(): Promise<number>;
2287
- fitsInCurrentEpoch(durationMs: number): Promise<boolean>;
2288
- }
2289
-
2290
- interface SellableCargo {
2291
- item_id: {
2292
- toNumber(): number;
2293
- } | number;
2294
- quantity: {
2295
- toNumber(): number;
2296
- } | number;
2297
- hasCargo: boolean;
2298
- }
2299
- type EntityRefInput = {
2300
- entityType: EntityTypeName;
2301
- entityId: UInt64Type;
2302
- };
2303
- declare class ActionsManager extends BaseManager {
2304
- travel(shipId: UInt64Type, destination: CoordinatesType, recharge?: boolean): Action;
2305
- grouptravel(entities: EntityRefInput[], destination: CoordinatesType, recharge?: boolean): Action;
2306
- resolve(entityId: UInt64Type, entityType?: EntityTypeName): Action;
2307
- cancel(entityId: UInt64Type, count: UInt64Type, entityType?: EntityTypeName): Action;
2308
- recharge(shipId: UInt64Type): Action;
2309
- transfer(sourceType: EntityTypeName, sourceId: UInt64Type, destType: EntityTypeName, destId: UInt64Type, goodId: UInt64Type, quantity: UInt64Type): Action;
2310
- buyItems(entityId: UInt64Type, goodId: UInt64Type, quantity: UInt64Type, entityType?: EntityTypeName): Action;
2311
- sellItems(entityId: UInt64Type, goodId: UInt64Type, quantity: UInt64Type, entityType?: EntityTypeName): Action;
2312
- buyShip(account: NameType, name: string): Action;
2313
- buyWarehouse(account: NameType, shipId: UInt64Type, name: string): Action;
2314
- buyContainer(account: NameType, shipId: UInt64Type, name: string): Action;
2315
- takeLoan(account: NameType, amount: UInt64Type): Action;
2316
- payLoan(account: NameType, amount: UInt64Type): Action;
2317
- foundCompany(account: NameType, name: string): Action;
2318
- join(account: NameType): Action;
2319
- extract(shipId: UInt64Type): Action;
2320
- warp(shipId: UInt64Type, destination: CoordinatesType): Action;
2321
- joinGame(account: NameType, companyName: string): Action[];
2322
- sellAllCargo(ship: Ship | UInt64Type, cargo?: SellableCargo[]): Action[];
2323
- }
2324
-
2325
- declare class GameContext {
2326
- readonly client: APIClient;
2327
- readonly server: Contract$2;
2328
- readonly platform: Contract$2;
2329
- private _entities?;
2330
- private _players?;
2331
- private _locations?;
2332
- private _trades?;
2333
- private _epochs?;
2334
- private _actions?;
2335
- private _gameCache?;
2336
- private _stateCache?;
2337
- constructor(client: APIClient, server: Contract$2, platform: Contract$2);
2338
- get entities(): EntitiesManager;
2339
- get players(): PlayersManager;
2340
- get locations(): LocationsManager;
2341
- get trades(): TradesManager;
2342
- get epochs(): EpochsManager;
2343
- get actions(): ActionsManager;
2344
- getGame(reload?: boolean): Promise<Types$1.game_row>;
2345
- getState(reload?: boolean): Promise<GameState>;
2346
- get cachedGame(): Types$1.game_row | undefined;
2347
- get cachedState(): GameState | undefined;
2348
- }
2349
-
2350
- declare abstract class BaseManager {
2351
- protected readonly context: GameContext;
2352
- constructor(context: GameContext);
2353
- protected get client(): _wharfkit_antelope.APIClient;
2354
- protected get server(): _wharfkit_contract.Contract;
2355
- protected get platform(): _wharfkit_contract.Contract;
2356
- protected getGame(): Promise<Types$1.game_row>;
2357
- protected getState(): Promise<GameState>;
2358
- }
2359
-
2360
- interface WarehouseStateInput {
2361
- id: UInt64Type;
2362
- owner: string;
2363
- name: string;
2364
- coordinates: CoordinatesType | {
2365
- x: number;
2366
- y: number;
2367
- z?: number;
2368
- };
2369
- capacity: number;
2370
- loaders: Types.loader_stats;
2371
- schedule?: Types.schedule;
2372
- cargo?: Types.cargo_item[];
2373
- }
2374
- declare class Warehouse extends Types.entity_info {
2375
- private _sched?;
2376
- private _inv?;
2377
- get name(): string;
2378
- get inv(): InventoryAccessor;
2379
- get inventory(): EntityInventory[];
2380
- get sched(): ScheduleAccessor;
2381
- get isIdle(): boolean;
2382
- isLoading(now: Date): boolean;
2383
- isUnloading(now: Date): boolean;
2384
- get location(): Location;
2385
- get totalCargoMass(): UInt64;
2386
- get cargoValue(): UInt64;
2387
- get maxCapacity(): UInt64;
2388
- get availableCapacity(): UInt64;
2389
- hasSpace(goodMass: UInt64, quantity: number): boolean;
2390
- get isFull(): boolean;
2391
- getCargoForItem(goodId: UInt64Type): EntityInventory | undefined;
2392
- get orbitalAltitude(): number;
2393
- }
2394
1662
 
2395
1663
  interface ContainerStateInput {
2396
1664
  id: UInt64Type;
@@ -2421,6 +1689,10 @@ declare class Container extends Types.entity_info {
2421
1689
  get isFull(): boolean;
2422
1690
  get orbitalAltitude(): number;
2423
1691
  }
1692
+ declare function computeContainerCapabilities(stats: Record<string, number>): {
1693
+ hullmass: number;
1694
+ capacity: number;
1695
+ };
2424
1696
 
2425
1697
  type EntityType = 'ship' | 'warehouse' | 'container' | 'location';
2426
1698
  declare class EntitiesManager extends BaseManager {
@@ -2459,7 +1731,6 @@ declare class Shipload {
2459
1731
  get entities(): EntitiesManager;
2460
1732
  get players(): PlayersManager;
2461
1733
  get locations(): LocationsManager;
2462
- get trades(): TradesManager;
2463
1734
  get epochs(): EpochsManager;
2464
1735
  get actions(): ActionsManager;
2465
1736
  getGame(reload?: boolean): Promise<Types$1.game_row>;
@@ -2474,24 +1745,6 @@ declare const itemIds: UInt16[];
2474
1745
  declare function getItem(itemId: UInt16Type): Item;
2475
1746
  declare function getItems(): Item[];
2476
1747
 
2477
- declare enum Rarities {
2478
- legendary = "LEGENDARY",
2479
- epic = "EPIC",
2480
- rare = "RARE",
2481
- uncommon = "UNCOMMON",
2482
- common = "COMMON",
2483
- trash = "TRASH"
2484
- }
2485
- interface Rarity {
2486
- rarity: Rarities;
2487
- minMultiplier: number;
2488
- maxMultiplier: number;
2489
- }
2490
- declare function getRarity(gameSeed: Checksum256Type, epochSeed: Checksum256Type, location: CoordinatesType, goodId: UInt16Type): Rarity;
2491
- declare function getRarityMultiplier(gameSeed: Checksum256Type, epochSeed: Checksum256Type, location: CoordinatesType, goodId: UInt16Type): number;
2492
- declare function marketPrice(location: ActionParams.Type.coordinates, goodId: UInt16Type, gameSeed: Checksum256Type, state: Types.state_row): ItemPrice;
2493
- declare function marketPrices(location: ActionParams.Type.coordinates, gameSeed: Checksum256Type, state: Types.state_row): ItemPrice[];
2494
-
2495
1748
  declare function getLocationType(gameSeed: Checksum256Type, coordinates: CoordinatesType): LocationType;
2496
1749
  declare function isExtractableLocation(locationType: LocationType): boolean;
2497
1750
  declare function getSystemName(gameSeed: Checksum256Type, location: CoordinatesType): string;
@@ -2555,88 +1808,156 @@ declare function resolveStats(category: ResourceCategory, stats: {
2555
1808
  stat3: number;
2556
1809
  }): NamedStats;
2557
1810
 
1811
+ interface StackInput {
1812
+ quantity: number;
1813
+ stats: Record<string, number>;
1814
+ }
1815
+ interface CategoryStacks {
1816
+ category: ResourceCategory;
1817
+ stacks: StackInput[];
1818
+ }
1819
+ declare function encodeStats(values: number[]): bigint;
1820
+ declare function decodeStats(seed: bigint, count: number): number[];
1821
+ declare function decodeCraftedItemStats(itemId: number, seed: bigint): Record<string, number>;
1822
+ declare function blendStacks(stacks: StackInput[], statKey: string): number;
1823
+ declare function computeComponentStats(componentId: number, categoryStacks: CategoryStacks[]): {
1824
+ key: string;
1825
+ value: number;
1826
+ }[];
1827
+ declare function blendComponentStacks(stacks: {
1828
+ quantity: number;
1829
+ stats: Record<string, number>;
1830
+ }[]): Record<string, number>;
1831
+ declare function computeEntityStats(entityRecipeId: string, componentStacks: Record<number, {
1832
+ quantity: number;
1833
+ stats: Record<string, number>;
1834
+ }[]>): {
1835
+ key: string;
1836
+ value: number;
1837
+ }[];
1838
+ declare function blendCargoStacks(itemId: number, stacks: {
1839
+ quantity: number;
1840
+ seed: UInt64;
1841
+ }[]): UInt64;
1842
+
2558
1843
  declare function hash(seed: Checksum256Type, string: string): Checksum256;
2559
1844
  declare function hash512(seed: Checksum256Type, string: string): Checksum512;
2560
1845
 
2561
1846
  /**
2562
- * Trade calculation result
2563
- */
2564
- interface TradeCalculation {
2565
- maxQuantity: number;
2566
- totalCost: number;
2567
- totalMass: UInt64;
2568
- affordableQuantity: number;
2569
- spaceForQuantity: number;
2570
- }
2571
- /**
2572
- * Calculate updated weighted average cargo cost after purchase.
2573
- * Matches contract logic: (paid * owned + cost) / (owned + quantity)
1847
+ * Travel calculations for ship movement, energy usage, and flight times.
2574
1848
  *
2575
- * @param currentPaid - Current average cost per unit (from cargo.paid)
2576
- * @param currentOwned - Current owned quantity
2577
- * @param purchaseCost - Total cost of new purchase (price * quantity)
2578
- * @param purchaseQuantity - Quantity being purchased
2579
- * @returns New weighted average cost per unit
1849
+ * Functions prefixed with `calc_` are contract-parity functions that mirror
1850
+ * the C++ implementation in the server contract (schedule.cpp, ship.cpp).
1851
+ * These use snake_case intentionally to match the contract naming convention
1852
+ * and signal that they must produce identical results to the on-chain code.
2580
1853
  *
2581
- * @example
2582
- * // Owned 10 units at 100 each, buying 5 more at 120 each
2583
- * const newPaid = calculateUpdatedCargoCost(
2584
- * UInt64.from(100),
2585
- * UInt32.from(10),
2586
- * UInt64.from(600),
2587
- * UInt32.from(5)
2588
- * )
2589
- * // Result: (100*10 + 600) / (10+5) = 106.67 per unit
2590
- */
2591
- declare function calculateUpdatedCargoCost(currentPaid: UInt64, currentOwned: UInt32, purchaseCost: UInt64, purchaseQuantity: UInt32): UInt64;
2592
- /**
2593
- * Calculate the maximum quantity of a good a ship can buy
2594
- * considering both space and player balance
2595
- */
2596
- declare function calculateMaxTradeQuantity(ship: Ship, player: Player, goodPrice: ItemPrice): TradeCalculation;
2597
- /**
2598
- * Trade profit calculation result
1854
+ * Functions prefixed with `calculate` are higher-level SDK helpers that may
1855
+ * combine multiple contract calculations for convenience.
2599
1856
  */
2600
- interface TradeProfitResult {
2601
- revenue: UInt64;
2602
- cost: UInt64;
2603
- profit: Int64;
2604
- margin: number;
1857
+
1858
+ declare function calc_orbital_altitude(mass: number): number;
1859
+ declare function distanceBetweenCoordinates(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): UInt64;
1860
+ declare function distanceBetweenPoints(x1: Int64Type, y1: Int64Type, x2: Int64Type, y2: Int64Type): UInt64;
1861
+ declare function lerp(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates, time: number): ActionParams.Type.coordinates;
1862
+ declare function rotation(origin: ActionParams.Type.coordinates, destination: ActionParams.Type.coordinates): number;
1863
+ declare function findNearbyPlanets(seed: Checksum256, origin: ActionParams.Type.coordinates, maxDistance?: UInt64Type): Distance[];
1864
+ declare function calc_rechargetime(capacity: UInt32Type, energy: UInt32Type, recharge: UInt32Type): UInt32;
1865
+ declare function calc_ship_rechargetime(ship: ShipLike): UInt32;
1866
+ declare function calc_flighttime(distance: UInt64Type, acceleration: number): UInt32;
1867
+ declare function calc_loader_flighttime(ship: ShipLike, mass: UInt64, altitude?: number): UInt32;
1868
+ declare function calc_loader_acceleration(ship: ShipLike, mass: UInt64): number;
1869
+ declare function calc_ship_flighttime(ship: ShipLike, mass: UInt64, distance: UInt64): UInt32;
1870
+ declare function calc_ship_acceleration(ship: ShipLike, mass: UInt64): number;
1871
+ declare function calc_acceleration(thrust: number, mass: number): number;
1872
+ declare function calc_ship_mass(ship: ShipLike, cargos: CargoMassInfo[]): UInt64;
1873
+ declare function calc_energyusage(distance: UInt64Type, drain: UInt32Type): UInt32;
1874
+ declare function calculateTransferTime(ship: ShipLike, cargos: CargoMassInfo[], quantities?: Map<number, number>): UInt32;
1875
+ declare function calculateRefuelingTime(ship: ShipLike): UInt32;
1876
+ declare function calculateFlightTime(ship: ShipLike, cargos: CargoMassInfo[], distance: UInt64Type): UInt32;
1877
+ interface LoadTimeBreakdown {
1878
+ unloadTime: number;
1879
+ loadTime: number;
1880
+ totalTime: number;
1881
+ unloadMass: number;
1882
+ loadMass: number;
2605
1883
  }
2606
- /**
2607
- * Calculate profit for a trade route
2608
- */
2609
- declare function calculateTradeProfit(quantity: UInt32Type, buyPrice: UInt32Type, sellPrice: UInt32Type): TradeProfitResult;
2610
- /**
2611
- * Calculate profit per unit of mass
2612
- */
2613
- declare function calculateProfitPerMass(quantity: number, buyPrice: number, sellPrice: number, massPerUnit: number): number;
2614
- /**
2615
- * Calculate profit per second for a trade route
2616
- */
2617
- declare function calculateProfitPerSecond(profit: Int64Type, travelTimeSeconds: UInt32Type): number;
2618
- /**
2619
- * Find the best good to trade between two locations
2620
- */
2621
- declare function findBestItemToTrade(ship: Ship, player: Player, originPrices: ItemPrice[], destPrices: ItemPrice[], travelTimeSeconds: UInt32Type): {
2622
- item: ItemPrice;
1884
+ declare function calculateLoadTimeBreakdown(ship: ShipLike, cargos: CargoMassInfo[], loadQuantities?: Map<number, number>, unloadQuantities?: Map<number, number>): LoadTimeBreakdown;
1885
+ interface EstimatedTravelTime {
1886
+ flightTime: UInt32;
1887
+ rechargeTime: UInt32;
1888
+ loadTime: UInt32;
1889
+ unloadTime: UInt32;
1890
+ total: UInt32;
1891
+ }
1892
+ interface EstimateTravelTimeOptions {
1893
+ needsRecharge?: boolean;
1894
+ loadMass?: UInt32Type;
1895
+ unloadMass?: UInt32Type;
1896
+ }
1897
+ declare function estimateTravelTime(ship: ShipLike, travelMass: UInt64Type, distance: UInt64Type, options?: EstimateTravelTimeOptions): EstimatedTravelTime;
1898
+ declare function estimateDealTravelTime(ship: ShipLike, shipMass: UInt64Type, distance: UInt64Type, loadMass: UInt32Type): UInt32;
1899
+ declare function hasEnergyForDistance(ship: ShipLike, distance: UInt64Type): boolean;
1900
+ interface TransferEntity {
1901
+ location: {
1902
+ z?: {
1903
+ toNumber(): number;
1904
+ } | number;
1905
+ };
1906
+ loaders?: {
1907
+ thrust: {
1908
+ toNumber(): number;
1909
+ } | number;
1910
+ mass: {
1911
+ toNumber(): number;
1912
+ } | number;
1913
+ quantity: {
1914
+ toNumber(): number;
1915
+ } | number;
1916
+ };
1917
+ }
1918
+ interface HasScheduleAndLocation {
1919
+ coordinates: ActionParams.Type.coordinates;
1920
+ schedule?: Types.schedule;
1921
+ }
1922
+ declare function getFlightOrigin(entity: HasScheduleAndLocation, flightTaskIndex: number): ActionParams.Type.coordinates;
1923
+ declare function getDestinationLocation(entity: HasScheduleAndLocation): ActionParams.Type.coordinates | undefined;
1924
+ declare function getPositionAt(entity: HasScheduleAndLocation, taskIndex: number, taskProgress: number): ActionParams.Type.coordinates;
1925
+ declare function calc_transfer_duration(source: TransferEntity, dest: TransferEntity, cargoMass: number): number;
1926
+
1927
+ interface CargoData {
1928
+ cargo: EntityInventory[];
1929
+ }
1930
+ declare function totalCargoMass(cargo: EntityInventory[]): UInt64;
1931
+ declare function getCargoForItem(cargo: EntityInventory[], goodId: UInt64Type): EntityInventory | undefined;
1932
+ declare function hasSpace(currentMass: UInt64, maxCapacity: UInt64, goodMass: UInt64, quantity: number): boolean;
1933
+ declare function availableCapacity(currentMass: UInt64, maxCapacity: UInt64): UInt64;
1934
+ declare function isFull(currentMass: UInt64, maxCapacity: UInt64): boolean;
1935
+ declare function afterRemoveItems(cargo: Types.cargo_item[], goodsToRemove: Array<{
1936
+ goodId: number;
2623
1937
  quantity: number;
2624
- profit: number;
2625
- profitPerSecond: number;
2626
- margin: number;
2627
- } | null;
2628
- /**
2629
- * Calculate break-even price for selling cargo
2630
- */
2631
- declare function calculateBreakEvenPrice(costPaid: number, quantity: number): number;
2632
- /**
2633
- * Check if a trade is profitable
2634
- */
2635
- declare function isProfitable(buyPrice: UInt32Type, sellPrice: UInt32Type): boolean;
2636
- /**
2637
- * Calculate return on investment percentage
2638
- */
2639
- declare function calculateROI(cost: number, profit: number): number;
1938
+ }>): EntityInventory[];
1939
+ declare function afterRemoveAllItems(cargo: Types.cargo_item[]): EntityInventory[];
1940
+
1941
+ type cargoUtils_CargoData = CargoData;
1942
+ declare const cargoUtils_totalCargoMass: typeof totalCargoMass;
1943
+ declare const cargoUtils_getCargoForItem: typeof getCargoForItem;
1944
+ declare const cargoUtils_hasSpace: typeof hasSpace;
1945
+ declare const cargoUtils_availableCapacity: typeof availableCapacity;
1946
+ declare const cargoUtils_isFull: typeof isFull;
1947
+ declare const cargoUtils_afterRemoveItems: typeof afterRemoveItems;
1948
+ declare const cargoUtils_afterRemoveAllItems: typeof afterRemoveAllItems;
1949
+ declare namespace cargoUtils {
1950
+ export {
1951
+ cargoUtils_CargoData as CargoData,
1952
+ cargoUtils_totalCargoMass as totalCargoMass,
1953
+ cargoUtils_getCargoForItem as getCargoForItem,
1954
+ cargoUtils_hasSpace as hasSpace,
1955
+ cargoUtils_availableCapacity as availableCapacity,
1956
+ cargoUtils_isFull as isFull,
1957
+ cargoUtils_afterRemoveItems as afterRemoveItems,
1958
+ cargoUtils_afterRemoveAllItems as afterRemoveAllItems,
1959
+ };
1960
+ }
2640
1961
 
2641
1962
  interface Entity {
2642
1963
  id: UInt64;
@@ -2645,8 +1966,7 @@ interface Entity {
2645
1966
  entity_name: string;
2646
1967
  location: Coordinates | Types.coordinates;
2647
1968
  }
2648
- type ShipEntity = Entity & MovementCapability & EnergyCapability & StorageCapability & LoaderCapability & MassCapability & ScheduleCapability & {
2649
- trade?: Types.trade_stats;
1969
+ type ShipEntity = Entity & Partial<MovementCapability> & Partial<EnergyCapability> & StorageCapability & Partial<LoaderCapability> & MassCapability & ScheduleCapability & {
2650
1970
  extractor?: Types.extractor_stats;
2651
1971
  };
2652
1972
  type WarehouseEntity = Entity & StorageCapability & LoaderCapability & ScheduleCapability;
@@ -2657,7 +1977,6 @@ declare function canMove(e: Entity): e is Entity & MovementCapability & EnergyCa
2657
1977
  declare function hasEnergy(e: Entity): e is Entity & EnergyCapability;
2658
1978
  declare function hasStorage(e: Entity): e is Entity & StorageCapability;
2659
1979
  declare function hasLoaders(e: Entity): e is Entity & LoaderCapability;
2660
- declare function hasTrade(e: Entity): e is Entity & TradeCapability;
2661
1980
  declare function hasMass(e: Entity): e is Entity & MassCapability;
2662
1981
  declare function hasSchedule(e: Entity): e is Entity & ScheduleCapability;
2663
1982
  declare function hasExtractor(e: Entity): e is Entity & ExtractorCapability;
@@ -2669,9 +1988,184 @@ declare function needsRecharge(entity: MovementCapability & EnergyCapability): b
2669
1988
 
2670
1989
  declare function calcLoadDuration(entity: LoaderCapability, cargoMass: UInt64): UInt32;
2671
1990
 
2672
- declare function calc_extraction_duration(extractor: Types.extractor_stats, cargoMass: number, stratum: number, richness: number): UInt32;
1991
+ declare function calc_extraction_duration(extractor: Types.extractor_stats, itemMass: number, quantity: number, stratum: number, richness: number): UInt32;
2673
1992
  declare function calc_extraction_energy(extractor: Types.extractor_stats, duration: number): UInt16;
2674
1993
 
1994
+ interface CrafterCapability {
1995
+ crafter: Types.crafter_stats;
1996
+ }
1997
+ declare function capsHasCrafter(caps: EntityCapabilities): boolean;
1998
+ declare function calc_craft_duration(speed: number, totalInputMass: number, quantity: number): UInt32;
1999
+ declare function calc_craft_energy(drain: number, duration: number): UInt16;
2000
+
2001
+ declare const ITEM_ENGINE_T1 = 10006;
2002
+ declare const ITEM_GENERATOR_T1 = 10007;
2003
+ declare const ITEM_EXTRACTOR_T1 = 10014;
2004
+ declare const ITEM_LOADER_T1 = 10015;
2005
+ declare const ITEM_MANUFACTURING_T1 = 10016;
2006
+ declare const MODULE_ANY = 0;
2007
+ declare const MODULE_ENGINE = 1;
2008
+ declare const MODULE_GENERATOR = 2;
2009
+ declare const MODULE_EXTRACTOR = 3;
2010
+ declare const MODULE_LOADER = 4;
2011
+ declare const MODULE_WARP = 5;
2012
+ declare const MODULE_CRAFTER = 6;
2013
+ declare const MODULE_LAUNCHER = 7;
2014
+ interface CargoSeed {
2015
+ itemId: number;
2016
+ seed: bigint;
2017
+ }
2018
+ interface ModuleEntry {
2019
+ type: number;
2020
+ installed?: CargoSeed;
2021
+ }
2022
+ declare function moduleAccepts(slotType: number, moduleType: number): boolean;
2023
+ declare function getModuleCapabilityType(itemId: number): number;
2024
+ declare function isModuleItem(itemId: number): boolean;
2025
+
2026
+ declare const categoryColors: Record<ResourceCategory, string>;
2027
+ declare const tierColors: Record<ResourceTier, string>;
2028
+ declare const categoryIcons: Record<ResourceCategory, string>;
2029
+ declare const componentIcon = "\u25A3";
2030
+ declare const moduleIcon = "\u2B22";
2031
+
2032
+ declare const ITEM_DRILL_SHAFT = 10009;
2033
+ declare const ITEM_EXTRACTION_PROBE = 10010;
2034
+ declare const ITEM_CARGO_ARM = 10011;
2035
+ declare const ITEM_TOOL_BIT = 10012;
2036
+ declare const ITEM_REACTION_CHAMBER = 10013;
2037
+ declare const ITEM_HULL_PLATES = 10001;
2038
+ declare const ITEM_CARGO_LINING = 10002;
2039
+ declare const ITEM_CONTAINER_PACKED = 10003;
2040
+ declare const ITEM_THRUSTER_CORE = 10004;
2041
+ declare const ITEM_POWER_CELL = 10005;
2042
+ declare const ITEM_SHIP_T1_PACKED = 10008;
2043
+ interface RecipeInput {
2044
+ category?: ResourceCategory;
2045
+ itemId?: number;
2046
+ quantity: number;
2047
+ }
2048
+ interface ComponentStat {
2049
+ key: string;
2050
+ source: ResourceCategory;
2051
+ }
2052
+ interface ComponentDefinition {
2053
+ id: number;
2054
+ name: string;
2055
+ description: string;
2056
+ color: string;
2057
+ mass: number;
2058
+ stats: ComponentStat[];
2059
+ recipe: RecipeInput[];
2060
+ usedIn: {
2061
+ type: 'entity' | 'module';
2062
+ name: string;
2063
+ }[];
2064
+ }
2065
+ interface EntityRecipe {
2066
+ id: string;
2067
+ name: string;
2068
+ description: string;
2069
+ color: string;
2070
+ packedItemId: number;
2071
+ recipe: RecipeInput[];
2072
+ stats: {
2073
+ key: string;
2074
+ sourceComponentId: number;
2075
+ sourceStatKey: string;
2076
+ }[];
2077
+ }
2078
+ interface CraftableItem {
2079
+ type: 'component' | 'entity' | 'module';
2080
+ id: number | string;
2081
+ name: string;
2082
+ description: string;
2083
+ color: string;
2084
+ }
2085
+ declare const components: ComponentDefinition[];
2086
+ declare const entityRecipes: EntityRecipe[];
2087
+ interface ModuleRecipe {
2088
+ id: string;
2089
+ name: string;
2090
+ description: string;
2091
+ color: string;
2092
+ itemId: number;
2093
+ moduleType: number;
2094
+ recipe: RecipeInput[];
2095
+ stats: {
2096
+ key: string;
2097
+ sourceComponentId: number;
2098
+ sourceStatKey: string;
2099
+ }[];
2100
+ }
2101
+ declare const moduleRecipes: ModuleRecipe[];
2102
+ declare function getModuleRecipe(id: string): ModuleRecipe | undefined;
2103
+ declare function getModuleRecipeByItemId(itemId: number): ModuleRecipe | undefined;
2104
+ declare function getComponentById(id: number): ComponentDefinition | undefined;
2105
+ declare function getEntityRecipe(id: string): EntityRecipe | undefined;
2106
+ declare function getEntityRecipeByItemId(itemId: number): EntityRecipe | undefined;
2107
+ declare function getAllCraftableItems(): CraftableItem[];
2108
+ declare function getComponentsForCategory(category: ResourceCategory): ComponentDefinition[];
2109
+ declare function getComponentsForStat(statKey: string): ComponentDefinition[];
2110
+
2111
+ declare function computeShipHullCapabilities(stats: Record<string, number>): {
2112
+ hullmass: number;
2113
+ capacity: number;
2114
+ };
2115
+ declare function computeEngineCapabilities(stats: Record<string, number>): {
2116
+ thrust: number;
2117
+ drain: number;
2118
+ };
2119
+ declare function computeGeneratorCapabilities(stats: Record<string, number>): {
2120
+ capacity: number;
2121
+ recharge: number;
2122
+ };
2123
+ declare function computeExtractorCapabilities(stats: Record<string, number>): {
2124
+ rate: number;
2125
+ drain: number;
2126
+ depth: number;
2127
+ drill: number;
2128
+ };
2129
+ declare function computeLoaderCapabilities(stats: Record<string, number>): {
2130
+ mass: number;
2131
+ thrust: number;
2132
+ quantity: number;
2133
+ };
2134
+ declare function computeManufacturingCapabilities(stats: Record<string, number>): {
2135
+ speed: number;
2136
+ drain: number;
2137
+ };
2138
+
2139
+ interface ResolvedItemStat {
2140
+ key: string;
2141
+ label: string;
2142
+ abbreviation: string;
2143
+ value: number;
2144
+ color: string;
2145
+ category: ResourceCategory;
2146
+ inverted?: boolean;
2147
+ }
2148
+ interface ResolvedAttributeGroup {
2149
+ capability: string;
2150
+ attributes: {
2151
+ label: string;
2152
+ value: number;
2153
+ }[];
2154
+ }
2155
+ type ResolvedItemType = 'resource' | 'component' | 'module' | 'entity';
2156
+ interface ResolvedItem {
2157
+ itemId: number;
2158
+ name: string;
2159
+ icon: string;
2160
+ category?: ResourceCategory;
2161
+ tier: ResourceTier;
2162
+ mass: number;
2163
+ itemType: ResolvedItemType;
2164
+ stats?: ResolvedItemStat[];
2165
+ attributes?: ResolvedAttributeGroup[];
2166
+ }
2167
+ declare function resolveItem(itemId: UInt16Type, seed?: UInt64Type, modules?: Types.module_entry[]): ResolvedItem;
2168
+
2675
2169
  type movement_stats = Types.movement_stats;
2676
2170
  type energy_stats = Types.energy_stats;
2677
2171
  type loader_stats = Types.loader_stats;
@@ -2685,4 +2179,4 @@ type location_epoch = Types.location_epoch;
2685
2179
  type location_derived = Types.location_derived;
2686
2180
  type location_row = Types.location_row;
2687
2181
 
2688
- export { ActionsManager, AnyEntity, BetterSaleLocation, COMMIT_ALREADY_SET, COMMIT_CANNOT_MATCH, COMMIT_NOT_SET, COMPANY_NOT_FOUND, CONTAINER_Z, CargoData, CargoMassInfo, CargoSaleItem, CollectActionType, CollectAnalysis, CollectAnalysisCallbacks, CollectAnalysisOptions, CollectOption, Container, ContainerEntity, ContainerStateInput, Coordinates, CoordinatesType, DEPTH_THRESHOLD_T1, DEPTH_THRESHOLD_T2, DEPTH_THRESHOLD_T3, DEPTH_THRESHOLD_T4, DEPTH_THRESHOLD_T5, Deal, DiscountedItemInfo, Distance, EPOCH_NON_ZERO, EPOCH_NOT_READY, ERROR_SYSTEM_ALREADY_INITIALIZED, ERROR_SYSTEM_DISABLED, ERROR_SYSTEM_NOT_INITIALIZED, EnergyCapability, EntitiesManager, Entity, EntityCapabilities, EntityInventory, EntityRefInput, EntityState, EntityType, EntityTypeName, EpochInfo, EpochsManager, EstimateTravelTimeOptions, EstimatedTravelTime, ExtractorCapability, FindDealsOptions, GAME_NOT_FOUND, GAME_SEED_NOT_SET, GameState, HasCapacity, HasCargo, HasCargomass, HasScheduleAndLocation, INITIAL_CONTAINER_CAPACITY, INITIAL_CONTAINER_HULLMASS, INITIAL_EXTRACTOR_DRAIN, INITIAL_EXTRACTOR_EFFICIENCY, INITIAL_EXTRACTOR_RATE, INITIAL_LOADER_MASS, INITIAL_LOADER_QUANTITY, INITIAL_LOADER_THRUST, INITIAL_SHIP_CAPACITY, INITIAL_SHIP_DRAIN, INITIAL_SHIP_ENERGY, INITIAL_SHIP_GENERATOR_CAPACITY, INITIAL_SHIP_HULLMASS, INITIAL_SHIP_MASS, INITIAL_SHIP_RECHARGE, INITIAL_SHIP_THRUST, INITIAL_SHIP_Z, INITIAL_WAREHOUSE_CAPACITY, INSUFFICIENT_BALANCE, INSUFFICIENT_ITEM_QUANTITY, INSUFFICIENT_ITEM_SUPPLY, INVALID_AMOUNT, ITEM_DOES_NOT_EXIST, ITEM_NOT_AVAILABLE_AT_LOCATION, InventoryAccessor, Item, ItemPrice, LOCATION_MAX_DEPTH, LOCATION_MIN_DEPTH, LoadTimeBreakdown, LoaderCapability, Location, LocationType, LocationsManager, MAX_ORBITAL_ALTITUDE, MIN_ORBITAL_ALTITUDE, MassCapability, MovementCapability, NO_SCHEDULE, NamedStats, PLANET_SUBTYPE_GAS_GIANT, PLANET_SUBTYPE_ICY, PLANET_SUBTYPE_INDUSTRIAL, PLANET_SUBTYPE_OCEAN, PLANET_SUBTYPE_ROCKY, PLANET_SUBTYPE_TERRESTRIAL, PLAYER_ALREADY_JOINED, PLAYER_NOT_FOUND, PRECISION, platform as PlatformContract, Player, PlayerStateInput, PlayersManager, PotentialDeal, Projectable, ProjectedEntity, REQUIRES_MORE_THAN_ONE, REQUIRES_POSITIVE_VALUE, Rarities, Rarity, RepositionLocation, ResourceCategory, ResourceStats, ResourceTier, SHIP_ALREADY_THERE, SHIP_ALREADY_TRAVELING, SHIP_CANNOT_BUY_TRAVELING, SHIP_CANNOT_CANCEL_TASK, SHIP_CANNOT_UPDATE_TRAVELING, SHIP_CARGO_NOT_LOADED, SHIP_CARGO_NOT_OWNED, SHIP_INVALID_CARGO, SHIP_INVALID_DESTINATION, SHIP_INVALID_TRAVEL_DURATION, SHIP_NOT_ARRIVED, SHIP_NOT_ENOUGH_ENERGY, SHIP_NOT_ENOUGH_ENERGY_CAPACITY, SHIP_NOT_FOUND, SHIP_NOT_IDLE, SHIP_NOT_OWNED, SHIP_NO_COMPLETED_TASKS, SHIP_NO_TASKS_TO_CANCEL, ScheduleAccessor, ScheduleCapability, ScheduleData, Scheduleable, server as ServerContract, Ship, ShipEntity, ShipLike, ShipStateInput, Shipload, StatDefinition, StorageCapability, StratumInfo, TRAVEL_MAX_DURATION, TaskCancelable, TaskType, TradeCalculation, TradeCapability, TradeProfitResult, TradesManager, TransferEntity, WAREHOUSE_ALREADY_AT_LOCATION, WAREHOUSE_CAPACITY_EXCEEDED, WAREHOUSE_NOT_FOUND, WAREHOUSE_Z, Warehouse, WarehouseEntity, WarehouseStateInput, analyzeCargoSale, analyzeCollectOptions, availableCapacity$1 as availableCapacity, availableCapacityFromMass, calcCargoMass, calcCargoValue, calcEnergyUsage, calcLoadDuration, calc_acceleration, calc_energyusage, calc_extraction_duration, calc_extraction_energy, calc_flighttime, calc_loader_acceleration, calc_loader_flighttime, calc_orbital_altitude, calc_rechargetime, calc_ship_acceleration, calc_ship_flighttime, calc_ship_mass, calc_ship_rechargetime, calc_transfer_duration, calculateBreakEvenPrice, calculateFlightTime, calculateLoadTimeBreakdown, calculateMaxTradeQuantity, calculateProfitPerMass, calculateProfitPerSecond, calculateROI, calculateRefuelingTime, calculateTradeProfit, calculateTransferTime, calculateUpdatedCargoCost, canMove, capsHasExtractor, capsHasLoaders, capsHasMass, capsHasMovement, capsHasStorage, capsHasTrade, cargoUtils, cargo_item, container_row, coordsToLocationId, createExploreOption, createInventoryAccessor, createProjectedEntity, createScheduleAccessor, createSellAndRepositionOption, createSellAndStayOption, createSellAndTradeOption, createTravelToSellOption, Shipload as default, depthScaleFactor, deriveLocation, deriveLocationEpoch, deriveLocationSize, deriveLocationStatic, deriveResourceStats, deriveStratum, distanceBetweenCoordinates, distanceBetweenPoints, energyPercent, energy_stats, estimateDealTravelTime, estimateTravelTime, extractor_stats, findBestDeal, findBestItemToTrade, findDealsForShip, findNearbyPlanets, getCurrentEpoch, getDepthThreshold, getDestinationLocation, getEligibleResources, getEpochInfo, getFlightOrigin, getItem, getItems, getLocationCandidates, getLocationType, getPositionAt, getRarity, getRarityMultiplier, getResourceTier, getResourceWeight, getStatDefinitions, getStatName, getSystemName, hasEnergy, hasEnergyForDistance, hasExtractor, hasLoaders, hasMass, hasSchedule, hasSpace$1 as hasSpace, hasSpaceForMass, hasStorage, hasSystem, hasTrade, hash, hash512, isExtractableLocation, isFull$1 as isFull, isFullFromMass, isProfitable, itemIds, lerp, loader_stats, location_derived, location_epoch, location_row, location_static, makeContainer, makeShip, makeWarehouse, marketPrice, marketPrices, maxTravelDistance, movement_stats, needsRecharge, projectEntity, projectEntityAt, resolveStats, rotation, schedule, task, toLocation, warehouse_row };
2182
+ export { ActionsManager, AnyEntity, BASE_ORBITAL_MASS, COMMIT_ALREADY_SET, COMMIT_CANNOT_MATCH, COMMIT_NOT_SET, COMPANY_NOT_FOUND, CONTAINER_Z, CargoData, CargoMassInfo, CargoSeed, CategoryStacks, ComponentDefinition, ComponentStat, Container, ContainerEntity, ContainerStateInput, Coordinates, CoordinatesType, CraftableItem, CrafterCapability, DEPTH_THRESHOLD_T1, DEPTH_THRESHOLD_T2, DEPTH_THRESHOLD_T3, DEPTH_THRESHOLD_T4, DEPTH_THRESHOLD_T5, Distance, EPOCH_NON_ZERO, EPOCH_NOT_READY, ERROR_SYSTEM_ALREADY_INITIALIZED, ERROR_SYSTEM_DISABLED, ERROR_SYSTEM_NOT_INITIALIZED, EnergyCapability, EntitiesManager, Entity, EntityCapabilities, EntityInventory, EntityRecipe, EntityRefInput, EntityState, EntityType, EntityTypeName, EpochInfo, EpochsManager, EstimateTravelTimeOptions, EstimatedTravelTime, ExtractorCapability, GAME_NOT_FOUND, GAME_SEED_NOT_SET, GameState, HasCapacity, HasCargo, HasCargomass, HasScheduleAndLocation, INITIAL_CONTAINER_CAPACITY, INITIAL_CONTAINER_HULLMASS, INITIAL_WAREHOUSE_CAPACITY, INSUFFICIENT_BALANCE, INSUFFICIENT_ITEM_QUANTITY, INSUFFICIENT_ITEM_SUPPLY, INVALID_AMOUNT, ITEM_CARGO_ARM, ITEM_CARGO_LINING, ITEM_CONTAINER_PACKED, ITEM_DOES_NOT_EXIST, ITEM_DRILL_SHAFT, ITEM_ENGINE_T1, ITEM_EXTRACTION_PROBE, ITEM_EXTRACTOR_T1, ITEM_GENERATOR_T1, ITEM_HULL_PLATES, ITEM_LOADER_T1, ITEM_MANUFACTURING_T1, ITEM_NOT_AVAILABLE_AT_LOCATION, ITEM_POWER_CELL, ITEM_REACTION_CHAMBER, ITEM_SHIP_T1_PACKED, ITEM_THRUSTER_CORE, ITEM_TOOL_BIT, InventoryAccessor, Item, LOCATION_MAX_DEPTH, LOCATION_MIN_DEPTH, LoadTimeBreakdown, LoaderCapability, Location, LocationType, LocationsManager, MAX_ORBITAL_ALTITUDE, MIN_ORBITAL_ALTITUDE, MODULE_ANY, MODULE_CRAFTER, MODULE_ENGINE, MODULE_EXTRACTOR, MODULE_GENERATOR, MODULE_LAUNCHER, MODULE_LOADER, MODULE_WARP, MassCapability, ModuleEntry, ModuleRecipe, MovementCapability, NO_SCHEDULE, NamedStats, PLANET_SUBTYPE_GAS_GIANT, PLANET_SUBTYPE_ICY, PLANET_SUBTYPE_INDUSTRIAL, PLANET_SUBTYPE_OCEAN, PLANET_SUBTYPE_ROCKY, PLANET_SUBTYPE_TERRESTRIAL, PLAYER_ALREADY_JOINED, PLAYER_NOT_FOUND, PRECISION, platform as PlatformContract, Player, PlayerStateInput, PlayersManager, Projectable, ProjectedEntity, REQUIRES_MORE_THAN_ONE, REQUIRES_POSITIVE_VALUE, RecipeInput, ResolvedAttributeGroup, ResolvedItem, ResolvedItemStat, ResolvedItemType, ResourceCategory, ResourceStats, ResourceTier, SHIP_ALREADY_THERE, SHIP_ALREADY_TRAVELING, SHIP_CANNOT_BUY_TRAVELING, SHIP_CANNOT_CANCEL_TASK, SHIP_CANNOT_UPDATE_TRAVELING, SHIP_CARGO_NOT_LOADED, SHIP_CARGO_NOT_OWNED, SHIP_INVALID_CARGO, SHIP_INVALID_DESTINATION, SHIP_INVALID_TRAVEL_DURATION, SHIP_NOT_ARRIVED, SHIP_NOT_ENOUGH_ENERGY, SHIP_NOT_ENOUGH_ENERGY_CAPACITY, SHIP_NOT_FOUND, SHIP_NOT_IDLE, SHIP_NOT_OWNED, SHIP_NO_COMPLETED_TASKS, SHIP_NO_TASKS_TO_CANCEL, ScheduleAccessor, ScheduleCapability, ScheduleData, Scheduleable, server as ServerContract, Ship, ShipEntity, ShipLike, ShipStateInput, Shipload, StackInput, StatDefinition, StorageCapability, StratumInfo, TRAVEL_MAX_DURATION, TaskCancelable, TaskType, TransferEntity, WAREHOUSE_ALREADY_AT_LOCATION, WAREHOUSE_CAPACITY_EXCEEDED, WAREHOUSE_NOT_FOUND, WAREHOUSE_Z, Warehouse, WarehouseEntity, WarehouseStateInput, availableCapacity$1 as availableCapacity, availableCapacityFromMass, blendCargoStacks, blendComponentStacks, blendStacks, calcCargoMass, calcEnergyUsage, calcLoadDuration, calc_acceleration, calc_craft_duration, calc_craft_energy, calc_energyusage, calc_extraction_duration, calc_extraction_energy, calc_flighttime, calc_loader_acceleration, calc_loader_flighttime, calc_orbital_altitude, calc_rechargetime, calc_ship_acceleration, calc_ship_flighttime, calc_ship_mass, calc_ship_rechargetime, calc_transfer_duration, calculateFlightTime, calculateLoadTimeBreakdown, calculateRefuelingTime, calculateTransferTime, canMove, capsHasCrafter, capsHasExtractor, capsHasLoaders, capsHasMass, capsHasMovement, capsHasStorage, cargoUtils, cargo_item, categoryColors, categoryIcons, componentIcon, components, computeComponentStats, computeContainerCapabilities, computeEngineCapabilities, computeEntityStats, computeExtractorCapabilities, computeGeneratorCapabilities, computeLoaderCapabilities, computeManufacturingCapabilities, computeShipHullCapabilities, container_row, coordsToLocationId, createInventoryAccessor, createProjectedEntity, createScheduleAccessor, decodeCraftedItemStats, decodeStats, Shipload as default, depthScaleFactor, deriveLocation, deriveLocationEpoch, deriveLocationSize, deriveLocationStatic, deriveResourceStats, deriveStratum, distanceBetweenCoordinates, distanceBetweenPoints, encodeStats, energyPercent, energy_stats, entityRecipes, estimateDealTravelTime, estimateTravelTime, extractor_stats, findNearbyPlanets, getAllCraftableItems, getComponentById, getComponentsForCategory, getComponentsForStat, getCurrentEpoch, getDepthThreshold, getDestinationLocation, getEligibleResources, getEntityRecipe, getEntityRecipeByItemId, getEpochInfo, getFlightOrigin, getItem, getItems, getLocationCandidates, getLocationType, getModuleCapabilityType, getModuleRecipe, getModuleRecipeByItemId, getPositionAt, getResourceTier, getResourceWeight, getStatDefinitions, getStatName, getSystemName, hasEnergy, hasEnergyForDistance, hasExtractor, hasLoaders, hasMass, hasSchedule, hasSpace$1 as hasSpace, hasSpaceForMass, hasStorage, hasSystem, hash, hash512, isExtractableLocation, isFull$1 as isFull, isFullFromMass, isModuleItem, itemIds, lerp, loader_stats, location_derived, location_epoch, location_row, location_static, makeContainer, makeShip, makeWarehouse, maxTravelDistance, moduleAccepts, moduleIcon, moduleRecipes, movement_stats, needsRecharge, projectEntity, projectEntityAt, resolveItem, resolveStats, rotation, schedule, task, tierColors, toLocation, warehouse_row };