@shipload/sdk 1.0.0-next.74 → 1.0.0-next.76

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 (56) hide show
  1. package/lib/scan.js +1 -1
  2. package/lib/scan.js.map +1 -1
  3. package/lib/scan.m.js +1 -1
  4. package/lib/scan.m.js.map +1 -1
  5. package/lib/shipload.d.ts +81 -35
  6. package/lib/shipload.js +13576 -11311
  7. package/lib/shipload.js.map +1 -1
  8. package/lib/shipload.m.js +13554 -11311
  9. package/lib/shipload.m.js.map +1 -1
  10. package/lib/testing.d.ts +20 -16
  11. package/lib/testing.js +229 -53
  12. package/lib/testing.js.map +1 -1
  13. package/lib/testing.m.js +229 -53
  14. package/lib/testing.m.js.map +1 -1
  15. package/package.json +6 -6
  16. package/src/capabilities/storage.ts +45 -10
  17. package/src/contracts/server.ts +49 -41
  18. package/src/data/component-process.test.ts +119 -0
  19. package/src/data/component-process.ts +33 -0
  20. package/src/data/entities.json +367 -2
  21. package/src/data/item-ids.ts +15 -0
  22. package/src/data/items.json +90 -0
  23. package/src/data/kind-registry.json +97 -7
  24. package/src/data/metadata.ts +83 -5
  25. package/src/data/recipes-runtime.ts +1 -1
  26. package/src/data/recipes.json +1476 -10
  27. package/src/data/task-types.json +9 -0
  28. package/src/derivation/capabilities.test.ts +25 -2
  29. package/src/derivation/capabilities.ts +16 -3
  30. package/src/derivation/capacity-fn-registry.ts +8 -1
  31. package/src/derivation/reserve-regen.ts +5 -9
  32. package/src/derivation/stratum.ts +1 -1
  33. package/src/derivation/tiers.ts +1 -1
  34. package/src/derivation/upgrades.ts +5 -4
  35. package/src/index-module.ts +10 -1
  36. package/src/influence/influence.test.ts +1 -1
  37. package/src/managers/actions.ts +12 -19
  38. package/src/managers/entities.test.ts +23 -0
  39. package/src/managers/entities.ts +8 -1
  40. package/src/managers/shuttle.test.ts +67 -0
  41. package/src/managers/shuttle.ts +17 -0
  42. package/src/nft/description.ts +6 -0
  43. package/src/resolution/resolve-item.test.ts +6 -6
  44. package/src/resolution/resolve-item.ts +4 -0
  45. package/src/scan/scan-wasm.base64.ts +1 -1
  46. package/src/scheduling/availability.test.ts +3 -3
  47. package/src/scheduling/availability.ts +3 -4
  48. package/src/scheduling/lanes.ts +1 -1
  49. package/src/scheduling/projection.ts +15 -13
  50. package/src/scheduling/schedule.test.ts +24 -0
  51. package/src/scheduling/schedule.ts +11 -4
  52. package/src/scheduling/task-effects.ts +3 -1
  53. package/src/scheduling/unwrap.test.ts +25 -6
  54. package/src/scheduling/unwrap.ts +19 -3
  55. package/src/travel/travel.ts +4 -0
  56. package/src/types.ts +2 -0
