@shipload/sdk 1.0.0-next.46 → 1.0.0-next.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/shipload.d.ts +30 -3
- package/lib/shipload.js +283 -219
- package/lib/shipload.js.map +1 -1
- package/lib/shipload.m.js +282 -220
- package/lib/shipload.m.js.map +1 -1
- package/lib/testing.d.ts +9 -0
- package/lib/testing.js +48 -18
- package/lib/testing.js.map +1 -1
- package/lib/testing.m.js +48 -18
- package/lib/testing.m.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities/modules.ts +9 -0
- package/src/contracts/server.ts +28 -1
- package/src/data/capabilities.ts +1 -1
- package/src/data/items.json +11 -11
- package/src/data/kind-registry.json +1 -1
- package/src/data/metadata.ts +12 -12
- package/src/data/recipes-runtime.ts +1 -0
- package/src/data/recipes.json +170 -180
- package/src/derivation/crafting.ts +14 -10
- package/src/derivation/index.ts +1 -0
- package/src/derivation/upgrades.ts +14 -0
- package/src/index-module.ts +2 -0
- package/src/managers/actions.ts +19 -0
- package/src/nft/description.ts +8 -4
- package/src/types.ts +3 -0
|
@@ -141,16 +141,20 @@ export function computeEntityStats(
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
return recipe.statSlots.map((slot) => {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
|
152
|
-
|
|
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
|
|
|
@@ -293,7 +297,7 @@ export function computeCraftedOutputStats(
|
|
|
293
297
|
out.push(0)
|
|
294
298
|
continue
|
|
295
299
|
}
|
|
296
|
-
if (slot.sources.length === 1
|
|
300
|
+
if (slot.sources.length === 1) {
|
|
297
301
|
const src = slot.sources[0]
|
|
298
302
|
const key = keyForRecipeInputStat(recipe, src.inputIndex, src.statIndex)
|
|
299
303
|
const input = recipe.inputs[src.inputIndex]
|
package/src/derivation/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import recipes from '../data/recipes.json'
|
|
2
|
+
import type {Recipe} from '../data/recipes-runtime'
|
|
3
|
+
|
|
4
|
+
const bySource = new Map<number, Recipe[]>()
|
|
5
|
+
for (const r of recipes as Recipe[]) {
|
|
6
|
+
if (r.sourceSubclass === undefined) continue
|
|
7
|
+
const list = bySource.get(r.sourceSubclass) ?? []
|
|
8
|
+
list.push(r)
|
|
9
|
+
bySource.set(r.sourceSubclass, list)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function eligibleUpgrades(entityItemId: number): Recipe[] {
|
|
13
|
+
return bySource.get(entityItemId) ?? []
|
|
14
|
+
}
|
package/src/index-module.ts
CHANGED
|
@@ -150,6 +150,8 @@ export type {ReserveTier, TierRange} from './derivation'
|
|
|
150
150
|
export {getEffectiveReserve} from './derivation'
|
|
151
151
|
export type {EffectiveReserveInput} from './derivation'
|
|
152
152
|
|
|
153
|
+
export {eligibleUpgrades} from './derivation'
|
|
154
|
+
|
|
153
155
|
export {getStatDefinitions, getStatName, resolveStats} from './derivation'
|
|
154
156
|
export type {StatDefinition, NamedStats} from './derivation'
|
|
155
157
|
|
package/src/managers/actions.ts
CHANGED
|
@@ -447,6 +447,25 @@ export class ActionsManager extends BaseManager {
|
|
|
447
447
|
})
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
+
upgrade(
|
|
451
|
+
builderId: UInt64Type,
|
|
452
|
+
targetId: UInt64Type,
|
|
453
|
+
targetItemId: UInt16Type,
|
|
454
|
+
inputs: ServerContract.ActionParams.Type.cargo_item[],
|
|
455
|
+
slot?: UInt8Type
|
|
456
|
+
): Action {
|
|
457
|
+
const params: ServerContract.ActionParams.upgrade = {
|
|
458
|
+
builder_id: UInt64.from(builderId),
|
|
459
|
+
target_id: UInt64.from(targetId),
|
|
460
|
+
target_item_id: UInt16.from(targetItemId),
|
|
461
|
+
inputs,
|
|
462
|
+
}
|
|
463
|
+
if (slot !== undefined) {
|
|
464
|
+
params.slot = UInt8.from(slot)
|
|
465
|
+
}
|
|
466
|
+
return this.server.action('upgrade', params)
|
|
467
|
+
}
|
|
468
|
+
|
|
450
469
|
claimplot(entityId: UInt64Type, targetItemId: UInt16Type, slot: ClusterSlotType): Action {
|
|
451
470
|
return this.server.action('claimplot', {
|
|
452
471
|
builder_id: UInt64.from(entityId),
|
package/src/nft/description.ts
CHANGED
|
@@ -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,
|
|
@@ -102,7 +104,7 @@ export const computeBatteryBankCapacity = (
|
|
|
102
104
|
export function entityDisplayName(itemId: number): string {
|
|
103
105
|
switch (itemId) {
|
|
104
106
|
case ITEM_SHIP_T1_PACKED:
|
|
105
|
-
return '
|
|
107
|
+
return 'Roustabout'
|
|
106
108
|
case ITEM_WAREHOUSE_T1_PACKED:
|
|
107
109
|
return 'Warehouse'
|
|
108
110
|
case ITEM_EXTRACTOR_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 '
|
|
132
|
+
return 'Power Core'
|
|
131
133
|
case ITEM_GATHERER_T1:
|
|
132
|
-
return 'Limpet Bay'
|
|
133
134
|
case ITEM_GATHERER_T2:
|
|
134
|
-
return '
|
|
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
|
}
|
package/src/types.ts
CHANGED
|
@@ -64,6 +64,8 @@ export enum TaskType {
|
|
|
64
64
|
DEMOLISH = 13,
|
|
65
65
|
CLAIMPLOT = 14,
|
|
66
66
|
BUILDPLOT = 15,
|
|
67
|
+
CHARGE = 16,
|
|
68
|
+
UPGRADE = 17,
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
export enum HoldKind {
|
|
@@ -71,6 +73,7 @@ export enum HoldKind {
|
|
|
71
73
|
PUSH = 2,
|
|
72
74
|
GATHER = 3,
|
|
73
75
|
BUILD = 4,
|
|
76
|
+
UPGRADE = 6,
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
export enum LocationType {
|