@shipload/sdk 1.0.0-next.46 → 1.0.0-next.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shipload/sdk",
3
3
  "description": "SDKs for Shipload",
4
- "version": "1.0.0-next.46",
4
+ "version": "1.0.0-next.47",
5
5
  "homepage": "https://github.com/shipload/toolkit/tree/master/packages/sdk",
6
6
  "repository": {
7
7
  "type": "git",
@@ -12,6 +12,8 @@ import {
12
12
  ITEM_STORAGE_T1,
13
13
  ITEM_WARP_T1,
14
14
  } from '../data/item-ids'
15
+ import {getItem} from '../data/catalog'
16
+ import type {EntitySlot} from '../data/recipes-runtime'
15
17
 
16
18
  export const MODULE_ANY = 0
17
19
  export const MODULE_ENGINE = 1
@@ -100,3 +102,10 @@ export function moduleSlotTypeToCode(slotType: string): number {
100
102
  return MODULE_ANY
101
103
  }
102
104
  }
105
+
106
+ export function slotAcceptsModule(slot: EntitySlot, moduleItemId: number): boolean {
107
+ const moduleType = getModuleCapabilityType(moduleItemId)
108
+ if (moduleType === 0xff) return false
109
+ if (!moduleAccepts(moduleSlotTypeToCode(slot.type), moduleType)) return false
110
+ return getItem(moduleItemId).tier <= slot.maxTier
111
+ }
@@ -43,7 +43,7 @@ export const capabilityAttributes: CapabilityAttribute[] = [
43
43
  {
44
44
  capability: 'Energy',
45
45
  attribute: 'capacity',
46
- description: 'Energy capacity from Reactors and installed Battery Bank modules',
46
+ description: 'Energy capacity from Power Cores and installed Battery Bank modules',
47
47
  },
48
48
  {capability: 'Energy', attribute: 'recharge', description: 'Energy regeneration rate'},
49
49
  {capability: 'Loading', attribute: 'mass', description: 'Weight of the loader unit itself'},
@@ -176,7 +176,7 @@ export const itemMetadata: Record<number, ItemMetadata> = {
176
176
  color: '#E86344',
177
177
  },
178
178
  10101: {
179
- name: 'Reactor',
179
+ name: 'Power Core',
180
180
  description: 'Basic energy system. Stores and recharges energy from resonant crystals.',
181
181
  color: '#4ADBFF',
182
182
  },
@@ -215,7 +215,7 @@ export const itemMetadata: Record<number, ItemMetadata> = {
215
215
  },
216
216
  10108: {
217
217
  name: 'Battery Bank',
218
- description: 'Stores additional charge produced by reactors.',
218
+ description: 'Stores additional charge produced by the power core.',
219
219
  color: '#4ADBFF',
220
220
  },
221
221
  10109: {
@@ -253,7 +253,7 @@ export const itemMetadata: Record<number, ItemMetadata> = {
253
253
  },
254
254
  10205: {
255
255
  name: 'Mass Driver',
256
- description: 'Planetary launch platform with generator and drive coil module slots.',
256
+ description: 'Planetary launch platform with power core and drive coil module slots.',
257
257
  color: '#E86344',
258
258
  },
259
259
  10206: {
@@ -329,7 +329,7 @@ export const itemMetadata: Record<number, ItemMetadata> = {
329
329
  },
330
330
 
331
331
  20106: {
332
- name: 'Tractor Beam (T2)',
332
+ name: 'Tractor Beam',
333
333
  description:
334
334
  'Advanced haul beam projector reinforced with tier 2 components for greater towing capacity.',
335
335
  color: '#4ADBFF',
@@ -344,7 +344,7 @@ export const itemMetadata: Record<number, ItemMetadata> = {
344
344
  20210: {
345
345
  name: 'Prospector',
346
346
  description:
347
- 'Advanced exploration vessel with tiered engine, generator, and gatherer slots.',
347
+ 'Advanced exploration vessel with tiered engine, power core, and limpet bay slots.',
348
348
  color: '#4AE898',
349
349
  },
350
350
  20211: {
@@ -356,16 +356,16 @@ export const itemMetadata: Record<number, ItemMetadata> = {
356
356
  }
357
357
 
358
358
  export const entityMetadata: Record<number, EntityMetadata> = {
359
- 10201: {moduleSlotLabels: ['Engine', 'Reactor', 'Limpet Bay', 'Shuttle Bay', 'Cargo Hold']},
359
+ 10201: {moduleSlotLabels: ['Engine', 'Power Core', 'Limpet Bay', 'Shuttle Bay', 'Cargo Hold']},
360
360
  10202: {
361
361
  moduleSlotLabels: ['Shuttle Bay', 'Cargo Hold', 'Cargo Hold', 'Cargo Hold', 'Cargo Hold'],
362
362
  },
363
- 10203: {moduleSlotLabels: ['Reactor', 'Limpet Bay']},
364
- 10204: {moduleSlotLabels: ['Reactor', 'Fabricator']},
365
- 10205: {moduleSlotLabels: ['Reactor', 'Drive Coil']},
363
+ 10203: {moduleSlotLabels: ['Power Core', 'Limpet Bay']},
364
+ 10204: {moduleSlotLabels: ['Power Core', 'Fabricator']},
365
+ 10205: {moduleSlotLabels: ['Power Core', 'Drive Coil']},
366
366
  10206: {moduleSlotLabels: ['Cargo Hold', 'Cargo Hold', 'Cargo Hold']},
367
- 20210: {moduleSlotLabels: ['Engine', 'Reactor', 'Limpet Bay', 'Limpet Bay', 'Flex Socket']},
368
- 20211: {moduleSlotLabels: ['Engine', 'Reactor', 'Tractor Beam', 'Tractor Beam']},
367
+ 20210: {moduleSlotLabels: ['Engine', 'Power Core', 'Limpet Bay', 'Limpet Bay', 'Flex Slot']},
368
+ 20211: {moduleSlotLabels: ['Engine', 'Power Core', 'Tractor Beam', 'Tractor Beam']},
369
369
  }
370
370
 
371
371
  for (const item of items as Array<{id: number}>) {
@@ -1672,6 +1672,10 @@
1672
1672
  {
1673
1673
  "inputIndex": 0,
1674
1674
  "statIndex": 0
1675
+ },
1676
+ {
1677
+ "inputIndex": 5,
1678
+ "statIndex": 0
1675
1679
  }
1676
1680
  ]
1677
1681
  },
@@ -1680,6 +1684,10 @@
1680
1684
  {
1681
1685
  "inputIndex": 0,
1682
1686
  "statIndex": 1
1687
+ },
1688
+ {
1689
+ "inputIndex": 5,
1690
+ "statIndex": 1
1683
1691
  }
1684
1692
  ]
1685
1693
  },
@@ -1727,6 +1735,10 @@
1727
1735
  {
1728
1736
  "inputIndex": 0,
1729
1737
  "statIndex": 0
1738
+ },
1739
+ {
1740
+ "inputIndex": 5,
1741
+ "statIndex": 0
1730
1742
  }
1731
1743
  ]
1732
1744
  },
@@ -1735,6 +1747,10 @@
1735
1747
  {
1736
1748
  "inputIndex": 0,
1737
1749
  "statIndex": 1
1750
+ },
1751
+ {
1752
+ "inputIndex": 5,
1753
+ "statIndex": 1
1738
1754
  }
1739
1755
  ]