@@ -0,0 +1,119 @@
1
+ import {describe, expect, test} from 'bun:test'
2
+ import {
3
+ ITEM_BEAM,
4
+ ITEM_ENGINE_T1,
5
+ ITEM_ORE_T1,
6
+ ITEM_PLATE,
7
+ ITEM_PLATE_T2,
8
+ ITEM_PROSPECTOR_T1A_PACKED,
9
+ ITEM_PROSPECTOR_T2A_PACKED,
10
+ ITEM_PROSPECTOR_T2B_PACKED,
11
+ ITEM_ROUSTABOUT_T1A_PACKED,
12
+ ITEM_STORAGE_T1,
13
+ } from './item-ids'
14
+ import {getComponents} from './catalog'
15
+ import {getRecipe} from './recipes-runtime'
16
+ import {completeComponentSet, getComponentProcess} from './component-process'
17
+ import {resolveItem} from '../resolution/resolve-item'
18
+
19
+ function inputsOf(itemId: number) {
20
+ const recipe = getRecipe(itemId)
21
+ if (!recipe) throw new Error(`no recipe for ${itemId}`)
22
+ return recipe.inputs
23
+ }
24
+
25
+ describe('component process', () => {
26
+ test('every component at every tier is refined or machined, five of each per tier', () => {
27
+ const tiers = new Set(getComponents().map((item) => item.tier))
28
+ for (const tier of tiers) {
29
+ const kinds = getComponents({tier}).map((item) => getComponentProcess(item.id))
30
+ expect(kinds.filter((k) => k === 'refined').length).toBe(5)
31
+ expect(kinds.filter((k) => k === 'machined').length).toBe(5)
32
+ }
33
+ })
34
+
35
+ test('the refined five are the single-resource components', () => {
36
+ const refined = getComponents({tier: 1})
37
+ .filter((item) => getComponentProcess(item.id) === 'refined')
38
+ .map((item) => item.name)
39
+ .sort()
40
+ expect(refined).toEqual(['Ceramic', 'Plasma Cell', 'Plate', 'Polymer', 'Sensor'])
41
+ })
42
+
43
+ test('the kind holds across tiers', () => {
44
+ expect(getComponentProcess(ITEM_PLATE)).toBe('refined')
45
+ expect(getComponentProcess(ITEM_PLATE_T2)).toBe('refined')
46
+ expect(getComponentProcess(ITEM_BEAM)).toBe('machined')
47
+ })
48
+
49
+ test('non-components and unknown ids have no kind', () => {
50
+ expect(getComponentProcess(ITEM_ORE_T1)).toBeUndefined()
51
+ expect(getComponentProcess(ITEM_ENGINE_T1)).toBeUndefined()
52
+ expect(getComponentProcess(ITEM_ROUSTABOUT_T1A_PACKED)).toBeUndefined()
53
+ expect(getComponentProcess(65535)).toBeUndefined()
54
+ })
55
+
56
+ test('resolveItem carries the kind for components only', () => {
57
+ expect(resolveItem(ITEM_BEAM).process).toBe('machined')
58
+ expect(resolveItem(ITEM_PLATE_T2).process).toBe('refined')
59
+ expect(resolveItem(ITEM_ORE_T1).process).toBeUndefined()
60
+ })
61
+ })
62
+
63
+ describe('completeComponentSet', () => {
64
+ test('recognises the hull First and Second step recipes', () => {
65
+ expect(completeComponentSet(inputsOf(ITEM_ROUSTABOUT_T1A_PACKED))).toEqual({
66
+ process: 'refined',
67
+ tier: 1,
68
+ quantity: 200,
69
+ })
70
+ expect(completeComponentSet(inputsOf(ITEM_PROSPECTOR_T1A_PACKED))).toEqual({
71
+ process: 'machined',
72
+ tier: 1,
73
+ quantity: 100,
74
+ })
75
+ expect(completeComponentSet(inputsOf(ITEM_PROSPECTOR_T2A_PACKED))).toEqual({
76
+ process: 'refined',
77
+ tier: 2,
78
+ quantity: 200,
79
+ })
80
+ expect(completeComponentSet(inputsOf(ITEM_PROSPECTOR_T2B_PACKED))).toEqual({
81
+ process: 'machined',
82
+ tier: 2,
83
+ quantity: 150,
84
+ })
85
+ })
86
+
87
+ test('a mixed module recipe is not a complete set', () => {
88
+ expect(completeComponentSet(inputsOf(ITEM_STORAGE_T1))).toBeNull()
89
+ })
90
+
91
+ test('unequal quantities keep the set but drop the shared quantity', () => {
92
+ const inputs = inputsOf(ITEM_ROUSTABOUT_T1A_PACKED).map((input, index) =>
93
+ index === 0 ? {...input, quantity: 50} : input
94
+ )
95
+ expect(completeComponentSet(inputs)).toEqual({process: 'refined', tier: 1, quantity: null})
96
+ })
97
+
98
+ test('one machined part among four refined is not a set', () => {
99
+ const inputs = inputsOf(ITEM_ROUSTABOUT_T1A_PACKED).map((input, index) =>
100
+ index === 0 ? {...input, itemId: ITEM_BEAM} : input
101
+ )
102
+ expect(completeComponentSet(inputs)).toBeNull()
103
+ })
104
+
105
+ test('a repeated family is not a set', () => {
106
+ const inputs = inputsOf(ITEM_ROUSTABOUT_T1A_PACKED).map((input) => ({
107
+ ...input,
108
+ itemId: ITEM_PLATE,
109
+ }))
110
+ expect(completeComponentSet(inputs)).toBeNull()
111
+ })
112
+
113
+ test('mixed tiers are not a set', () => {
114
+ const inputs = inputsOf(ITEM_ROUSTABOUT_T1A_PACKED).map((input, index) =>
115
+ index === 0 ? {...input, itemId: ITEM_PLATE_T2} : input
116
+ )
117
+ expect(completeComponentSet(inputs)).toBeNull()
118
+ })
119
+ })
@@ -0,0 +1,33 @@
1
+ import {getItem} from './catalog'
2
+ import {getItemFamily, type ComponentProcess} from './metadata'
3
+ import type {RecipeInput} from './recipes-runtime'
4
+
5
+ export const COMPONENT_PROCESS_ORDER: readonly ComponentProcess[] = ['refined', 'machined']
6
+
7
+ export function getComponentProcess(itemId: number): ComponentProcess | undefined {
8
+ return getItemFamily(itemId)?.process
9
+ }
10
+
11
+ export interface CompleteComponentSet {
12
+ process: ComponentProcess
13
+ tier: number
14
+ quantity: number | null
15
+ }
16
+
17
+ export function completeComponentSet(inputs: readonly RecipeInput[]): CompleteComponentSet | null {
18
+ const parts = inputs.filter((input) => getComponentProcess(input.itemId) !== undefined)
19
+ if (parts.length !== 5) return null
20
+ const process = getComponentProcess(parts[0].itemId)
21
+ const tier = getItem(parts[0].itemId).tier
22
+ const families = new Set<string>()
23
+ for (const part of parts) {
24
+ const item = getItem(part.itemId)
25
+ if (getComponentProcess(part.itemId) !== process || item.tier !== tier) return null
26
+ families.add(item.family)
27
+ }
28
+ if (!process || families.size !== 5) return null
29
+ const quantity = parts.every((part) => part.quantity === parts[0].quantity)
30
+ ? parts[0].quantity
31
+ : null
32
+ return {process, tier, quantity}
33
+ }
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "entityItemId": 10200,
4
4
  "slots": [],
5
- "baseHullmass": 1000
5
+ "baseHullmass": 19000
6
6
  },
7
7
  {
8
8
  "entityItemId": 10201,
@@ -310,7 +310,7 @@
310
310
  {
311
311
  "entityItemId": 11200,
312
312
  "slots": [],
313
- "baseHullmass": 1000
313
+ "baseHullmass": 31000
314
314
  },
315
315
  {
316
316
  "entityItemId": 11202,
@@ -468,5 +468,370 @@
468
468
  }
469
469
  ],
470
470
  "baseHullmass": 73600
471
+ },
472
+ {
473
+ "entityItemId": 11215,
474
+ "slots": [
475
+ {
476
+ "type": "generator",
477
+ "outputPct": 90,
478
+ "maxTier": 2
479
+ },
480
+ {
481
+ "type": "engine",
482
+ "outputPct": 90,
483
+ "maxTier": 2
484
+ },
485
+ {
486
+ "type": "loader",
487
+ "outputPct": 100,
488
+ "maxTier": 2
489
+ }
490
+ ],
491
+ "baseHullmass": 59200
492
+ },
493
+ {
494
+ "entityItemId": 11216,
495
+ "slots": [
496
+ {
497
+ "type": "generator",
498
+ "outputPct": 95,
499
+ "maxTier": 2
500
+ },
501
+ {
502
+ "type": "engine",
503
+ "outputPct": 95,
504
+ "maxTier": 2
505
+ },
506
+ {
507
+ "type": "aux",
508
+ "outputPct": 95,
509
+ "maxTier": 2
510
+ },
511
+ {
512
+ "type": "loader",
513
+ "outputPct": 100,
514
+ "maxTier": 2
515
+ }
516
+ ],
517
+ "baseHullmass": 73600
518
+ },
519
+ {
520
+ "entityItemId": 11217,
521
+ "slots": [
522
+ {
523
+ "type": "generator",
524
+ "outputPct": 90,
525
+ "maxTier": 2
526
+ },
527
+ {
528
+ "type": "engine",
529
+ "outputPct": 90,
530
+ "maxTier": 2
531
+ },
532
+ {
533
+ "type": "builder",
534
+ "outputPct": 100,
535
+ "maxTier": 2
536
+ }
537
+ ],
538
+ "baseHullmass": 59200
539
+ },
540
+ {
541
+ "entityItemId": 11218,
542
+ "slots": [
543
+ {
544
+ "type": "generator",
545
+ "outputPct": 95,
546
+ "maxTier": 2
547
+ },
548
+ {
549
+ "type": "engine",
550
+ "outputPct": 95,
551
+ "maxTier": 2
552
+ },
553
+ {
554
+ "type": "aux",
555
+ "outputPct": 95,
556
+ "maxTier": 2
557
+ },
558
+ {
559
+ "type": "builder",
560
+ "outputPct": 100,
561
+ "maxTier": 2
562
+ }
563
+ ],
564
+ "baseHullmass": 73600
565
+ },
566
+ {
567
+ "entityItemId": 11219,
568
+ "slots": [
569
+ {
570
+ "type": "generator",
571
+ "outputPct": 90,
572
+ "maxTier": 2
573
+ },
574
+ {
575
+ "type": "engine",
576
+ "outputPct": 90,
577
+ "maxTier": 2
578
+ },
579
+ {
580
+ "type": "hauler",
581
+ "outputPct": 100,
582
+ "maxTier": 2
583
+ }
584
+ ],
585
+ "baseHullmass": 59200
586
+ },
587
+ {
588
+ "entityItemId": 11220,
589
+ "slots": [
590
+ {
591
+ "type": "generator",
592
+ "outputPct": 95,
593
+ "maxTier": 2
594
+ },
595
+ {
596
+ "type": "engine",
597
+ "outputPct": 95,
598
+ "maxTier": 2
599
+ },
600
+ {
601
+ "type": "aux",
602
+ "outputPct": 95,
603
+ "maxTier": 2
604
+ },
605
+ {
606
+ "type": "hauler",
607
+ "outputPct": 100,
608
+ "maxTier": 2
609
+ }
610
+ ],
611
+ "baseHullmass": 73600
612
+ },
613
+ {
614
+ "entityItemId": 11221,
615
+ "slots": [
616
+ {
617
+ "type": "generator",
618
+ "outputPct": 90,
619
+ "maxTier": 2
620
+ },
621
+ {
622
+ "type": "engine",
623
+ "outputPct": 90,
624
+ "maxTier": 2
625
+ },
626
+ {
627
+ "type": "storage",
628
+ "outputPct": 100,
629
+ "maxTier": 2
630
+ }
631
+ ],
632
+ "baseHullmass": 59200
633
+ },
634
+ {
635
+ "entityItemId": 11222,
636
+ "slots": [
637
+ {
638
+ "type": "generator",
639
+ "outputPct": 95,
640
+ "maxTier": 2
641
+ },
642
+ {
643
+ "type": "engine",
644
+ "outputPct": 95,
645
+ "maxTier": 2
646
+ },
647
+ {
648
+ "type": "aux",
649
+ "outputPct": 95,
650
+ "maxTier": 2
651
+ },
652
+ {
653
+ "type": "storage",
654
+ "outputPct": 100,
655
+ "maxTier": 2
656
+ }
657
+ ],
658
+ "baseHullmass": 73600
659
+ },
660
+ {
661
+ "entityItemId": 11223,
662
+ "slots": [
663
+ {
664
+ "type": "generator",
665
+ "outputPct": 90,
666
+ "maxTier": 2
667
+ },
668
+ {
669
+ "type": "engine",
670
+ "outputPct": 90,
671
+ "maxTier": 2
672
+ },
673
+ {
674
+ "type": "crafter",
675
+ "outputPct": 100,
676
+ "maxTier": 2
677
+ }
678
+ ],
679
+ "baseHullmass": 59200
680
+ },
681
+ {
682
+ "entityItemId": 11224,
683
+ "slots": [
684
+ {
685
+ "type": "generator",
686
+ "outputPct": 95,
687
+ "maxTier": 2
688
+ },
689
+ {
690
+ "type": "engine",
691
+ "outputPct": 95,
692
+ "maxTier": 2
693
+ },
694
+ {
695
+ "type": "aux",
696
+ "outputPct": 95,
697
+ "maxTier": 2
698
+ },
699
+ {
700
+ "type": "crafter",
701
+ "outputPct": 100,
702
+ "maxTier": 2
703
+ }
704
+ ],
705
+ "baseHullmass": 73600
706
+ },
707
+ {
708
+ "entityItemId": 11225,
709
+ "slots": [
710
+ {
711
+ "type": "generator",
712
+ "outputPct": 95,
713
+ "maxTier": 2
714
+ },
715
+ {
716
+ "type": "engine",
717
+ "outputPct": 95,
718
+ "maxTier": 2
719
+ },
720
+ {
721
+ "type": "gatherer",
722
+ "outputPct": 100,
723
+ "maxTier": 2
724
+ },
725
+ {
726
+ "type": "hauler",
727
+ "outputPct": 100,
728
+ "maxTier": 2
729
+ }
730
+ ],
731
+ "baseHullmass": 73600
732
+ },
733
+ {
734
+ "entityItemId": 11226,
735
+ "slots": [
736
+ {
737
+ "type": "generator",
738
+ "outputPct": 95,
739
+ "maxTier": 2
740
+ },
741
+ {
742
+ "type": "engine",
743
+ "outputPct": 95,
744
+ "maxTier": 2
745
+ },
746
+ {
747
+ "type": "loader",
748
+ "outputPct": 100,
749
+ "maxTier": 2
750
+ },
751
+ {
752
+ "type": "storage",
753
+ "outputPct": 100,
754
+ "maxTier": 2
755
+ }
756
+ ],
757
+ "baseHullmass": 73600
758
+ },
759
+ {
760
+ "entityItemId": 11227,
761
+ "slots": [
762
+ {
763
+ "type": "generator",
764
+ "outputPct": 95,
765
+ "maxTier": 2
766
+ },
767
+ {
768
+ "type": "engine",
769
+ "outputPct": 95,
770
+ "maxTier": 2
771
+ },
772
+ {
773
+ "type": "loader",
774
+ "outputPct": 100,
775
+ "maxTier": 2
776
+ },
777
+ {
778
+ "type": "hauler",
779
+ "outputPct": 100,
780
+ "maxTier": 2
781
+ }
782
+ ],
783
+ "baseHullmass": 73600
784
+ },
785
+ {
786
+ "entityItemId": 11228,
787
+ "slots": [
788
+ {
789
+ "type": "generator",
790
+ "outputPct": 95,
791
+ "maxTier": 2
792
+ },
793
+ {
794
+ "type": "engine",
795
+ "outputPct": 95,
796
+ "maxTier": 2
797
+ },
798
+ {
799
+ "type": "crafter",
800
+ "outputPct": 100,
801
+ "maxTier": 2
802
+ },
803
+ {
804
+ "type": "storage",
805
+ "outputPct": 100,
806
+ "maxTier": 2
807
+ }
808
+ ],
809
+ "baseHullmass": 73600
810
+ },
811
+ {
812
+ "entityItemId": 11229,
813
+ "slots": [
814
+ {
815
+ "type": "generator",
816
+ "outputPct": 95,
817
+ "maxTier": 2
818
+ },
819
+ {
820
+ "type": "engine",
821
+ "outputPct": 95,
822
+ "maxTier": 2
823
+ },
824
+ {
825
+ "type": "builder",
826
+ "outputPct": 100,
827
+ "maxTier": 2
828
+ },
829
+ {
830
+ "type": "storage",
831
+ "outputPct": 100,
832
+ "maxTier": 2
833
+ }
834
+ ],
835
+ "baseHullmass": 73600
471
836
  }