1740
1756
  },
@@ -141,16 +141,20 @@ export function computeEntityStats(
141
141
  }
142
142
 
143
143
  return recipe.statSlots.map((slot) => {
144
- const src = slot.sources[0]
145
- const key = keyForStatSlot(recipe, slot)
146
- if (!src) return {key, value: 1}
147
- const input = recipe.inputs[src.inputIndex]
148
- if (!input) {
149
- return {key, value: 1}
144
+ const slotKey = keyForStatSlot(recipe, slot)
145
+ if (slot.sources.length === 0) return {key: slotKey, value: 1}
146
+ let weightedSum = 0
147
+ let totalWeight = 0
148
+ for (const src of slot.sources) {
149
+ const key = keyForRecipeInputStat(recipe, src.inputIndex, src.statIndex)
150
+ const input = recipe.inputs[src.inputIndex]
151
+ if (!input) continue
152
+ const weight = recipe.blendWeights?.[src.inputIndex] ?? 1
153
+ weightedSum += (blendedByComponent[input.itemId]?.[key] ?? 0) * weight
154
+ totalWeight += weight
150
155
  }
151
- const blended = blendedByComponent[input.itemId] ?? {}
152
- const value = blended[key] ?? 0
153
- return {key, value: Math.max(1, Math.min(999, value))}
156
+ const value = totalWeight > 0 ? Math.floor(weightedSum / totalWeight) : 0
157
+ return {key: slotKey, value: Math.max(1, Math.min(999, value))}
154
158
  })
155
159
  }
156
160
 
@@ -22,7 +22,9 @@ import {
22
22
  ITEM_GENERATOR_T1,
23
23
  ITEM_HAULER_SHIP_T2_PACKED,
24
24
  ITEM_HAULER_T1,
25
+ ITEM_HAULER_T2,
25
26
  ITEM_BATTERY_T1,
27
+ ITEM_LAUNCHER_T1,
26
28
  ITEM_LOADER_T1,
27
29
  ITEM_PROSPECTOR_T2_PACKED,
28
30
  ITEM_SHIP_T1_PACKED,
@@ -127,11 +129,10 @@ export function moduleDisplayName(itemId: number): string {
127
129
  case ITEM_ENGINE_T1:
128
130
  return 'Engine'
129
131
  case ITEM_GENERATOR_T1:
130
- return 'Reactor'
132
+ return 'Power Core'
131
133
  case ITEM_GATHERER_T1:
132
- return 'Limpet Bay'
133
134
  case ITEM_GATHERER_T2:
134
- return 'Gatherer (T2)'
135
+ return 'Limpet Bay'
135
136
  case ITEM_LOADER_T1:
136
137
  return 'Shuttle Bay'
137
138
  case ITEM_CRAFTER_T1:
@@ -139,11 +140,14 @@ export function moduleDisplayName(itemId: number): string {
139
140
  case ITEM_STORAGE_T1:
140
141
  return 'Cargo Hold'
141
142
  case ITEM_HAULER_T1:
143
+ case ITEM_HAULER_T2:
142
144
  return 'Tractor Beam'
143
145
  case ITEM_WARP_T1:
144
146
  return 'Warp Drive'
145
147
  case ITEM_BATTERY_T1:
146
148
  return 'Battery Bank'
149
+ case ITEM_LAUNCHER_T1:
150
+ return 'Drive Coil'
147
151
  default:
148
152
  return 'Module'
149
153
  }