472
837
  ]
@@ -115,3 +115,18 @@ export const ITEM_ASSEMBLY_YARD_T2_PACKED = 11209
115
115
  export const ITEM_PROSPECTOR_T2A_PACKED = 11212
116
116
  export const ITEM_PROSPECTOR_T2B_PACKED = 11213
117
117
  export const ITEM_DREDGER_T2A_PACKED = 11214
118
+ export const ITEM_TENDER_T2A_PACKED = 11215
119
+ export const ITEM_TENDER_T2B_PACKED = 11216
120
+ export const ITEM_WRIGHT_T2A_PACKED = 11217
121
+ export const ITEM_WRIGHT_T2B_PACKED = 11218
122
+ export const ITEM_TUG_T2A_PACKED = 11219
123
+ export const ITEM_TUG_T2B_PACKED = 11220
124
+ export const ITEM_PORTER_T2A_PACKED = 11221
125
+ export const ITEM_PORTER_T2B_PACKED = 11222
126
+ export const ITEM_SMITH_T2A_PACKED = 11223
127
+ export const ITEM_SMITH_T2B_PACKED = 11224
128
+ export const ITEM_TRAWLER_T2A_PACKED = 11225
129
+ export const ITEM_STEWARD_T2A_PACKED = 11226
130
+ export const ITEM_WRANGLER_T2A_PACKED = 11227
131
+ export const ITEM_ARTISAN_T2A_PACKED = 11228
132
+ export const ITEM_OUTFITTER_T2A_PACKED = 11229
@@ -759,5 +759,95 @@
759
759
  "mass": 57600,
760
760
  "type": "entity",
761
761
  "tier": 2
762
+ },
763
+ {
764
+ "id": 11215,
765
+ "mass": 43200,
766
+ "type": "entity",
767
+ "tier": 2
768
+ },
769
+ {
770
+ "id": 11216,
771
+ "mass": 57600,
772
+ "type": "entity",
773
+ "tier": 2
774
+ },
775
+ {
776
+ "id": 11217,
777
+ "mass": 43200,
778
+ "type": "entity",
779
+ "tier": 2
780
+ },
781
+ {
782
+ "id": 11218,
783
+ "mass": 57600,
784
+ "type": "entity",
785
+ "tier": 2
786
+ },
787
+ {
788
+ "id": 11219,
789
+ "mass": 43200,
790
+ "type": "entity",
791
+ "tier": 2
792
+ },
793
+ {
794
+ "id": 11220,
795
+ "mass": 57600,
796
+ "type": "entity",
797
+ "tier": 2
798
+ },
799
+ {
800
+ "id": 11221,
801
+ "mass": 43200,
802
+ "type": "entity",
803
+ "tier": 2
804
+ },
805
+ {
806
+ "id": 11222,
807
+ "mass": 57600,
808
+ "type": "entity",
809
+ "tier": 2
810
+ },
811
+ {
812
+ "id": 11223,
813
+ "mass": 43200,
814
+ "type": "entity",
815
+ "tier": 2
816
+ },
817
+ {
818
+ "id": 11224,
819
+ "mass": 57600,
820
+ "type": "entity",
821
+ "tier": 2
822
+ },
823
+ {
824
+ "id": 11225,
825
+ "mass": 57600,
826
+ "type": "entity",
827
+ "tier": 2
828
+ },
829
+ {
830
+ "id": 11226,
831
+ "mass": 57600,
832
+ "type": "entity",
833
+ "tier": 2
834
+ },
835
+ {
836
+ "id": 11227,
837
+ "mass": 57600,
838
+ "type": "entity",
839
+ "tier": 2
840
+ },
841
+ {
842
+ "id": 11228,
843
+ "mass": 57600,
844
+ "type": "entity",
845
+ "tier": 2
846
+ },
847
+ {
848
+ "id": 11229,
849
+ "mass": 57600,
850
+ "type": "entity",
851
+ "tier": 2
762
852
  }
763
853
  ]