@elite-dangerous-almanac/core 0.2.1 → 0.2.2
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/README.md +3 -2
- package/THIRD_PARTY_NOTICES.md +24 -2
- package/dist/astro/body-orbit.d.ts +174 -0
- package/dist/astro/body-orbit.js +1 -0
- package/dist/astro/body-orbit.js.map +1 -0
- package/dist/astro/body-physics.d.ts +228 -0
- package/dist/astro/body-physics.js +1 -0
- package/dist/astro/body-physics.js.map +1 -0
- package/dist/astro/body-rings.d.ts +223 -0
- package/dist/astro/body-rings.js +1 -0
- package/dist/astro/body-rings.js.map +1 -0
- package/dist/astro/codex-region-lookup.js +1 -1
- package/dist/astro/codex-region-lookup.js.map +1 -1
- package/dist/astro/index.d.ts +38 -1
- package/dist/astro/index.js +1 -1
- package/dist/astro/nebulae.d.ts +4 -4
- package/dist/astro/procedural-system.js +1 -1
- package/dist/astro/star-physics.d.ts +255 -0
- package/dist/astro/star-physics.js +1 -0
- package/dist/astro/star-physics.js.map +1 -0
- package/dist/body-scan-CEUYjCfH.d.ts +416 -0
- package/dist/{chunk-HUYYGTRM.js → chunk-3LZXB2MC.js} +1 -1
- package/dist/chunk-3RTUSDQF.js +1 -0
- package/dist/chunk-3RTUSDQF.js.map +1 -0
- package/dist/chunk-4OTQBHQL.js +1 -0
- package/dist/chunk-4OTQBHQL.js.map +1 -0
- package/dist/{chunk-MRTTQYT5.js → chunk-7EWZGDWY.js} +1 -1
- package/dist/{chunk-TBZJIQ5P.js → chunk-7TVFV3VO.js} +1 -1
- package/dist/chunk-7TVFV3VO.js.map +1 -0
- package/dist/chunk-7ZERP4TB.js +1 -0
- package/dist/{chunk-APEG4ZER.js.map → chunk-7ZERP4TB.js.map} +1 -1
- package/dist/chunk-B5VTFOK4.js +1 -0
- package/dist/chunk-B5VTFOK4.js.map +1 -0
- package/dist/chunk-DAQ3PJ4R.js +1 -0
- package/dist/chunk-DAQ3PJ4R.js.map +1 -0
- package/dist/chunk-GBTCWNO6.js +1 -0
- package/dist/chunk-GBTCWNO6.js.map +1 -0
- package/dist/chunk-NEXDA73Y.js +1 -0
- package/dist/chunk-NEXDA73Y.js.map +1 -0
- package/dist/chunk-P2MUFVJC.js +1 -0
- package/dist/chunk-P2MUFVJC.js.map +1 -0
- package/dist/{chunk-AAE4KZ2V.js → chunk-SS6XK336.js} +1 -1
- package/dist/{chunk-AAE4KZ2V.js.map → chunk-SS6XK336.js.map} +1 -1
- package/dist/chunk-TMXKC6JL.js +1 -0
- package/dist/chunk-TMXKC6JL.js.map +1 -0
- package/dist/chunk-ZZ376WHL.js +1 -0
- package/dist/chunk-ZZ376WHL.js.map +1 -0
- package/dist/commodities/commodities.d.ts +1 -1
- package/dist/equipment/index.js +1 -1
- package/dist/equipment/upgrade-costs.js +1 -1
- package/dist/equipment/upgrade-costs.js.map +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/materials/index.js +1 -1
- package/dist/materials/materials.d.ts +1 -1
- package/dist/materials/micro-resources-all.js +1 -1
- package/dist/materials/micro-resources.d.ts +1 -1
- package/dist/materials/micro-resources.js +1 -1
- package/dist/ships/build-metrics.d.ts +21 -232
- package/dist/ships/build-metrics.js +1 -1
- package/dist/ships/distributor.d.ts +1 -1
- package/dist/ships/heat.d.ts +1 -1
- package/dist/ships/index.d.ts +2 -2
- package/dist/ships/index.js +1 -1
- package/dist/ships/loadout-calculations.d.ts +2 -2
- package/dist/ships/mobility-capacitor.d.ts +1 -1
- package/dist/ships/modules-all.js +1 -1
- package/dist/ships/modules.d.ts +1 -1
- package/dist/ships/modules.js +1 -1
- package/dist/ships/pre-engineered-stats.d.ts +7 -5
- package/dist/ships/pre-engineered-stats.js +1 -1
- package/dist/ships/shield-capacitor.d.ts +1 -1
- package/dist/ships/shields.d.ts +1 -1
- package/dist/ships/ship-loadout.d.ts +71 -16
- package/dist/ships/ship-loadout.js +1 -1
- package/package.json +18 -3
- package/dist/chunk-6S36AVA4.js +0 -1
- package/dist/chunk-6S36AVA4.js.map +0 -1
- package/dist/chunk-APEG4ZER.js +0 -1
- package/dist/chunk-GVNTKCVF.js +0 -1
- package/dist/chunk-GVNTKCVF.js.map +0 -1
- package/dist/chunk-JET673E5.js +0 -1
- package/dist/chunk-JET673E5.js.map +0 -1
- package/dist/chunk-SG6YLUQ4.js +0 -1
- package/dist/chunk-SG6YLUQ4.js.map +0 -1
- package/dist/chunk-TBZJIQ5P.js.map +0 -1
- /package/dist/{chunk-HUYYGTRM.js.map → chunk-3LZXB2MC.js.map} +0 -0
- /package/dist/{chunk-MRTTQYT5.js.map → chunk-7EWZGDWY.js.map} +0 -0
|
@@ -166,7 +166,11 @@ type LoadoutSlot = BuildSlot & {
|
|
|
166
166
|
* `sourceSymbol` when the source named nothing there at all. A module whose source stated
|
|
167
167
|
* a recipe and no `Modifiers` reports `unresolvedEngineering` when neither a craftable
|
|
168
168
|
* recipe nor a catalogued article answers to what it named, because that module alone
|
|
169
|
-
* keeps the figures of an unengineered one.
|
|
169
|
+
* keeps the figures of an unengineered one. Two further entries report a *reading* the
|
|
170
|
+
* import chose rather than a change it made: `ambiguousEngineering` where an identity-only
|
|
171
|
+
* block was rolled while a catalogued article answers to it just as well, and
|
|
172
|
+
* `rerolledEngineering` where a stated modifier block moved nothing the module has and the
|
|
173
|
+
* recipe beside it was rolled in its place.
|
|
170
174
|
*
|
|
171
175
|
* @example
|
|
172
176
|
* ```ts
|
|
@@ -211,6 +215,43 @@ type LoadoutImportOutcome = {
|
|
|
211
215
|
readonly sourceSymbol: string;
|
|
212
216
|
/** Recipe the source named, in its own spelling. */
|
|
213
217
|
readonly blueprintSymbol: string;
|
|
218
|
+
} | {
|
|
219
|
+
/**
|
|
220
|
+
* The source stated a recipe and no `Modifiers`, and both readings of that
|
|
221
|
+
* identity are legitimate: the module's own engineering menu offers the recipe,
|
|
222
|
+
* *and* a catalogued fixed article carries the same blueprint at the same grade
|
|
223
|
+
* and effect. The roll was fitted, because that is what nearly every such block
|
|
224
|
+
* is; {@link preEngineeredVariant} is the article passed over.
|
|
225
|
+
*/
|
|
226
|
+
readonly action: 'ambiguousEngineering';
|
|
227
|
+
/** Exact slot spelling used by the imported build. */
|
|
228
|
+
readonly slot: string;
|
|
229
|
+
/** Module identity the recipe was stated for. */
|
|
230
|
+
readonly sourceSymbol: string;
|
|
231
|
+
/** Recipe the source named, in its own spelling. */
|
|
232
|
+
readonly blueprintSymbol: string;
|
|
233
|
+
/**
|
|
234
|
+
* The catalogued article the same block equally describes. Pass it to
|
|
235
|
+
* {@link ships!ShipLoadout.setPreEngineeredVariant |
|
|
236
|
+
* ShipLoadout.setPreEngineeredVariant} to take that reading instead.
|
|
237
|
+
*/
|
|
238
|
+
readonly preEngineeredVariant: PreEngineeredVariant;
|
|
239
|
+
} | {
|
|
240
|
+
/**
|
|
241
|
+
* The source stated `Modifiers` that move no stat this module has — an empty
|
|
242
|
+
* array, or labels the catalogues model nothing for — and identified no
|
|
243
|
+
* catalogued article, so the module would have published unengineered figures
|
|
244
|
+
* while reporting that it is engineered. The recipe stated beside them was
|
|
245
|
+
* rolled at the stated grade and quality in their place, and the source's own
|
|
246
|
+
* modifier block is gone from the build.
|
|
247
|
+
*/
|
|
248
|
+
readonly action: 'rerolledEngineering';
|
|
249
|
+
/** Exact slot spelling used by the imported build. */
|
|
250
|
+
readonly slot: string;
|
|
251
|
+
/** Module identity the recipe was stated for. */
|
|
252
|
+
readonly sourceSymbol: string;
|
|
253
|
+
/** Recipe the source named, in its own spelling. */
|
|
254
|
+
readonly blueprintSymbol: string;
|
|
214
255
|
};
|
|
215
256
|
|
|
216
257
|
/**
|
|
@@ -543,7 +584,7 @@ interface SlefExportOptions extends LoadoutExportOptions {
|
|
|
543
584
|
* const metrics = BuildMetrics.of(build);
|
|
544
585
|
* metrics.maxJumpRange(); // -> 60.5478 (ly, best single jump)
|
|
545
586
|
* metrics.powerBudget().withinBudget; // -> true
|
|
546
|
-
* metrics.
|
|
587
|
+
* metrics.shieldMetricsResult().value?.strength; // -> 743.12 (MJ)
|
|
547
588
|
* metrics.armourMetrics().hitPoints; // -> 307.8
|
|
548
589
|
* ```
|
|
549
590
|
*/
|
|
@@ -585,14 +626,23 @@ declare class ShipLoadout {
|
|
|
585
626
|
* the module would report that it is engineered while publishing the figures of one
|
|
586
627
|
* that is not. Where the module's own engineering menu offers the recipe, the block
|
|
587
628
|
* is read as an ordinary roll of it, even if a fixed article of that module carries
|
|
588
|
-
* the same blueprint at the same grade
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
629
|
+
* the same blueprint at the same grade — a reading {@link importOutcomes} reports as
|
|
630
|
+
* `ambiguousEngineering`, carrying the article passed over so
|
|
631
|
+
* {@link setPreEngineeredVariant} can take the other one. A Mercenary article is read
|
|
632
|
+
* as its own article at the grade it was bought at, and as that purchase climbed by
|
|
633
|
+
* its bespoke recipe above it. Where the menu does not offer the recipe, no ordinary
|
|
634
|
+
* roll could have written the block, so a single catalogued article answering to it
|
|
635
|
+
* is fitted. Where neither answers, the module keeps unengineered figures and
|
|
594
636
|
* {@link importOutcomes} reports the slot as `unresolvedEngineering`.
|
|
595
637
|
*
|
|
638
|
+
* **A stated modifier block that moves nothing is replaced by the roll.** A block
|
|
639
|
+
* naming only stats the module has no value for describes some other module, and
|
|
640
|
+
* preserving it would publish unengineered figures under an engineered block, so the
|
|
641
|
+
* recipe stated beside it is rolled instead and the slot is reported as
|
|
642
|
+
* `rerolledEngineering`. Every block that moves at least one stat this module carries
|
|
643
|
+
* stays exactly as the source wrote it: a capture's own figures are what the game
|
|
644
|
+
* reported, and outrank anything recomputed here.
|
|
645
|
+
*
|
|
596
646
|
* Modules are imported as one complete snapshot, so their order does not affect
|
|
597
647
|
* per-ship count allowances. An entry stands as the event stated it when the mount
|
|
598
648
|
* can hold the article the catalogue resolves, when its slot is a known cosmetic or
|
|
@@ -760,21 +810,26 @@ declare class ShipLoadout {
|
|
|
760
810
|
/**
|
|
761
811
|
* What the import made of this build: the changes it applied, in source order,
|
|
762
812
|
* followed by the fixed mounts stocked from the hull defaults because the source
|
|
763
|
-
* named none, in the defaults' own order, followed by
|
|
764
|
-
* engineering
|
|
813
|
+
* named none, in the defaults' own order, followed by what it made of each module's
|
|
814
|
+
* stated engineering.
|
|
765
815
|
*
|
|
766
816
|
* @returns A deeply frozen list. It is empty for builds created with
|
|
767
817
|
* {@link ShipLoadout.empty} or {@link ShipLoadout.default}, and for imports that
|
|
768
|
-
* needed no normalization and
|
|
818
|
+
* needed no normalization and read every stated recipe unambiguously.
|
|
769
819
|
* @remarks
|
|
770
820
|
* Each entry names the exact slot, and the source identity where the source gave one.
|
|
771
821
|
* `emptied` means an unknown module was removed from a removable mount; `defaulted`
|
|
772
822
|
* names the stock article fitted to armour, a core internal or the cargo hatch, with
|
|
773
823
|
* a `null` `sourceSymbol` when the source named nothing there at all.
|
|
774
|
-
* `
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
824
|
+
* `rerolledEngineering` names a module whose stated `Modifiers` moved no stat it
|
|
825
|
+
* carries, so the recipe beside them was rolled in their place.
|
|
826
|
+
*
|
|
827
|
+
* Two entries report no change to the fit at all. `unresolvedEngineering` means the
|
|
828
|
+
* source stated a recipe and no `Modifiers`, nothing the catalogues carry answers to
|
|
829
|
+
* it, and that module alone keeps the figures of an unengineered one.
|
|
830
|
+
* `ambiguousEngineering` means such a block had *two* answers — an ordinary roll and
|
|
831
|
+
* a catalogued fixed article — and carries the article that was passed over, ready
|
|
832
|
+
* for {@link setPreEngineeredVariant} (see {@link ShipLoadout.fromLoadout}).
|
|
778
833
|
*/
|
|
779
834
|
get importOutcomes(): readonly LoadoutImportOutcome[];
|
|
780
835
|
/**
|
|
@@ -796,7 +851,7 @@ declare class ShipLoadout {
|
|
|
796
851
|
* an error — it never leaves the pad, where the tank always is one — while a ship
|
|
797
852
|
* that only fails with the hold full is a warning, and leaves the build valid and
|
|
798
853
|
* complete: how much cargo to take is the pilot's call. Either way
|
|
799
|
-
* {@link ships!BuildMetrics.
|
|
854
|
+
* {@link ships!BuildMetrics.mobilityMetricsResult | BuildMetrics.mobilityMetricsResult} reports
|
|
800
855
|
* a speed of zero at the load in question.
|
|
801
856
|
*
|
|
802
857
|
* A capture may state a mass nobody can weigh — a negative `UnladenMass`, or an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{LoadoutEditError,ShipLoadout}from"../chunk-
|
|
1
|
+
export{LoadoutEditError,ShipLoadout}from"../chunk-B5VTFOK4.js"; //# sourceMappingURL=ship-loadout.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elite-dangerous-almanac/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Elite Dangerous static data and calculations: astronomy, ships and outfitting, personal equipment and engineering, materials, and market commodities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -53,6 +53,18 @@
|
|
|
53
53
|
"import": "./dist/astro/index.js"
|
|
54
54
|
},
|
|
55
55
|
"./astro/internal/*": null,
|
|
56
|
+
"./astro/body-orbit": {
|
|
57
|
+
"types": "./dist/astro/body-orbit.d.ts",
|
|
58
|
+
"import": "./dist/astro/body-orbit.js"
|
|
59
|
+
},
|
|
60
|
+
"./astro/body-physics": {
|
|
61
|
+
"types": "./dist/astro/body-physics.d.ts",
|
|
62
|
+
"import": "./dist/astro/body-physics.js"
|
|
63
|
+
},
|
|
64
|
+
"./astro/body-rings": {
|
|
65
|
+
"types": "./dist/astro/body-rings.d.ts",
|
|
66
|
+
"import": "./dist/astro/body-rings.js"
|
|
67
|
+
},
|
|
56
68
|
"./astro/codex-region-lookup": {
|
|
57
69
|
"types": "./dist/astro/codex-region-lookup.d.ts",
|
|
58
70
|
"import": "./dist/astro/codex-region-lookup.js"
|
|
@@ -117,6 +129,10 @@
|
|
|
117
129
|
"types": "./dist/astro/sector-name.d.ts",
|
|
118
130
|
"import": "./dist/astro/sector-name.js"
|
|
119
131
|
},
|
|
132
|
+
"./astro/star-physics": {
|
|
133
|
+
"types": "./dist/astro/star-physics.d.ts",
|
|
134
|
+
"import": "./dist/astro/star-physics.js"
|
|
135
|
+
},
|
|
120
136
|
"./astro/system-address-input": {
|
|
121
137
|
"types": "./dist/astro/system-address-input.d.ts",
|
|
122
138
|
"import": "./dist/astro/system-address-input.js"
|
|
@@ -470,7 +486,7 @@
|
|
|
470
486
|
"scripts": {
|
|
471
487
|
"audit": "pnpm audit --audit-level=low",
|
|
472
488
|
"build": "node scripts/copy-notices.mjs && node scripts/copy-assets.mjs && tsup && node scripts/prune-sourcemap-sources.mjs && node scripts/prune-barrel-imports.mjs && node scripts/attach-barrel-docs.mjs",
|
|
473
|
-
"check": "pnpm run check:fixtures && pnpm run check:i18n-coverage && pnpm run lint && pnpm run format:check && pnpm run typecheck && pnpm run check:examples && pnpm
|
|
489
|
+
"check": "pnpm run check:fixtures && pnpm run check:i18n-coverage && pnpm run lint && pnpm run format:check && pnpm run typecheck && pnpm run check:examples && pnpm test",
|
|
474
490
|
"check:fixtures": "node ../scripts/fixtures/generate-schema-and-types.mjs --check",
|
|
475
491
|
"check:i18n-coverage": "node scripts/i18n-coverage.mjs --check",
|
|
476
492
|
"format": "prettier --write . ../README.md ../CONTRIBUTING.md ../SECURITY.md ../schemas/**/*.{json,md} ../scripts/**/*.mjs ../.github/*.{md,yml} ../.github/workflows/*.yml ../.github/ISSUE_TEMPLATE/*.yml",
|
|
@@ -483,7 +499,6 @@
|
|
|
483
499
|
"typecheck": "tsc --noEmit",
|
|
484
500
|
"docs": "typedoc && node scripts/build-wiki-sidebar.mjs && node scripts/postprocess-wiki.mjs",
|
|
485
501
|
"check:examples": "node --test scripts/example-claims.test.mjs scripts/example-runtime.test.mjs && node scripts/check-examples.mjs",
|
|
486
|
-
"check:sizes": "pnpm run build && node scripts/check-sizes.mjs",
|
|
487
502
|
"test:package": "node --test package.test.mjs"
|
|
488
503
|
},
|
|
489
504
|
"devDependencies": {
|
package/dist/chunk-6S36AVA4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{weaponsCapacitorMetrics}from"./chunk-M4FZRDAH.js";import{shieldCapacitorMetrics}from"./chunk-XQJERZUS.js";import{cellBankSummary,shieldRecovery}from"./chunk-JMAXSXXQ.js";import{loadoutInternals,fittedThrusterParamsFor,preEngineeredVariantFor,powerConsumerFor,powerAvailable,heatInputResultFor,completeResult,cellBankInputsFor,armourInputFor,weaponStatsFor,weaponsCapacitorInputFor,mobilityInputResultFor,shieldInputResultFor,shieldCapacitorInputResultFor,shieldRecoveryInputResultFor,distributorInputResultFor,incompleteResult}from"./chunk-AAE4KZ2V.js";import{isNonOutfittingSlot,isBuiltInHullModule,orderBySlotLayout}from"./chunk-JET673E5.js";import{weaponMetrics,sumWeaponMetrics}from"./chunk-37JIMWLK.js";import{shieldMetrics}from"./chunk-5VWACBTN.js";import{powerBudget}from"./chunk-GGQMIQPC.js";import{frameShiftDriveMassFactor,singleJumpRange,fuelPerJump,totalRange}from"./chunk-VTMCSCXV.js";import{calculateUnladenMass}from"./chunk-DCB4COCL.js";import{mobilityCapacitorMetrics}from"./chunk-VEEBJFJ7.js";import{mobilityMetrics}from"./chunk-A4QKXXZD.js";import{distributorMetrics}from"./chunk-M2TCZKRT.js";import{getExperimentalEffectCost}from"./chunk-CJK2IBI2.js";import{heatMetrics}from"./chunk-6HA2YIKW.js";import{ammunitionCapacity}from"./chunk-AA3K5XUE.js";import{armourMetrics}from"./chunk-Q5ALV3DI.js";import{requirePips,requireFiniteNonNegative}from"./chunk-65FZECUX.js";import{getBlueprintCost}from"./chunk-MTJ4MS7W.js";import{sumMaterials}from"./chunk-CJQ37JII.js";import{deepFreeze}from"./chunk-DURKO7JU.js";var FACADE="BuildMetrics";function requireLoadOptions(scope,options){for(const field of["fuel","cargo"]){const value=options[field];if(value!==void 0)requireFiniteNonNegative(scope,field,value)}}var BuildMetrics=class _BuildMetrics{#build;#state;constructor(build,state){this.#build=build;this.#state=state}static of(build){return new _BuildMetrics(build,loadoutInternals(build,`${FACADE}.of: build`))}loadout(){return this.#build}frameShiftDrive(){const drive=this.#state.resolveDrive();if(drive===null){throw new TypeError(`${FACADE}: build has no frame shift drive`)}return drive}thrusters(){return fittedThrusterParamsFor(this.#state.modules(),this.#state.statsFor)}frameShiftDriveMassFactor(options={}){requireLoadOptions(`${FACADE}.frameShiftDriveMassFactor`,options);return frameShiftDriveMassFactor(this.#loadedMass(options.cargo??0),options.fuel??this.#build.fuelCapacity.main,this.frameShiftDrive())}maxJumpRange(){const fsd=this.frameShiftDrive();return singleJumpRange(this.#loadedMass(0),this.#maxJumpFuel(fsd),fsd)}jumpRange(options={}){requireLoadOptions(`${FACADE}.jumpRange`,options);return singleJumpRange(this.#loadedMass(options.cargo??0),options.fuel??this.#build.fuelCapacity.main,this.frameShiftDrive())}ladenJumpRange(){return this.jumpRange({cargo:this.#build.cargoCapacity})}fuelPerJump(distance,options={}){requireLoadOptions(`${FACADE}.fuelPerJump`,options);return fuelPerJump(distance,this.#loadedMass(options.cargo??0),options.fuel??this.#build.fuelCapacity.main,this.frameShiftDrive())}totalRange(options={}){requireLoadOptions(`${FACADE}.totalRange`,options);return totalRange(this.#loadedMass(options.cargo??0),options.fuel??this.#build.fuelCapacity.main,this.frameShiftDrive())}standardLoad(load){return this.#standardLoad("standardLoad",load).value}standardLoadResult(load){return this.#standardLoad("standardLoadResult",load)}jumpRangeSummary(){const maximum=this.#require(this.standardLoadResult("maximum"),"maximum load");const unladen=this.#require(this.standardLoadResult("unladen"),"unladen load");const laden=this.#require(this.standardLoadResult("laden"),"laden load");return{max:this.jumpRange(maximum),unladen:this.jumpRange(unladen),laden:this.jumpRange(laden),totalMax:this.totalRange(maximum),totalUnladen:this.totalRange(unladen),totalLaden:this.totalRange(laden)}}buildMass(options={}){requireLoadOptions(`${FACADE}.buildMass`,options);const unladen=this.#build.unladenMass;const fuel=options.fuel??this.#build.fuelCapacity.main;const cargo=options.cargo??0;return Object.freeze({hull:this.#state.ship.hullMass,modules:calculateUnladenMass(0,this.#state.calculationModules()),unladen:unladen,fuel:fuel,cargo:cargo,total:unladen+fuel+cargo})}buildCost(){const hull=this.#state.ship.hullCost;let modules=0;let mercCoins=0;const unpriced=[];const materials=[];for(const module of this.#state.modules()){const stats=this.#state.statsFor(module);if(stats?.cost!==void 0){modules+=stats.cost}else if(stats!==null||!isNonOutfittingSlot(module.Slot)&&!isBuiltInHullModule(module)){unpriced.push({slot:module.Slot,symbol:module.Item})}const variant=preEngineeredVariantFor(module);mercCoins+=variant?.mercCoinCost??0;const engineering=module.Engineering;if(!engineering)continue;const grade=engineering.Level;const bought=variant?.grade??0;if(Number.isInteger(grade)&&grade>bought&&grade<=5){const climb=getBlueprintCost(engineering.BlueprintName,grade,bought);if(climb){materials.push(climb.materials);mercCoins+=climb.mercCoins}}const experimental=engineering.ExperimentalEffect;if(experimental!==void 0&&experimental.toLowerCase()!==variant?.experimentalEffectSymbol?.toLowerCase()){const cost=getExperimentalEffectCost(experimental);if(cost)materials.push(cost)}}return deepFreeze({credits:{total:hull+modules,hull:hull,modules:modules,rebuy:Math.trunc((hull+modules)*.05),unpriced:unpriced},mercCoins:mercCoins,materials:sumMaterials(...materials)})}powerBudget(){const modules=this.#state.modules();const consumers=[];for(const module of modules){const consumer=powerConsumerFor(module,this.#state.statsFor(module));if(consumer)consumers.push(consumer)}return powerBudget(powerAvailable(modules,this.#state.statsFor),consumers)}heatMetrics(){return this.heatMetricsResult().value}heatMetricsResult(){const input=heatInputResultFor(this.#state.ship,this.#state.effectiveModules(),this.powerBudget(),this.#state.statsFor);return input.complete?completeResult(heatMetrics(input.value)):input}mobilityMetrics(options={}){return this.#mobility("mobilityMetrics",options).value}mobilityMetricsResult(options={}){return this.#mobility("mobilityMetricsResult",options)}mobilityCapacitorMetrics(options={}){return this.#mobilityCapacitor("mobilityCapacitorMetrics",options).value}mobilityCapacitorMetricsResult(options={}){return this.#mobilityCapacitor("mobilityCapacitorMetricsResult",options)}shieldMetrics(){return this.#shields().value}shieldMetricsResult(){return this.#shields()}shieldCapacitorMetrics(options={}){return this.#shieldCapacitor("shieldCapacitorMetrics",options).value}shieldCapacitorMetricsResult(options={}){return this.#shieldCapacitor("shieldCapacitorMetricsResult",options)}shieldRecovery(options={}){return this.#recovery("shieldRecovery",options).value}shieldRecoveryResult(options={}){return this.#recovery("shieldRecoveryResult",options)}cellBanks(){return cellBankSummary(orderBySlotLayout(cellBankInputsFor(this.#state.modules(),this.powerBudget(),this.#state.statsFor),this.#state.layout(),bank=>bank.slot))}armourMetrics(){return armourMetrics(armourInputFor(this.#state.ship,this.#state.modules(),this.#state.statsFor))}weaponMetrics(){const weapons=[];for(const module of this.#state.modules()){const record=this.#state.statsFor(module);const stats=weaponStatsFor(this.#state.effectiveModule(module),record);if(!stats)continue;weapons.push({slot:module.Slot,symbol:module.Item,name:record?.name??module.Item,enabled:module.On!==false,metrics:weaponMetrics(stats),ammunition:ammunitionCapacity(stats),...stats.maximumRange===void 0?{}:{maximumRange:stats.maximumRange},...stats.falloffRange===void 0?{}:{falloffRange:stats.falloffRange},...stats.projectileRange===void 0?{}:{projectileRange:{...stats.projectileRange}},...stats.armourPiercing===void 0?{}:{armourPiercing:stats.armourPiercing}})}const orderedWeapons=orderBySlotLayout(weapons,this.#state.layout(),weapon=>weapon.slot);return{weapons:orderedWeapons,total:sumWeaponMetrics(orderedWeapons.filter(weapon=>weapon.enabled).map(weapon=>weapon.metrics))}}weaponsCapacitorMetrics(options={}){const weaponsPips=requirePips(`${FACADE}.weaponsCapacitorMetrics`,"weaponsPips",options.weaponsPips??4);return weaponsCapacitorMetrics(weaponsCapacitorInputFor(this.#state.effectiveModules(),weaponsPips,this.powerBudget(),this.#state.statsFor))}distributorMetrics(options={}){return this.#distributor("distributorMetrics",options).value}distributorMetricsResult(options={}){return this.#distributor("distributorMetricsResult",options)}#mobility(method,options){const input=this.#mobilityInput(`${FACADE}.${method}`,options);return input.complete?completeResult(mobilityMetrics(input.value)):input}#mobilityCapacitor(method,options){const scope=`${FACADE}.${method}`;const enginesPips=requirePips(scope,"enginesPips",options.enginesPips??4);const input=this.#mobilityInput(scope,options);return input.complete?completeResult(mobilityCapacitorMetrics({...input.value,enginesPips:enginesPips})):input}#mobilityInput(scope,options){requireLoadOptions(scope,options);return mobilityInputResultFor(this.#state.ship,this.#state.modules(),()=>this.powerBudget(),()=>this.#loadedMass(options.cargo??0)+(options.fuel??this.#state.statedMainFuel()??this.#build.fuelCapacity.main),this.#state.statsFor)}#shields(){const input=shieldInputResultFor(this.#state.ship,this.#state.modules(),()=>this.powerBudget(),this.#state.statsFor);return input.complete?completeResult(shieldMetrics(input.value)):input}#shieldCapacitor(method,options){const systemsPips=requirePips(`${FACADE}.${method}`,"systemsPips",options.systemsPips??4);const input=shieldCapacitorInputResultFor(this.#state.ship,this.#state.modules(),()=>this.powerBudget(),systemsPips,this.#state.statsFor);return input.complete?completeResult(shieldCapacitorMetrics(input.value)):input}#recovery(method,options){const systemsPips=requirePips(`${FACADE}.${method}`,"systemsPips",options.systemsPips??4);const input=shieldRecoveryInputResultFor(this.#state.ship,this.#state.modules(),()=>this.powerBudget(),systemsPips,this.#state.statsFor);return input.complete?completeResult(shieldRecovery(input.value)):input}#distributor(method,options){const scope=`${FACADE}.${method}`;const pips={systemsPips:requirePips(scope,"systemsPips",options.systemsPips??4),enginesPips:requirePips(scope,"enginesPips",options.enginesPips??4),weaponsPips:requirePips(scope,"weaponsPips",options.weaponsPips??4)};const input=distributorInputResultFor(this.#state.effectiveModules(),pips,this.powerBudget(),this.#state.statsFor);return input.complete?completeResult(distributorMetrics(input.value)):input}#standardLoad(method,load){if(load!=="maximum"&&load!=="unladen"&&load!=="laden"){throw new RangeError(`${FACADE}.${method}: load must be 'maximum', 'unladen', or 'laden'`)}const fuel=this.#build.fuelCapacity;const cargo=load==="laden"?this.#build.cargoCapacity:0;const mass=load==="maximum"?this.#build.unladenMass:0;let drive=null;let maximumFuel=null;if(load==="maximum"){const fitted=this.#state.frameShiftDriveModule();let driveError=null;try{drive=this.#state.resolveDrive();maximumFuel=drive?.maxFuel??null}catch(error){if(!(error instanceof Error))throw error;driveError=error}if(maximumFuel===null){return incompleteResult([{field:"frameShiftDrive",reason:fitted?"unresolved":"missing",slot:fitted?.Slot??"FrameShiftDrive",...fitted?{symbol:fitted.Item}:{},message:driveError?.message??"FrameShiftDrive: no frame shift drive is fitted",params:fitted?{field:"frameShiftDrive",reason:"unresolved",slot:fitted.Slot,symbol:fitted.Item}:{field:"frameShiftDrive",reason:"missing",slot:"FrameShiftDrive"}}])}}const carriedFuel=load==="maximum"?Math.min(fuel.main,maximumFuel):fuel.main;const value=Object.freeze({fuel:carriedFuel,cargo:cargo,mass:this.#build.unladenMass+carriedFuel+cargo});if(load==="maximum"){try{this.jumpRange(value)}catch(error){if(!(error instanceof RangeError))throw error;const fitted=this.#state.frameShiftDriveModule();const field=drive!==null&&(!Number.isFinite(drive.maxFuel)||drive.maxFuel<0)?"frameShiftDrive":!Number.isFinite(value.fuel)||value.fuel<0?"fuelCapacity":!Number.isFinite(mass)||mass<0?"mass":"frameShiftDrive";const driveParams=field==="frameShiftDrive"&&fitted?{slot:fitted.Slot,symbol:fitted.Item}:{};return incompleteResult([{field:field,reason:"invalid",...driveParams,message:error.message,params:{field:field,reason:"invalid",...driveParams}}])}}return completeResult(value)}#require(result,what){if(result.value===null){throw new TypeError(`${FACADE}: cannot determine ${what} (${result.issues.map(issue=>issue.message).join("; ")})`)}return result.value}#loadedMass(cargo){return this.#build.unladenMass+cargo}#maxJumpFuel(fsd){return Math.min(this.#build.fuelCapacity.main,fsd.maxFuel)}};export{BuildMetrics};//# sourceMappingURL=chunk-6S36AVA4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ships/build-metrics.ts"],"names":["weaponsCapacitorMetrics","shieldCapacitorMetrics","cellBankSummary","shieldRecovery","loadoutInternals","fittedThrusterParamsFor","preEngineeredVariantFor","powerConsumerFor","powerAvailable","heatInputResultFor","completeResult","cellBankInputsFor","armourInputFor","weaponStatsFor","weaponsCapacitorInputFor","mobilityInputResultFor","shieldInputResultFor","shieldCapacitorInputResultFor","shieldRecoveryInputResultFor","distributorInputResultFor","incompleteResult","isNonOutfittingSlot","isBuiltInHullModule","orderBySlotLayout","weaponMetrics","sumWeaponMetrics","shieldMetrics","powerBudget","frameShiftDriveMassFactor","singleJumpRange","fuelPerJump","totalRange","calculateUnladenMass","mobilityCapacitorMetrics","mobilityMetrics","distributorMetrics","getExperimentalEffectCost","heatMetrics","ammunitionCapacity","armourMetrics","requirePips","requireFiniteNonNegative","getBlueprintCost","sumMaterials","deepFreeze","FACADE","requireLoadOptions","scope","options","field","value","BuildMetrics","_BuildMetrics","build","state","constructor","this","of","loadout","frameShiftDrive","drive","resolveDrive","TypeError","thrusters","modules","statsFor","loadedMass","cargo","fuel","fuelCapacity","main","maxJumpRange","fsd","maxJumpFuel","jumpRange","ladenJumpRange","cargoCapacity","distance","standardLoad","load","standardLoadResult","jumpRangeSummary","maximum","require","unladen","laden","max","totalMax","totalUnladen","totalLaden","buildMass","unladenMass","Object","freeze","hull","ship","hullMass","calculationModules","total","buildCost","hullCost","mercCoins","unpriced","materials","module","stats","cost","Slot","push","slot","symbol","Item","variant","mercCoinCost","engineering","Engineering","grade","Level","bought","Number","isInteger","climb","BlueprintName","experimental","ExperimentalEffect","toLowerCase","experimentalEffectSymbol","credits","rebuy","Math","trunc","consumers","consumer","heatMetricsResult","input","effectiveModules","complete","mobility","mobilityMetricsResult","mobilityCapacitor","mobilityCapacitorMetricsResult","shields","shieldMetricsResult","shieldCapacitor","shieldCapacitorMetricsResult","recovery","shieldRecoveryResult","cellBanks","layout","bank","weapons","record","effectiveModule","name","enabled","On","metrics","ammunition","maximumRange","falloffRange","projectileRange","armourPiercing","orderedWeapons","weapon","filter","map","weaponsPips","distributor","distributorMetricsResult","method","mobilityInput","enginesPips","statedMainFuel","systemsPips","pips","RangeError","mass","maximumFuel","fitted","frameShiftDriveModule","driveError","maxFuel","error","Error","reason","message","params","carriedFuel","min","isFinite","driveParams","result","what","issues","issue","join"],"mappings":"O,o/CAuHA,IAAM6C,OAAS,eAuQf,SAASC,mBAAmBC,MAAeC,SACvC,IAAA,MAAWC,QAAS,CAAC,OAAQ,SAAmB,CAC5C,MAAMC,MAAQF,QAAQC,OACtB,GAAIC,aAAU,EAAWT,yBAAyBM,MAAOE,MAAOC,MACpE,CACJ,CA4BO,IAAMC,aAAN,MAAMC,cACAC,OACAC,OAED,WAAAC,CAAYF,MAAoBC,OACpCE,MAAKH,MAASA,MACdG,MAAKF,MAASA,KAClB,CAqBA,SAAOG,CAAGJ,OACN,OAAO,IAAID,cAAaC,MAAOjD,iBAAiBiD,MAAO,GAAGR,oBAC9D,CASA,OAAAa,GACI,OAAOF,MAAKH,KAChB,CAUA,eAAAM,GACI,MAAMC,MAAQJ,MAAKF,MAAOO,eAC1B,GAAID,QAAU,KAAM,CAChB,MAAM,IAAIE,UAAU,GAAGjB,yCAC3B,CACA,OAAOe,KACX,CAgCA,SAAAG,GACI,OAAO1D,wBAAwBmD,MAAKF,MAAOU,UAAWR,MAAKF,MAAOW,SACtE,CAyBA,yBAAArC,CAA0BoB,QAAuB,CAAA,GAC7CF,mBAAmB,GAAGD,mCAAoCG,SAC1D,OAAOpB,0BACH4B,MAAKU,WAAYlB,QAAQmB,OAAS,GAClCnB,QAAQoB,MAAQZ,MAAKH,MAAOgB,aAAaC,KACzCd,KAAKG,kBAEb,CAWA,YAAAY,GACI,MAAMC,IAAMhB,KAAKG,kBACjB,OAAO9B,gBAAgB2B,MAAKU,WAAY,GAAIV,MAAKiB,YAAaD,KAAMA,IACxE,CAWA,SAAAE,CAAU1B,QAAuB,CAAA,GAC7BF,mBAAmB,GAAGD,mBAAoBG,SAC1C,OAAOnB,gBACH2B,MAAKU,WAAYlB,QAAQmB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P,YAAa,MAAMO,MAC1C,MAAMJ,OAAS1H,MAAKF,MAAO6H,wBAC3B,MAAMlI,MACFW,QAAU,QAAU2D,OAAOsE,SAASjI,MAAMyH,UAAYzH,MAAMyH,QAAU,GAChE,mBACC9D,OAAOsE,SAAS3I,MAAMkB,OAASlB,MAAMkB,KAAO,EAC3C,gBACCmD,OAAOsE,SAASb,OAASA,KAAO,EAC/B,OACA,kBACd,MAAMc,YACF7I,QAAU,mBAAqBiI,OACzB,CAAErE,KAAMqE,OAAOvE,KAAMG,OAAQoE,OAAOnE,MACpC,CAAA,EACV,OAAO3F,iBAAiB,CACpB,CACI6B,YACAuI,OAAQ,aACLM,YACHL,QAASH,MAAMG,QACfC,OAAQ,CAAEzI,YAAOuI,OAAQ,aAAcM,eAGnD,CACJ,CACA,OAAOpL,eAAewC,MAC1B,CAGA,QAAAiC,CAAY4G,OAA8BC,MACtC,GAAID,OAAO7I,QAAU,KAAM,CACvB,MAAM,IAAIY,UACN,GAAGjB,4BAA4BmJ,SAASD,OAAOE,OAAO5B,IAAK6B,OAAUA,MAAMT,SAASU,KAAK,SAEjG,CACA,OAAOJ,OAAO7I,KAClB,CAGA,WAAAgB,CAAYC,OACR,OAAOX,MAAKH,MAAOsC,YAAcxB,KACrC,CAGA,YAAAM,CAAaD,KACT,OAAOyD,KAAK2D,IAAIpI,MAAKH,MAAOgB,aAAaC,KAAME,IAAI6G,QACvD,UACJlI"}
|
package/dist/chunk-APEG4ZER.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CORE_MODULES}from"./chunk-FA5JVXVG.js";import{HARDPOINT_MODULES}from"./chunk-4TFAZX73.js";import{INTERNAL_MODULES}from"./chunk-4CBMQULR.js";import{UTILITY_MODULES}from"./chunk-ELT3FEA4.js";var ALL_MODULES=Object.freeze([...CORE_MODULES,...INTERNAL_MODULES,...HARDPOINT_MODULES,...UTILITY_MODULES]);export{ALL_MODULES};//# sourceMappingURL=chunk-APEG4ZER.js.map
|
package/dist/chunk-GVNTKCVF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ITEM_MICRO_RESOURCES}from"./chunk-WHWFKHV3.js";import{COMPONENT_MICRO_RESOURCES}from"./chunk-HTB52N6S.js";import{CONSUMABLE_MICRO_RESOURCES}from"./chunk-K7L7SMIR.js";import{DATA_MICRO_RESOURCES}from"./chunk-GVLDFJEY.js";var ALL_MICRO_RESOURCES=Object.freeze([...COMPONENT_MICRO_RESOURCES,...CONSUMABLE_MICRO_RESOURCES,...DATA_MICRO_RESOURCES,...ITEM_MICRO_RESOURCES]);export{ALL_MICRO_RESOURCES};//# sourceMappingURL=chunk-GVNTKCVF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/materials/micro-resources-all.ts"],"names":["ITEM_MICRO_RESOURCES","COMPONENT_MICRO_RESOURCES","CONSUMABLE_MICRO_RESOURCES","DATA_MICRO_RESOURCES","ALL_MICRO_RESOURCES","Object","freeze"],"mappings":"O,4NA6BO,IAAMI,oBAAgDC,OAAOC,OAAO,IACpEL,6BACAC,8BACAC,wBACAH,8BACNI"}
|
package/dist/chunk-JET673E5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{combinedRateOfFire}from"./chunk-37JIMWLK.js";import{getPreEngineeredVariants}from"./chunk-PL75RTA2.js";import{builtInModuleBySymbol,getModuleBySymbol}from"./chunk-HUYYGTRM.js";import{ALL_MODULES}from"./chunk-APEG4ZER.js";import{EXPERIMENTAL_EFFECTS,getExperimentalEffect}from"./chunk-77I24V6B.js";import{fieldForLabel,baseStats,computeModifiers,labelsForDamageType,scaleForLabel,preciseModifierValue,capabilityValueForLabel}from"./chunk-CJQ37JII.js";import{resolveBlueprintForModule}from"./chunk-OLKNYGGT.js";import{getBlueprintsForModule,getExperimentalsForModule,getEngineeringGroup}from"./chunk-GLWPSVFV.js";import{getBlueprintGrade,getBlueprint,BLUEPRINTS}from"./chunk-AYAKU4YA.js";import{normalizeKey}from"./chunk-BKWLI44T.js";import{requireStringIfPresent}from"./chunk-PKWVG2JY.js";import{deepFreeze}from"./chunk-DURKO7JU.js";function scaleDamageComponents(components,baseDamage,effectiveDamage){const scale=baseDamage!==void 0&&baseDamage!==0&&effectiveDamage!==void 0?effectiveDamage/baseDamage:1;return{...components.kinetic===void 0?{}:{kinetic:components.kinetic*scale},...components.thermal===void 0?{}:{thermal:components.thermal*scale},...components.explosive===void 0?{}:{explosive:components.explosive*scale},...components.absolute===void 0?{}:{absolute:components.absolute*scale},...components.antiXeno===void 0?{}:{antiXeno:components.antiXeno*scale},...components.unclassified===void 0?{}:{unclassified:components.unclassified.map(value=>value*scale)}}}function fixedModifierFeatures(modifiers){return modifiers.map(modifier=>({label:modifier.label,method:modifier.method,min:modifier.value,max:modifier.value}))}var FITTED_ITEM="ShipLoadout: fitted module Item";function isNonOutfittingSlot(slotKey){return/^(paintjob|shipname\d+|shipid\d+|bobble\d+|decal\d+|shipkit.+|weaponcolour|enginecolour|vesselvoice|shipcockpit|stringlights)$/i.test(slotKey)}function isCargoHatchSlot(slotKey){return slotKey.toLowerCase()==="cargohatch"}function isBuiltInHullModule(module){return isCargoHatchSlot(module.Slot)&&module.Item.toLowerCase().startsWith("modularcargobaydoor")}function cloneLoadoutModule(module){return{Slot:module.Slot,Item:module.Item,...module.On===void 0?{}:{On:module.On},...module.Priority===void 0?{}:{Priority:module.Priority},...module.Health===void 0?{}:{Health:module.Health},...module.Value===void 0?{}:{Value:module.Value},...module.Engineering===void 0?{}:{Engineering:{BlueprintName:module.Engineering.BlueprintName,Level:module.Engineering.Level,Quality:module.Engineering.Quality,...module.Engineering.ExperimentalEffect===void 0?{}:{ExperimentalEffect:module.Engineering.ExperimentalEffect},...module.Engineering.ExperimentalEffect_Localised===void 0?{}:{ExperimentalEffect_Localised:module.Engineering.ExperimentalEffect_Localised},...module.Engineering.Modifiers===void 0?{}:{Modifiers:module.Engineering.Modifiers.map(modifier=>({...modifier}))}}}}}function matchingKeyIn(keyed,slotKey){if(keyed.has(slotKey))return slotKey;const wanted=slotKey.toLowerCase();for(const key of keyed.keys()){if(key.toLowerCase()===wanted)return key}return null}function ownKeyIn(keyed,canonicalKey){return matchingKeyIn(keyed,canonicalKey)??(keyed.size>0&&[...keyed.keys()].every(key=>key===key.toLowerCase())?canonicalKey.toLowerCase():canonicalKey)}function orderBySlotLayout(values,layout,slotOf){const order=new Map(layout.map((slot,index)=>[slot.key.toLowerCase(),index]));return[...values].sort((left,right)=>(order.get(slotOf(left).toLowerCase())??Number.MAX_SAFE_INTEGER)-(order.get(slotOf(right).toLowerCase())??Number.MAX_SAFE_INTEGER))}function cloneModuleStats(module){try{return deepFreeze(structuredClone(module))}catch(error){if(!(error instanceof Error&&error.name==="DataCloneError"))throw error;return deepFreeze({...module,...module.restrictedToShips===void 0?{}:{restrictedToShips:[...module.restrictedToShips]},...module.limitIncrease===void 0?{}:{limitIncrease:{...module.limitIncrease}},...module.damageDistribution===void 0?{}:{damageDistribution:{...module.damageDistribution}},...module.damageComponents===void 0?{}:{damageComponents:{...module.damageComponents,...module.damageComponents.unclassified===void 0?{}:{unclassified:[...module.damageComponents.unclassified]}}},...module.projectileRange===void 0?{}:{projectileRange:{...module.projectileRange}}})}}var GUARDIAN_WEAPON_GROUPS=/* @__PURE__ */new Set(["guardianGauss","guardianPlasma","guardianShard"]);function missingBaseLabels(stats,base,features,experimental){const contributions=[...features,...experimental??[]];return[...new Set(contributions.map(contribution=>contribution.label).filter(label=>{if(base[label]!==void 0)return false;return fieldForLabel(label,stats)===null}))]}function recipeSignature(blueprintSymbol){const blueprint=getBlueprint(blueprintSymbol);if(!blueprint)return null;const grades=Object.entries(blueprint.grades).map(([grade,{features:features}])=>`${grade}:${features.map(feature=>`${feature.label}/${feature.method??""}`).sort().join(",")}`).sort().join(";");return`${blueprint.name.toLowerCase()}|${grades}`}var isGenericSpelling=blueprintSymbol=>blueprintSymbol.toLowerCase().startsWith("misc_");function isSoldWithBlueprint(item,wanted){return getPreEngineeredVariants(item).some(variant=>variant.acquisition==="mercenary"&&variant.blueprintSymbol.toLowerCase()===wanted)}function blueprintRoutesFor(item){const routes=/* @__PURE__ */new Map;for(const blueprintSymbol of getBlueprintsForModule(item))routes.set(blueprintSymbol,"ordinary");for(const variant of getPreEngineeredVariants(item)){if(variant.acquisition==="mercenary"&&!routes.has(variant.blueprintSymbol)){routes.set(variant.blueprintSymbol,"mercenary")}}return routes}function blueprintAvailableFor(item,blueprintSymbol){const offered=getBlueprintsForModule(item);const asWritten=normalizeKey(blueprintSymbol,"ShipLoadout.applyBlueprint: blueprintSymbol");const resolved=resolveBlueprintForModule(item,blueprintSymbol).trim();const wanted=resolved.toLowerCase();if(offered.some(id=>id.toLowerCase()===wanted))return true;if(isSoldWithBlueprint(item,wanted)||isSoldWithBlueprint(item,asWritten))return true;if(!isGenericSpelling(wanted))return false;const signature=recipeSignature(resolved);if(signature===null)return false;return offered.some(id=>recipeSignature(id)===signature&&!isGenericSpelling(id))}function experimentalAvailableFor(item,experimentalEffectSymbol){const wanted=normalizeKey(experimentalEffectSymbol,"ShipLoadout.applyBlueprint: options.experimentalEffectSymbol");return getExperimentalsForModule(item).some(id=>id.toLowerCase()===wanted)}function primitiveLabelFor(stats,label){if(label==="MaximumRange"&&stats.maximumRange!==void 0)return"Range";if(label==="DamageFalloffRange"&&stats.falloffRange!==void 0){return"FalloffRange"}if(label==="Range"&&stats.scannerRange!==void 0)return"ScannerRange";if(label==="DSS_PatchRadius")return"ProbeRadius";if(label==="FuelScoopRate")return"RefuelRate";if(label==="EnergyPerRegen"&&stats.shieldRegenRate!==void 0){return"DistributorDraw"}return label}function primitiveEngineeringInputsFor(stats,grade,experimental){const canonicalGrade={...grade,features:grade.features.map(feature=>{const label=primitiveLabelFor(stats,feature.label);return label===feature.label?feature:{...feature,label:label}})};if(!experimental)return{grade:canonicalGrade};return{grade:canonicalGrade,experimental:{...experimental,modifiers:experimental.modifiers.map(modifier=>{const label=primitiveLabelFor(stats,modifier.label);return label===modifier.label?modifier:{...modifier,label:label}})}}}function matchesCalculatedModifiers(captured,calculated){if(!captured||captured.length!==calculated.length)return false;const byLabel=new Map(captured.map(modifier=>[modifier.Label.trim().toLowerCase(),modifier]));if(byLabel.size!==captured.length)return false;return calculated.every(expected=>{const actual=byLabel.get(expected.Label.trim().toLowerCase());if(!actual)return false;if(expected.Value!==void 0){return actual.Value!==void 0&&Math.abs(actual.Value-expected.Value)<=1e-5*Math.max(1,Math.abs(expected.Value))}return actual.ValueStr===expected.ValueStr})}function unrollableFixedArticle(item,engineering){if(engineering.Modifiers!==void 0||typeof engineering.BlueprintName!=="string"){return null}const wanted=engineering.BlueprintName.trim().toLowerCase();const experimental=engineering.ExperimentalEffect?.trim().toLowerCase();const matches=getPreEngineeredVariants(item).filter(candidate=>candidate.blueprintSymbol.trim().toLowerCase()===wanted&&candidate.grade===engineering.Level&&(candidate.experimentalEffectSymbol===void 0?experimental===void 0&&engineering.ExperimentalEffect_Localised===void 0:candidate.experimentalEffectSymbol.trim().toLowerCase()===experimental)&&!blueprintAvailableFor(item,candidate.blueprintSymbol));return matches.length===1?matches[0]:null}function ordinaryEngineeringProof(item,engineering,experimental){const recipe=resolveBlueprintForModule(item,engineering.BlueprintName);const fixedCandidate=getPreEngineeredVariants(item).some(candidate=>candidate.acquisition!=="mercenary"&&candidate.blueprintSymbol.trim().toLowerCase()===recipe.trim().toLowerCase());if(!fixedCandidate)return"notFixedCandidate";const grade=getBlueprintGrade(recipe,engineering.Level);const quality=engineering.Quality;const stock=builtInModuleBySymbol(item,FITTED_ITEM);if(!stock||!grade||experimental===null||!Number.isFinite(quality)||quality<0||quality>1){return"unproven"}const current=primitiveEngineeringInputsFor(stock,grade,experimental);if(missingBaseLabels(stock,baseStats(stock),current.grade.features,current.experimental?.modifiers).length>0){return"unproven"}const calculated=journalModifiersFor(stock,computeModifiers(baseStats(stock),current.grade,quality,current.experimental));const damageDistribution=current.experimental?.damageDistribution??current.grade.damageDistribution;if(damageDistribution){for(const type of["kinetic","thermal","explosive","absolute"]){const value=damageDistribution[type];if(value===void 0)continue;const label=labelsForDamageType(type)[0];if(label===void 0)continue;calculated.push({Label:label,Value:value*scaleForLabel(label),OriginalValue:(stock.damageDistribution?.[type]??0)*scaleForLabel(label)})}}return matchesCalculatedModifiers(engineering.Modifiers,calculated)?"proven":"unproven"}var round6=value=>{const rounded=Math.round(value*1e6)/1e6;return Object.is(rounded,-0)?0:rounded};function float32FiringCycle(interval,burstRounds,burstRateOfFire){if(interval<=0)return void 0;const withinBurst=burstRounds>1?Math.fround(Math.fround(burstRounds-1)/Math.fround(burstRateOfFire)):0;const cycle=Math.fround(withinBurst+Math.fround(interval));return cycle>0?cycle:void 0}function float32RateOfFire(interval,burstRounds,burstRateOfFire){const cycle=float32FiringCycle(interval,burstRounds,burstRateOfFire);return cycle===void 0?void 0:Math.fround(Math.fround(burstRounds)/cycle)}function float32DamagePerSecond(damage,rounds,rate,burstRounds,cycle){if(cycle!==void 0&&(rounds!==1||burstRounds!==1)){const damagePerCycle=Math.fround(Math.fround(Math.fround(damage)*Math.fround(rounds))*Math.fround(burstRounds));return Math.fround(damagePerCycle/cycle)}return Math.fround(Math.fround(Math.fround(damage)*Math.fround(rounds))*Math.fround(rate))}var JOURNAL_MODIFIER_ORDER=["CargoCapacity","GuardianModuleResistance","Mass","Integrity","PowerDraw","BootTime","PowerCapacity","HeatEfficiency","FSDOptimalMass","MaxFuelPerJump","FSDHeatRate","EngineOptimalMass","EngineOptPerformance","EngineHeatRate","ShieldGenOptimalMass","ShieldGenStrength","DamagePerSecond","Damage","DistributorDraw","ThermalLoad","ArmourPenetration","MaximumRange","ShotSpeed","RateOfFire","DamageType","$Kinetic;","$Thermal;","$Explosive;","$Absolute;","AmmoClipSize","AmmoMaximum","ReloadTime","Jitter","DamageFalloffRange","DefenceModifierShieldMultiplier","DefenceModifierHealthMultiplier","DefenceModifierHealthAddition","DefenceModifierShieldAddition","RegenRate","BrokenRegenRate","EnergyPerRegen","KineticResistance","ThermicResistance","ExplosiveResistance","CausticResistance","DamageProtection","ModuleDefenceAbsorption","WeaponsCapacity","WeaponsRecharge","EnginesCapacity","EnginesRecharge","SystemsCapacity","SystemsRecharge","ShieldBankSpinUp","ShieldBankDuration","ShieldBankReinforcement","ShieldBankHeat","FSDInterdictorRange","FSDInterdictorFacingLimit","SensorTargetScanAngle","MaxAngle","ScannerTimeToScan","Range","DSS_PatchRadius","FuelScoopRate","FuelCapacity"];var JOURNAL_MODIFIER_RANK=new Map(JOURNAL_MODIFIER_ORDER.map((label,index)=>[label,index]));function sortJournalModifiers(modifiers){return modifiers.map((modifier,index)=>({modifier:modifier,index:index})).sort((a,b)=>(JOURNAL_MODIFIER_RANK.get(a.modifier.Label)??JOURNAL_MODIFIER_ORDER.length)-(JOURNAL_MODIFIER_RANK.get(b.modifier.Label)??JOURNAL_MODIFIER_ORDER.length)||a.index-b.index).map(({modifier:modifier})=>modifier)}function journalModifiersFor(stats,modifiers){const weapon=stats.damage!==void 0;const valueFor=(label,fallback)=>{const modifier=modifiers.find(candidate=>candidate.Label===label);return(modifier&&preciseModifierValue(modifier))??Math.fround(fallback)};const burstTouched=["BurstInterval","BurstSize","BurstRateOfFire"].some(label=>modifiers.some(modifier=>modifier.Label===label));const damageTouched=modifiers.some(modifier=>modifier.Label==="Damage");const rateTouched=burstTouched||modifiers.some(modifier=>modifier.Label==="RateOfFire");let damagePerSecond;let derivedRate;if(weapon&&(damageTouched||rateTouched)){const continuous=stats.burstInterval===void 0&&stats.rateOfFire===void 0;const baseDamage=Math.fround(stats.damage);const effectiveDamage=valueFor("Damage",stats.damage);if(continuous){damagePerSecond={Label:"DamagePerSecond",Value:round6(effectiveDamage),OriginalValue:round6(baseDamage)}}else{const burstRounds=valueFor("BurstSize",stats.burstRounds??1);const burstRate=valueFor("BurstRateOfFire",stats.burstRateOfFire??1);const baseBurstRounds=Math.fround(stats.burstRounds??1);const baseBurstRate=Math.fround(stats.burstRateOfFire??1);const baseInterval=stats.burstInterval===void 0?void 0:Math.fround(stats.burstInterval);const baseCycle=baseInterval===void 0?void 0:float32FiringCycle(baseInterval,baseBurstRounds,baseBurstRate);const baseRate=baseInterval!==void 0?float32RateOfFire(baseInterval,baseBurstRounds,baseBurstRate):stats.rateOfFire===void 0?void 0:Math.fround(stats.rateOfFire);const rateModifier=modifiers.find(modifier=>modifier.Label==="RateOfFire");const effectiveRate=rateModifier&&preciseModifierValue(rateModifier);const effectiveInterval=valueFor("BurstInterval",stats.burstInterval??0);const effectiveCycle=effectiveRate===void 0?float32FiringCycle(effectiveInterval,burstRounds,burstRate):void 0;const rate=effectiveRate??(effectiveCycle===void 0?void 0:Math.fround(Math.fround(burstRounds)/effectiveCycle));if(baseRate!==void 0&&rate!==void 0){const stockRounds=Math.fround(stats.roundsPerShot??1);const effectiveRounds=Math.fround(modifiers.find(modifier=>modifier.Label==="Rounds"||modifier.Label==="RoundsPerShot")?.Value??stockRounds);damagePerSecond={Label:"DamagePerSecond",Value:round6(float32DamagePerSecond(effectiveDamage,effectiveRounds,rate,burstRounds,effectiveCycle)),OriginalValue:round6(float32DamagePerSecond(baseDamage,stockRounds,baseRate,baseBurstRounds,baseCycle))};if(burstTouched){derivedRate={Label:"RateOfFire",Value:round6(rate),OriginalValue:round6(baseRate)}}}}}const result=[];for(const modifier of modifiers){const label=modifier.Label;if(weapon&&["BurstInterval","BurstSize","BurstRateOfFire"].includes(label))continue;if(weapon&&label==="Damage"&&stats.rateOfFire===void 0)continue;let journalLabel=label;if(label==="Range"&&stats.maximumRange!==void 0)journalLabel="MaximumRange";else if(label==="FalloffRange"&&stats.falloffRange!==void 0){journalLabel="DamageFalloffRange"}else if(label==="ScannerRange"&&stats.scannerRange!==void 0){journalLabel="Range"}else if(label==="ProbeRadius")journalLabel="DSS_PatchRadius";else if(label==="RefuelRate")journalLabel="FuelScoopRate";else if(label==="DistributorDraw"&&stats.shieldRegenRate!==void 0){journalLabel="EnergyPerRegen"}result.push(journalLabel===label?modifier:{...modifier,Label:journalLabel})}if(damagePerSecond)result.push(damagePerSecond);if(derivedRate){const direct=result.findIndex(modifier=>modifier.Label==="RateOfFire");if(direct>=0)result[direct]=derivedRate;else result.push(derivedRate)}return sortJournalModifiers(result)}function isFinalGuardianWeaponEngineering(item,blueprint){const group=getEngineeringGroup(item);if(group===null||!GUARDIAN_WEAPON_GROUPS.has(group))return false;const resolved=resolveBlueprintForModule(item,blueprint);return getBlueprint(resolved)!==null&&!blueprintAvailableFor(item,blueprint)}function engineerableBase(item,statsOverride){const stats=statsOverride??builtInModuleBySymbol(item,FITTED_ITEM);if(!stats||stats.engineeringLocked)return null;return{stats:stats,base:baseStats(stats)}}function availableBlueprintsFor(item,statsOverride){const engineerable=engineerableBase(item,statsOverride);if(!engineerable)return[];const{stats:stats,base:base}=engineerable;const available=[];for(const[blueprintSymbol,route]of blueprintRoutesFor(item)){const blueprint=BLUEPRINTS[blueprintSymbol];if(!blueprint)continue;const grades=Object.entries(blueprint.grades).filter(([,grade])=>missingBaseLabels(stats,base,grade.features).length===0).map(([grade])=>Number(grade)).filter(Number.isFinite).sort((a,b)=>a-b);if(grades.length>0)available.push({blueprintSymbol:blueprintSymbol,grades:grades,route:route})}return available}function availableExperimentalsFor(item,statsOverride){const engineerable=engineerableBase(item,statsOverride);if(!engineerable)return[];const{stats:stats,base:base}=engineerable;return getExperimentalsForModule(item).filter(experimentalEffectSymbol=>{const effect=EXPERIMENTAL_EFFECTS[experimentalEffectSymbol];return effect!==void 0&&missingBaseLabels(stats,base,effect.modifiers).length===0})}var MAX_ENGINEERING_GRADE=5;function modifiersWithExperimental(variant,experimental){const module=getModuleBySymbol(variant.symbol,ALL_MODULES);const effectName=experimental===void 0?variant.experimentalEffectSymbol:experimental;if(!module||!variant.modifiers?.length&&effectName==null)return null;const effect=effectName==null?void 0:getExperimentalEffect(effectName);if(effectName!==null&&effectName!==void 0&&!effect)return null;return computeModifiers(baseStats(module),fixedModifierFeatures(variant.modifiers??[]),1,effect??void 0)}function getPreEngineeredModifiers(variant){return modifiersWithExperimental(variant)??[]}function journalModifiersWithExperimental(variant,experimental){const module=getModuleBySymbol(variant.symbol,ALL_MODULES);if(!module)return[];const modifiers=journalModifiersFor(module,modifiersWithExperimental(variant,experimental)??[]);const effectName=experimental===void 0?variant.experimentalEffectSymbol:experimental;const damageDistribution=effectName?getExperimentalEffect(effectName)?.damageDistribution:void 0;if(!damageDistribution)return modifiers;for(const type of["kinetic","thermal","explosive","absolute"]){const value=damageDistribution[type];const label=labelsForDamageType(type)[0];if(value===void 0||label===void 0)continue;modifiers.push({Label:label,Value:value*scaleForLabel(label),OriginalValue:(module.damageDistribution?.[type]??0)*scaleForLabel(label)})}return modifiers}function getPreEngineeredJournalModifiers(variant){return journalModifiersWithExperimental(variant)}function sameJournalNumber(actual,expected){return Math.abs(actual-expected)<=Math.max(1e-5,Math.abs(expected)*1e-6)}function modifierKey(modifier,module){return fieldForLabel(modifier.Label,module)??`label:${normalizeKey(modifier.Label,"identifyPreEngineeredVariant: module.Engineering.Modifiers[].Label")}`}function sameModifier(actual,expected){if(expected.Value!==void 0){return actual.Value!==void 0&&sameJournalNumber(actual.Value,expected.Value)}return expected.ValueStr!==void 0&&actual.ValueStr!==void 0}function matchesModifierSignature(actualByKey,expected,module){let matched=0;for(const predicted of expected){const actual=actualByKey.get(modifierKey(predicted,module));if(!actual)continue;if(!sameModifier(actual,predicted))return false;matched++}return matched>=Math.max(1,expected.length-1)}function identifyPreEngineeredVariant(module){const engineering=module.Engineering;if(!engineering)return null;requireStringIfPresent(module.Item,"identifyPreEngineeredVariant: module.Item");const stock=getModuleBySymbol(module.Item,ALL_MODULES);if(!stock)return null;const capturedBlueprint=normalizeKey(engineering.BlueprintName,"identifyPreEngineeredVariant: module.Engineering.BlueprintName");const variants=getPreEngineeredVariants(module.Item);const blueprintMatches=variants.filter(candidate=>candidate.blueprintSymbol.toLowerCase()===capturedBlueprint);const blueprintMatch=blueprintMatches.length===1?blueprintMatches[0]:null;const capturedGrade=engineering.Level;if(blueprintMatch?.acquisition==="mercenary"&&Number.isInteger(capturedGrade)&&capturedGrade>=blueprintMatch.grade&&capturedGrade<=MAX_ENGINEERING_GRADE){return blueprintMatch}if(engineering.Modifiers===void 0){const capturedExperimental=normalizeKey(engineering.ExperimentalEffect,"identifyPreEngineeredVariant: module.Engineering.ExperimentalEffect");const identityMatches=blueprintMatches.filter(candidate=>candidate.engineeringLocked===true&&candidate.grade===capturedGrade&&(candidate.experimentalEffectSymbol===void 0?capturedExperimental===void 0&&engineering.ExperimentalEffect_Localised===void 0:candidate.experimentalEffectSymbol.toLowerCase()===capturedExperimental));return identityMatches.length===1?identityMatches[0]:null}if(!engineering.Modifiers?.length)return null;const actualByKey=/* @__PURE__ */new Map;for(const modifier of engineering.Modifiers){actualByKey.set(modifierKey(modifier,stock),modifier)}requireStringIfPresent(engineering.ExperimentalEffect,"identifyPreEngineeredVariant: module.Engineering.ExperimentalEffect");const matches=[];for(const candidate of variants){if(!candidate.modifiers?.length)continue;if(candidate.grade!==engineering.Level)continue;if(candidate.acquisition==="eventReward"&&(engineering.ExperimentalEffect!==void 0||engineering.ExperimentalEffect_Localised!==void 0||capturedBlueprint!==candidate.blueprintSymbol.toLowerCase())){continue}const primitive=modifiersWithExperimental(candidate,engineering.ExperimentalEffect??null);if(!primitive?.length)continue;const matched=matchesModifierSignature(actualByKey,primitive,stock)||matchesModifierSignature(actualByKey,journalModifiersWithExperimental(candidate,engineering.ExperimentalEffect??null),stock);if(matched)matches.push(candidate)}return matches.length===1?matches[0]:null}function unresolvedModifiers(variant){const resolved=new Set(getPreEngineeredModifiers(variant).map(modifier=>modifier.Label));return(variant.modifiers??[]).map(modifier=>modifier.label).filter(label=>!resolved.has(label))}function getPreEngineeredStats(variant){const module=getModuleBySymbol(variant.symbol,ALL_MODULES);if(!module)return null;if(!variant.modifiers?.length&&!variant.engineeringLocked&&variant.experimentalEffectSymbol===void 0)return{...module};const modifiers=variant.modifiers??[];const resolved={...module,...variant.engineeringLocked?{engineeringLocked:true}:{}};for(const{Label:Label,Value:Value,ValueStr:ValueStr}of getPreEngineeredModifiers(variant)){const field=fieldForLabel(Label,module);if(field&&field!=="damageDistribution"&&Value!==void 0){Object.assign(resolved,{[field]:Value/scaleForLabel(Label)})}else if(field&&ValueStr!==void 0&&capabilityValueForLabel(Label)!==null){Object.assign(resolved,{[field]:true})}}const experimentalDamageDistribution=variant.experimentalEffectSymbol?getExperimentalEffect(variant.experimentalEffectSymbol)?.damageDistribution:void 0;if(experimentalDamageDistribution){resolved.damageDistribution={...experimentalDamageDistribution};delete resolved.damageComponents}if(resolved.rateOfFire!==void 0&&!modifiers.some(m=>m.label==="RateOfFire")&&modifiers.some(m=>m.label==="BurstSize"||m.label==="BurstRateOfFire"||m.label==="BurstInterval")){const rate=combinedRateOfFire(resolved);if(rate!==void 0)resolved.rateOfFire=rate}if(module.damageComponents&&!experimentalDamageDistribution){resolved.damageComponents=scaleDamageComponents(module.damageComponents,module.damage,resolved.damage)}return resolved}export{FITTED_ITEM,availableBlueprintsFor,availableExperimentalsFor,blueprintAvailableFor,blueprintRoutesFor,cloneLoadoutModule,cloneModuleStats,experimentalAvailableFor,getPreEngineeredJournalModifiers,getPreEngineeredModifiers,getPreEngineeredStats,identifyPreEngineeredVariant,isBuiltInHullModule,isCargoHatchSlot,isFinalGuardianWeaponEngineering,isNonOutfittingSlot,journalModifiersFor,matchingKeyIn,missingBaseLabels,orderBySlotLayout,ordinaryEngineeringProof,ownKeyIn,primitiveEngineeringInputsFor,scaleDamageComponents,unresolvedModifiers,unrollableFixedArticle};//# sourceMappingURL=chunk-JET673E5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ships/internal/damage-components.ts","../src/ships/internal/fixed-modifier-features.ts","../src/ships/internal/loadout-state.ts","../src/ships/internal/loadout-engineering.ts","../src/ships/pre-engineered-stats.ts"],"names":["combinedRateOfFire","getPreEngineeredVariants","builtInModuleBySymbol","getModuleBySymbol","ALL_MODULES","EXPERIMENTAL_EFFECTS","getExperimentalEffect","fieldForLabel","baseStats","computeModifiers","labelsForDamageType","scaleForLabel","preciseModifierValue","capabilityValueForLabel","resolveBlueprintForModule","getBlueprintsForModule","getExperimentalsForModule","getEngineeringGroup","getBlueprintGrade","getBlueprint","BLUEPRINTS","normalizeKey","requireStringIfPresent","deepFreeze","scaleDamageComponents","components","baseDamage","effectiveDamage","scale","kinetic","thermal","explosive","absolute","antiXeno","unclassified","map","value","fixedModifierFeatures","modifiers","modifier","label","method","min","max","FITTED_ITEM","isNonOutfittingSlot","slotKey","test","isCargoHatchSlot","toLowerCase","isBuiltInHullModule","module","Slot","Item","startsWith","cloneLoadoutModule","On","Priority","Health","Value","Engineering","BlueprintName","Level","Quality","ExperimentalEffect","ExperimentalEffect_Localised","Modifiers","matchingKeyIn","keyed","has","wanted","key","keys","ownKeyIn","canonicalKey","size","every","orderBySlotLayout","values","layout","slotOf","order","Map","slot","index","sort","left","right","get","Number","MAX_SAFE_INTEGER","cloneModuleStats","structuredClone","error","Error","name","restrictedToShips","limitIncrease","damageDistribution","damageComponents","projectileRange","GUARDIAN_WEAPON_GROUPS","Set","missingBaseLabels","stats","base","features","experimental","contributions","contribution","filter","recipeSignature","blueprintSymbol","blueprint","grades","Object","entries","grade","feature","join","isGenericSpelling","isSoldWithBlueprint","item","some","variant","acquisition","blueprintRoutesFor","routes","set","blueprintAvailableFor","offered","asWritten","resolved","trim","id","signature","experimentalAvailableFor","experimentalEffectSymbol","primitiveLabelFor","maximumRange","falloffRange","scannerRange","shieldRegenRate","primitiveEngineeringInputsFor","canonicalGrade","matchesCalculatedModifiers","captured","calculated","length","byLabel","Label","expected","actual","Math","abs","ValueStr","unrollableFixedArticle","engineering","matches","candidate","ordinaryEngineeringProof","recipe","fixedCandidate","quality","stock","isFinite","current","journalModifiersFor","type","push","OriginalValue","round6","rounded","round","is","float32FiringCycle","interval","burstRounds","burstRateOfFire","withinBurst","fround","cycle","float32RateOfFire","float32DamagePerSecond","damage","rounds","rate","damagePerCycle","JOURNAL_MODIFIER_ORDER","JOURNAL_MODIFIER_RANK","sortJournalModifiers","a","b","weapon","valueFor","fallback","find","burstTouched","damageTouched","rateTouched","damagePerSecond","derivedRate","continuous","burstInterval","rateOfFire","burstRate","baseBurstRounds","baseBurstRate","baseInterval","baseCycle","baseRate","rateModifier","effectiveRate","effectiveInterval","effectiveCycle","stockRounds","roundsPerShot","effectiveRounds","result","includes","journalLabel","direct","findIndex","isFinalGuardianWeaponEngineering","group","engineerableBase","statsOverride","engineeringLocked","availableBlueprintsFor","engineerable","available","route","availableExperimentalsFor","effect","MAX_ENGINEERING_GRADE","modifiersWithExperimental","symbol","effectName","getPreEngineeredModifiers","journalModifiersWithExperimental","getPreEngineeredJournalModifiers","sameJournalNumber","modifierKey","sameModifier","matchesModifierSignature","actualByKey","matched","predicted","identifyPreEngineeredVariant","capturedBlueprint","variants","blueprintMatches","blueprintMatch","capturedGrade","isInteger","capturedExperimental","identityMatches","primitive","unresolvedModifiers","getPreEngineeredStats","field","assign","experimentalDamageDistribution","m"],"mappings":"O,g0BAWO,SAASwB,sBACZC,WACAC,WACAC,iBAEA,MAAMC,MACFF,kBAAe,GAAaA,aAAe,GAAKC,uBAAoB,EAC9DA,gBAAkBD,WAClB,EACV,MAAO,IACCD,WAAWI,eAAY,EAAY,CAAA,EAAK,CAAEA,QAASJ,WAAWI,QAAUD,UACxEH,WAAWK,eAAY,EAAY,CAAA,EAAK,CAAEA,QAASL,WAAWK,QAAUF,UACxEH,WAAWM,iBAAc,EAAY,CAAA,EAAK,CAAEA,UAAWN,WAAWM,UAAYH,UAC9EH,WAAWO,gBAAa,EAAY,CAAA,EAAK,CAAEA,SAAUP,WAAWO,SAAWJ,UAC3EH,WAAWQ,gBAAa,EAAY,CAAA,EAAK,CAAEA,SAAUR,WAAWQ,SAAWL,UAC3EH,WAAWS,oBAAiB,EAC1B,CAAA,EACA,CAAEA,aAAcT,WAAWS,aAAaC,IAAKC,OA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,CACA,OAAOpD,QACX,QAAAxF,YAAAwL,uBAAAI,0BAAAvG,sBAAAH,mBAAAvE,mBAAAoC,iBAAA6C,yBAAAwG,iCAAAF,0BAAAqB,sBAAAX,6BAAAtM,oBAAAF,iBAAA+K,iCAAAlL,oBAAA0H,oBAAApG,cAAAoC,kBAAA1B,kBAAAmF,yBAAAvF,SAAAsE,8BAAAvH,sBAAA0O,oBAAAtG"}
|
package/dist/chunk-SG6YLUQ4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{fixedSlotReason,validateLoadout}from"./chunk-OJC6AUL7.js";import{calculateModuleLimits}from"./chunk-KPETDYQX.js";import{publishLoadoutInternals,normalizeLoadoutEvent,preEngineeredVariantFor,moduleFitProblem,effectiveModule,moduleFitError}from"./chunk-AAE4KZ2V.js";import{parseSlef,toSlef,stringifySlef,getLoadoutModifier}from"./chunk-T4MKUKYS.js";import{getSourceModuleValue}from"./chunk-NIURLW2F.js";import{isNonOutfittingSlot,isBuiltInHullModule,cloneLoadoutModule,cloneModuleStats,availableBlueprintsFor,availableExperimentalsFor,ownKeyIn,FITTED_ITEM,blueprintAvailableFor,blueprintRoutesFor,experimentalAvailableFor,primitiveEngineeringInputsFor,missingBaseLabels,journalModifiersFor,getPreEngineeredStats,getPreEngineeredJournalModifiers,getPreEngineeredModifiers,ordinaryEngineeringProof,unresolvedModifiers,matchingKeyIn,isCargoHatchSlot,orderBySlotLayout}from"./chunk-JET673E5.js";import{getPreEngineeredVariants}from"./chunk-PL75RTA2.js";import{getShipBySymbol}from"./chunk-6UNAD74Z.js";import{builtInModuleBySymbol}from"./chunk-HUYYGTRM.js";import{ALL_MODULES}from"./chunk-APEG4ZER.js";import{singleJumpRange}from"./chunk-VTMCSCXV.js";import{calculateUnladenMass,calculateCargoCapacity,calculateFuelCapacity}from"./chunk-DCB4COCL.js";import{getDefaultLoadout}from"./chunk-GRIK3EDH.js";import{getExperimentalEffect}from"./chunk-77I24V6B.js";import{ammunitionCapacity}from"./chunk-AA3K5XUE.js";import{baseStats,computeModifiers,labelsForDamageType,scaleForLabel}from"./chunk-CJQ37JII.js";import{resolveBlueprintForModule}from"./chunk-OLKNYGGT.js";import{getExperimentalsForModule}from"./chunk-GLWPSVFV.js";import{getBlueprintGrade}from"./chunk-AYAKU4YA.js";import{loadoutSlotName}from"./chunk-KAA4VOOB.js";import{parseSlotName,enumerateSlots}from"./chunk-RAO35XDF.js";import{normalizeKey,CATALOGUE_KEY}from"./chunk-BKWLI44T.js";import{truncate,describeValue,requireString,requireStringIfPresent}from"./chunk-PKWVG2JY.js";import{deepFreeze}from"./chunk-DURKO7JU.js";var REBUY_FRACTION=.05;function exportLoadoutEvent(input,options){const fromSource=options.credits==="source";const source=fromSource?input.sourcePurchase:null;const totals=source!==null&&!input.sourceTotalsVoided&&sourceTotalsHold(input.modules,source)?source:null;const hullValue=fromSource?source?.hullValue??null:input.retailHullValue;const modulesValue=fromSource?totals?.modulesValue??null:computedModulesValue(input.modules,input.statsFor);const rebuy=fromSource?totals?.rebuy??null:hullValue===null||modulesValue===null?null:Math.trunc((hullValue+modulesValue)*REBUY_FRACTION);return{Ship:input.shipSymbol.toLowerCase(),...input.shipName===void 0?{}:{ShipName:input.shipName},...input.shipIdent===void 0?{}:{ShipIdent:input.shipIdent},...hullValue===null?{}:{HullValue:hullValue},...modulesValue===null?{}:{ModulesValue:modulesValue},UnladenMass:input.unladenMass,CargoCapacity:input.cargoCapacity,...input.maxJumpRange===null?{}:{MaxJumpRange:input.maxJumpRange},FuelCapacity:{Main:input.fuelCapacity.main,Reserve:input.fuelCapacity.reserve},...rebuy===null?{}:{Rebuy:rebuy},Modules:exportModules(input,options,fromSource)}}function exportModules(input,options,fromSource){const ordered=options.moduleOrder==="slots"?slotOrderedModules(input.modules,input.layout):[...input.modules.values()];return ordered.map(module=>{const on=module.On??(options.explicitPower?true:void 0);const priority=module.Priority??(options.explicitPower?0:void 0);const value=fromSource?sourceModuleValue(module,input.sourcePurchase):moduleValue(module,input.statsFor);return{Slot:module.Slot,Item:module.Item.toLowerCase(),...on===void 0?{}:{On:on},...priority===void 0?{}:{Priority:priority},...module.Health===void 0?{}:{Health:module.Health},...typeof value==="number"?{Value:value}:{},...module.Engineering===void 0?{}:{Engineering:cloneLoadoutModule(module).Engineering}}})}function slotOrderedModules(modules,layout){return orderBySlotLayout([...modules.values()],layout,module=>module.Slot)}function computedModulesValue(modules,statsFor){let sum=0;for(const module of modules.values()){const value=moduleValue(module,statsFor);if(value==="unknown")return null;if(value!=="free")sum+=value}return sum}function moduleValue(module,statsFor){const stats=statsFor(module);if(stats!==null)return stats.cost??"unknown";return isNonOutfittingSlot(module.Slot)||isBuiltInHullModule(module)?"free":"unknown"}var SOURCE_ITEM="ShipLoadout: sourcePurchase moduleValues[].item";function sourceModuleValue(module,source){const entry=source===null?null:getSourceModuleValue(source,module.Slot);if(entry===null)return"unknown";return normalizeKey(entry.item,SOURCE_ITEM)===normalizeKey(module.Item,FITTED_ITEM)?entry.value:"unknown"}function sourceTotalsHold(modules,source){for(const entry of source.moduleValues){const key=matchingKeyIn(modules,entry.slot);const fitted=key===null?void 0:modules.get(key);if(!fitted)return false;if(isCargoHatchSlot(entry.slot)&&entry.value===0)continue;if(normalizeKey(fitted.Item,FITTED_ITEM)!==normalizeKey(entry.item,SOURCE_ITEM)){return false}}return true}var SLOT_KEY="ShipLoadout: slotKey";var FITTED_SLOT="ShipLoadout: fitted module Slot";var LoadoutEditError=class extends TypeError{code;constraint;params;constructor(message,code,params,constraint){super(message);this.code=code;this.params=deepFreeze(structuredClone(params));if(constraint!==void 0)this.constraint=constraint}};var experimentalEffectUnsupported=(code,params)=>deepFreeze({kind:"unsupported",code:code,params:params});var engineeringNormalizationUnsupported=(code,params)=>deepFreeze({kind:"unsupported",code:code,params:params});function weighable(tonnes){return tonnes!==void 0&&Number.isFinite(tonnes)&&tonnes>=0?tonnes:void 0}var AGGREGATE_STATS=["mass","cargoCapacity","fuelCapacity"];var ShipLoadout=class _ShipLoadout{#ship;#shipSymbol;#modules;#moduleStats;#primitiveModifiers;#top;#sourcePurchase;#importOutcomes;#slotCache=/* @__PURE__ */new Map;#layoutCache;constructor(ship,shipSymbol,modules,top,sourcePurchase=null,moduleStats=/* @__PURE__ */new Map,primitiveModifiers=/* @__PURE__ */new Map,importOutcomes=deepFreeze([])){this.#ship=ship;this.#shipSymbol=shipSymbol;this.#modules=modules;this.#top=top;this.#sourcePurchase=sourcePurchase;this.#moduleStats=moduleStats;this.#primitiveModifiers=primitiveModifiers;this.#importOutcomes=importOutcomes;publishLoadoutInternals(this,{ship:ship,modules:()=>[...this.#modules.values()],effectiveModules:()=>this.#modulesForEffectiveStats(),effectiveModule:module=>this.#moduleForEffectiveStats(module),statsFor:module=>this.#statsFor(module),layout:()=>this.#layout(),resolveDrive:()=>this.#resolveDrive(),frameShiftDriveModule:()=>this.#frameShiftDrive()?.module,calculationModules:()=>this.#calculationModules(),statedMainFuel:()=>this.#top.FuelCapacity?.Main})}static fromSlef(input,index=0){const entries=parseSlef(input);const entry=entries[index];if(!entry){throw new TypeError(`ShipLoadout.fromSlef: no entry at index ${truncate(index)} (have ${entries.length})`)}const imported=normalizeLoadoutEvent(entry.data);const ship=getShipBySymbol(imported.shipSymbol);if(!ship){throw new TypeError(`ShipLoadout.fromSlef: unknown hull "${truncate(imported.shipSymbol)}"`)}return _ShipLoadout.#fromImported(imported,ship)}static fromLoadout(event){if(event===null||typeof event!=="object"){throw new TypeError(`ShipLoadout.fromLoadout: event must be a Loadout event, received ${describeValue(event)}`)}const imported=normalizeLoadoutEvent(event);const ship=getShipBySymbol(imported.shipSymbol);if(!ship){throw new TypeError(`ShipLoadout.fromLoadout: unknown hull "${truncate(imported.shipSymbol)}"`)}return _ShipLoadout.#fromImported(imported,ship)}static#fromImported(imported,ship){const outcomes=[...imported.outcomes];const loadout=new _ShipLoadout(ship,imported.shipSymbol,imported.modules,imported.top,imported.sourcePurchase,imported.moduleStats,imported.primitiveModifiers,outcomes);const{UnladenMass:UnladenMass,CargoCapacity:CargoCapacity,FuelCapacity:FuelCapacity}=imported.top;for(const module of[...imported.modules.values()]){const unresolved=loadout.#rollStatedRecipe(module);if(unresolved!==null)outcomes.push(unresolved)}if(UnladenMass!==void 0)loadout.#top.UnladenMass=UnladenMass;if(CargoCapacity!==void 0)loadout.#top.CargoCapacity=CargoCapacity;if(FuelCapacity!==void 0)loadout.#top.FuelCapacity=FuelCapacity;deepFreeze(outcomes);return loadout}#rollStatedRecipe(module){const engineering=module.Engineering;if(!engineering||engineering.Modifiers!==void 0||typeof engineering.BlueprintName!=="string"){return null}if(this.#moduleStats.has(module.Slot)){const variant=preEngineeredVariantFor(module);if(variant?.acquisition!=="mercenary"||engineering.Level<=variant.grade){return null}}try{this.applyBlueprint(module.Slot,engineering.BlueprintName,{grade:engineering.Level,quality:engineering.Quality??1,...typeof engineering.ExperimentalEffect==="string"?{experimentalEffectSymbol:engineering.ExperimentalEffect}:{}});return null}catch(error){if(!(error instanceof TypeError)&&!(error instanceof RangeError))throw error;return{action:"unresolvedEngineering",slot:module.Slot,sourceSymbol:module.Item,blueprintSymbol:engineering.BlueprintName}}}static empty(shipSymbol){const requested=requireString(shipSymbol,"ShipLoadout.empty: shipSymbol");const ship=getShipBySymbol(requested);if(!ship){throw new TypeError(`ShipLoadout.empty: no slot layout for hull "${truncate(shipSymbol)}"`)}const fitted=(getDefaultLoadout(ship.symbol)?.modules??[]).filter(module=>{const parsed=parseSlotName(module.slot);return parsed!==null&&fixedSlotReason(parsed)!==null});return new _ShipLoadout(ship,ship.symbol,new Map(fitted.map(module=>[module.slot,{Slot:module.slot,Item:module.symbol}])),{})}static default(shipSymbol){const requested=requireString(shipSymbol,"ShipLoadout.default: shipSymbol");const ship=getShipBySymbol(requested);if(!ship){throw new TypeError(`ShipLoadout.default: no default loadout for hull "${truncate(shipSymbol)}"`)}const loadout=getDefaultLoadout(ship.symbol);return new _ShipLoadout(ship,loadout.symbol,new Map(loadout.modules.map(module=>[module.slot,{Slot:module.slot,Item:module.symbol}])),{})}get shipSymbol(){return this.#shipSymbol}get shipName(){return this.#top.ShipName??null}get shipIdent(){return this.#top.ShipIdent??null}get unladenMass(){return this.#top.UnladenMass??this.#computedUnladenMass()}#computedUnladenMass(){return calculateUnladenMass(this.#ship.hullMass,this.#calculationModules())}get fuelCapacity(){const cap=this.#top.FuelCapacity;if(cap?.Main!==void 0&&cap.Reserve!==void 0){return Object.freeze({main:cap.Main,reserve:cap.Reserve})}const computed=this.#computedFuelCapacity();return Object.freeze({main:cap?.Main??computed.main,reserve:cap?.Reserve??computed.reserve})}get cargoCapacity(){return this.#top.CargoCapacity??this.#computedCargoCapacity()}#computedCargoCapacity(){return calculateCargoCapacity(this.#calculationModules())}#computedFuelCapacity(){return calculateFuelCapacity(this.#ship.reserveFuelCapacity,this.#calculationModules())}get hullValue(){return this.#top.HullValue??null}get modulesValue(){return this.#top.ModulesValue??null}get rebuy(){return this.#top.Rebuy??null}get sourcePurchase(){return this.#sourcePurchase}get importOutcomes(){return this.#importOutcomes}validation(){const slots=this.#layout();const byKey=new Map(slots.map(slot=>[normalizeKey(slot.key,CATALOGUE_KEY),slot]));const modules=[...this.#modules.values()].map(module=>{const stats=this.#statsFor(module);const slot=byKey.get(normalizeKey(module.Slot,FITTED_SLOT));const builtIn=stats===null&&isNonOutfittingSlot(module.Slot)||isBuiltInHullModule(module);const fitProblem=stats&&slot&&!builtIn?moduleFitProblem(this.#shipSymbol,slot,stats):null;const thrusterMaxMass=weighable(stats?.slot==="thrusters"?effectiveModule(this.#moduleForEffectiveStats(module),stats)?.maxMass:void 0);return{slot:module.Slot,symbol:module.Item,requiresKnownSlot:!builtIn,fitError:fitProblem?.message??null,...fitProblem===null?{}:{fitConstraint:fitProblem.constraint},...fitProblem?.params===void 0?{}:{fitParams:fitProblem.params},...stats?.exclusionGroup===void 0?{}:{exclusionGroup:stats.exclusionGroup},...stats?.limitGroup===void 0?{}:{limitGroup:stats.limitGroup},...stats?.limitIncrease===void 0?{}:{limitIncrease:stats.limitIncrease},...thrusterMaxMass===void 0?{}:{thrusterMaxMass:thrusterMaxMass}}});const dry=weighable(this.unladenMass);const fuel=weighable(this.fuelCapacity.main);const cargo=weighable(this.cargoCapacity);const mass=dry===void 0?void 0:{dry:dry,...fuel===void 0?{}:{fuel:fuel},...fuel===void 0||cargo===void 0?{}:{cargo:cargo}};return validateLoadout({shipSymbol:this.#shipSymbol,slots:slots,modules:modules,...mass===void 0?{}:{mass:mass}})}slots(kind){const cached=this.#slotCache.get(kind);if(cached!==void 0)return cached;const slots=kind===void 0?this.#layout():this.#layout().filter(slot=>slot.kind===kind);const currentLimits=this.#moduleLimits();const value=deepFreeze(slots.map(slot=>{const stats=this.#moduleStatsAt(slot.key);const fixedReason=fixedSlotReason(slot);const immovableReason=fixedReason!==null?fixedReason:stats?.limitIncrease!==void 0&&this.#moduleLimitRegression(slot.key,null,currentLimits,stats)!==null?"moduleLimit":null;return{...slot,name:loadoutSlotName(slot),module:this.fittedModuleAt(slot.key),removable:immovableReason===null,...immovableReason===null?{}:{immovableReason:immovableReason}}}));this.#slotCache.set(kind,value);return value}fittedModuleAt(slotKey){const module=this.#fittedModuleFor(slotKey);if(!module)return null;const raw=cloneLoadoutModule(module);const stats=this.#statsFor(module);const effective=effectiveModule(this.#moduleForEffectiveStats(module),stats);return deepFreeze({slot:module.Slot,symbol:raw.Item,on:raw.On,priority:raw.Priority,health:raw.Health,value:raw.Value,engineering:raw.Engineering,raw:raw,stats:stats===null?null:cloneModuleStats(stats),effectiveStats:effective===null?null:cloneModuleStats(effective),ammunition:ammunitionCapacity(effective),preEngineeredVariant:preEngineeredVariantFor(raw)})}fittedModules(){return deepFreeze([...this.#modules.keys()].flatMap(key=>{const fitted=this.fittedModuleAt(key);return fitted===null?[]:[fitted]}))}availableBlueprints(slotKey){const module=this.#fittedModuleFor(slotKey);return deepFreeze(module?availableBlueprintsFor(module.Item,this.#statsFor(module)):[])}availableExperimentalEffects(slotKey){const module=this.#fittedModuleFor(slotKey);return deepFreeze(module?availableExperimentalsFor(module.Item,this.#statsFor(module)):[])}modulesForSlot(slotKey){const slot=this.#requireSlot(slotKey);const occupied=new Set([...this.#modules.values()].flatMap(fitted=>{if(normalizeKey(fitted.Slot,FITTED_SLOT)===normalizeKey(slot.key,CATALOGUE_KEY))return[];const group=this.#statsFor(fitted)?.exclusionGroup;return group===void 0?[]:[group]}));const currentLimits=this.#moduleLimits();const currentStats=this.#moduleStatsAt(slot.key);return ALL_MODULES.filter(module=>module.grantOnly===void 0&&moduleFitError(this.#shipSymbol,slot,module)===null&&(module.exclusionGroup===void 0||!occupied.has(module.exclusionGroup))&&this.#moduleLimitRegression(slot.key,module,currentLimits,currentStats)===null)}repairFixedMount(slotKey){const requested=requireString(slotKey,SLOT_KEY);const wanted=normalizeKey(requested,SLOT_KEY);const slot=this.#requireSlot(requested);const fittedKey=this.#fittedKey(requested);const resultSlot=fittedKey??requested;const canonicalKey=slot.key;if(fixedSlotReason(slot)===null){return deepFreeze({status:"refused",slot:resultSlot,reason:"notFixedMount"})}const current=this.#fittedModuleFor(requested);const currentStats=current?this.#statsFor(current):null;const valid=current!==void 0&¤tStats!==null&&(slot.kind==="cargoHatch"?isBuiltInHullModule(current):moduleFitProblem(this.#shipSymbol,slot,currentStats)===null);if(valid){return deepFreeze({status:"unchanged",slot:current.Slot,symbol:current.Item})}const defaultModule=getDefaultLoadout(this.#shipSymbol)?.modules.find(module=>normalizeKey(module.slot,CATALOGUE_KEY)===wanted);if(!defaultModule){return deepFreeze({status:"defaultUnavailable",slot:resultSlot})}const ownKey=ownKeyIn(this.#modules,canonicalKey);const replacement={Slot:ownKey,Item:defaultModule.symbol,...current?.On===void 0?{}:{On:current.On},...current?.Priority===void 0?{}:{Priority:current.Priority},...current?.Health===void 0?{}:{Health:current.Health}};const replacementStats=builtInModuleBySymbol(defaultModule.symbol,"ShipLoadout.repairFixedMount")??(isBuiltInHullModule(replacement)?builtInModuleBySymbol("ModularCargoBayDoor","ShipLoadout.repairFixedMount"):null);if(!replacementStats){return deepFreeze({status:"defaultUnavailable",slot:resultSlot,symbol:defaultModule.symbol})}this.#replaceModule(ownKey,replacement,replacementStats);return deepFreeze({status:"repaired",slot:ownKey,symbol:defaultModule.symbol})}setModule(slotKey,module){const slot=this.#requireSlot(slotKey);if(module===null||module===void 0){throw new TypeError(`ShipLoadout.setModule: no module supplied for "${truncate(slotKey)}" (did the module lookup return undefined?)`)}if(typeof module.symbol!=="string"){throw new TypeError(`ShipLoadout.setModule: module for "${truncate(slotKey)}" must be an outfitting module, received ${describeValue(module)}`)}module=cloneModuleStats(module);const catalogued=builtInModuleBySymbol(module.symbol,FITTED_ITEM);if(catalogued===null){throw new TypeError(`ShipLoadout.setModule: no module is catalogued as "${truncate(module.symbol)}"`)}for(const field of AGGREGATE_STATS){const stated=module[field];if(stated===void 0){if(catalogued[field]===void 0)continue;throw new TypeError(`ShipLoadout.setModule: the supplied record for "${truncate(module.symbol)}" has no ${field}`)}if(typeof stated!=="number"||!Number.isFinite(stated)){throw new TypeError(`ShipLoadout.setModule: the supplied record for "${truncate(module.symbol)}" states a ${field} of ${describeValue(stated)}`)}}const problem=moduleFitProblem(this.#shipSymbol,slot,module);if(problem){if(problem.constraint==="immutableSlot"){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${problem.message}`,"immutableSlot",{slot:slot.key})}throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${problem.message}`,"incompatibleModule",{...problem.params,slot:slot.key,symbol:module.symbol,constraint:problem.constraint},problem.constraint)}if(module.exclusionGroup!==void 0){const conflict=[...this.#modules.values()].find(fitted=>normalizeKey(fitted.Slot,FITTED_SLOT)!==normalizeKey(slot.key,CATALOGUE_KEY)&&this.#statsFor(fitted)?.exclusionGroup===module.exclusionGroup);if(conflict){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${module.exclusionGroup} is limited to one per ship (already fitted in ${truncate(conflict.Slot)})`,"duplicateExclusiveModule",{exclusionGroup:module.exclusionGroup,slot:slot.key,symbol:module.symbol,previousSlot:conflict.Slot,previousSymbol:conflict.Item})}}const limitProblem=this.#moduleLimitRegression(slot.key,module);if(limitProblem!==null){throw new LoadoutEditError(`ShipLoadout.setModule: ${truncate(module.symbol)} → ${truncate(slotKey)}: ${limitProblem.group} would have ${limitProblem.count} modules but the ship allows ${limitProblem.limit}`,"moduleLimitExceeded",{group:limitProblem.group,count:limitProblem.count,limit:limitProblem.limit,slot:slot.key,symbol:module.symbol})}const key=this.#fittedKey(slotKey)??slot.key;this.#replaceModule(key,{Slot:key,Item:module.symbol},module);return this}removeModule(slotKey){const wanted=normalizeKey(slotKey,SLOT_KEY);if(wanted==="cargohatch"){throw new LoadoutEditError("ShipLoadout.removeModule: the cargoHatch slot cannot be changed","immutableSlot",{slot:"CargoHatch"})}const parsed=parseSlotName(slotKey);const slot=this.#layout().find(candidate=>normalizeKey(candidate.key,CATALOGUE_KEY)===wanted);if(parsed!==null&&fixedSlotReason(parsed)==="requiredSlot"){const fittedKey=this.#fittedKey(slotKey);const key2=slot?.key??fittedKey??slotKey;throw new LoadoutEditError(`ShipLoadout.removeModule: the ${truncate(key2)} slot is required and cannot be emptied`,"requiredSlot",{slot:key2})}const key=this.#fittedKey(slotKey);if(key!==null){const limitProblem=this.#moduleLimitRegression(key,null);if(limitProblem!==null){const fitted=this.#modules.get(key);throw new LoadoutEditError(`ShipLoadout.removeModule: ${truncate(slotKey)}: ${limitProblem.group} would have ${limitProblem.count} modules but the ship allows ${limitProblem.limit}`,"moduleLimitExceeded",{group:limitProblem.group,count:limitProblem.count,limit:limitProblem.limit,slot:key,...fitted===void 0?{}:{symbol:fitted.Item}})}this.#replaceModule(key,null)}return this}applyBlueprint(slotKey,blueprintSymbol,options){requireString(blueprintSymbol,"ShipLoadout.applyBlueprint: blueprintSymbol");if(options===null||typeof options!=="object"){throw new TypeError(`ShipLoadout.applyBlueprint: options must be an object with a grade, received ${describeValue(options)}`)}const wantedGrade=options.grade;const wantedQuality=options.quality;const wantedExperimental=options.experimentalEffectSymbol??void 0;requireStringIfPresent(wantedExperimental,"ShipLoadout.applyBlueprint: options.experimentalEffectSymbol");const module=this.#fittedModuleFor(slotKey);if(!module){throw new RangeError(`ShipLoadout.applyBlueprint: slot "${truncate(slotKey)}" is empty`)}const fittedStats=this.#statsFor(module);if(!fittedStats){throw new TypeError(`ShipLoadout.applyBlueprint: no stats for module "${truncate(module.Item)}"`)}const recipe=resolveBlueprintForModule(module.Item,blueprintSymbol);const named=recipe===blueprintSymbol?`"${truncate(blueprintSymbol)}"`:`"${truncate(blueprintSymbol)}" (${truncate(recipe)} on this module)`;const written=blueprintSymbol.trim().toLowerCase();const resolved=recipe.trim().toLowerCase();if(getPreEngineeredVariants(module.Item).some(variant=>variant.acquisition==="eventReward"&&(variant.blueprintSymbol.toLowerCase()===written||variant.blueprintSymbol.toLowerCase()===resolved))){throw new TypeError(`ShipLoadout.applyBlueprint: ${named} is a fixed pre-engineered identity, not a craftable blueprint; use setPreEngineeredVariant to fit its fixed article`)}if(!Number.isInteger(wantedGrade)||wantedGrade<1||wantedGrade>5){throw new RangeError(`ShipLoadout.applyBlueprint: no blueprint ${named} grade ${truncate(wantedGrade)}`)}const grade=getBlueprintGrade(recipe,wantedGrade);if(!grade){throw new RangeError(`ShipLoadout.applyBlueprint: no blueprint ${named} grade ${truncate(wantedGrade)}`)}let experimental;if(wantedExperimental!==void 0){experimental=getExperimentalEffect(wantedExperimental);if(!experimental){throw new RangeError(`ShipLoadout.applyBlueprint: unknown experimental effect "${truncate(wantedExperimental)}"`)}}const quality=wantedQuality??1;if(!Number.isFinite(quality)||quality<0||quality>1){throw new RangeError(`ShipLoadout.applyBlueprint: quality must be a finite number in [0, 1]`)}if(fittedStats.engineeringLocked){throw new TypeError(`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is a final pre-engineered article and accepts no further engineering`)}if(!blueprintAvailableFor(module.Item,blueprintSymbol)){const offered=[...blueprintRoutesFor(module.Item)].map(([blueprint,route])=>`${blueprint} (${route})`);throw new TypeError(offered.length>0?`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is not offered blueprint ${named}; available candidates are ${offered.join(", ")}`:`ShipLoadout.applyBlueprint: no registry lists an engineering menu for module "${truncate(module.Item)}"`)}if(wantedExperimental!==void 0&&!experimentalAvailableFor(module.Item,wantedExperimental)){const offered=getExperimentalsForModule(module.Item);throw new TypeError(`ShipLoadout.applyBlueprint: module "${truncate(module.Item)}" is not offered experimental effect "${truncate(wantedExperimental)}"; it takes ${offered.length>0?offered.join(", "):"no experimental effect"}`)}const stats=this.#engineeringBaseStats(module)??fittedStats;const base=baseStats(stats);const canonical=primitiveEngineeringInputsFor(stats,grade,experimental);const missing=missingBaseLabels(stats,base,canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){throw new TypeError(`ShipLoadout.applyBlueprint: cannot compute ${named} for module "${truncate(module.Item)}"; missing base stats for ${missing.join(", ")}`)}const damageDistribution=experimental?.damageDistribution??grade.damageDistribution;const primitiveModifiers=computeModifiers(base,canonical.grade,quality,canonical.experimental);const modifiers=journalModifiersFor(stats,primitiveModifiers);if(damageDistribution){for(const type of["kinetic","thermal","explosive","absolute"]){const value=damageDistribution[type];if(value===void 0)continue;const label=labelsForDamageType(type)[0];if(label===void 0)continue;const damageModifier={Label:label,Value:value*scaleForLabel(label),OriginalValue:(stats.damageDistribution?.[type]??0)*scaleForLabel(label)};modifiers.push(damageModifier);primitiveModifiers.push(damageModifier)}}const engineering={BlueprintName:blueprintSymbol,Level:wantedGrade,Quality:quality,...wantedExperimental!==void 0?{ExperimentalEffect:wantedExperimental}:{},Modifiers:modifiers};this.#replaceModule(module.Slot,{...module,Engineering:engineering},stats,primitiveModifiers);return this}setExperimentalEffect(slotKey,experimental){if(experimental!==null){requireString(experimental,"ShipLoadout.setExperimentalEffect: experimental")}const wanted=experimental;const module=this.#fittedModuleFor(slotKey);if(!module)return experimentalEffectUnsupported("emptySlot",{slot:slotKey});const stats=this.#statsFor(module);if(!stats){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const engineering=module.Engineering;if(!engineering){return experimentalEffectUnsupported("notEngineered",{slot:module.Slot,symbol:module.Item})}if(stats.engineeringLocked){return experimentalEffectUnsupported("finalArticle",{slot:module.Slot,symbol:module.Item})}const previous=engineering.ExperimentalEffect??null;if(previous===null&&wanted===null||previous!==null&&wanted!==null&&previous.trim().toLowerCase()===wanted.trim().toLowerCase()){return deepFreeze({kind:"unchanged",experimentalEffectSymbol:previous})}const variant=preEngineeredVariantFor(module);let effect;if(wanted!==null){effect=getExperimentalEffect(wanted);if(!effect){return experimentalEffectUnsupported("unknownExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:wanted})}const restoresBakedEffect=variant?.experimentalEffectSymbol!==void 0&&variant.experimentalEffectSymbol.trim().toLowerCase()===wanted.trim().toLowerCase();if(!experimentalAvailableFor(module.Item,wanted)&&!restoresBakedEffect){return experimentalEffectUnsupported("unsupportedExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:wanted})}}if(variant&&variant.acquisition!=="mercenary"){const stock=this.#engineeringBaseStats(module);if(!stock){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const missing=missingBaseLabels(stock,baseStats(stock),[],effect?.modifiers);if(missing.length>0){return experimentalEffectUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}const{experimentalEffectSymbol:originalEffect,...withoutEffect}=variant;const adjusted=wanted===null?withoutEffect:{...withoutEffect,experimentalEffectSymbol:wanted};const resolved=getPreEngineeredStats(withoutEffect);if(!resolved){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const replacement={BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:engineering.Quality,...wanted===null?{}:{ExperimentalEffect:wanted},Modifiers:getPreEngineeredJournalModifiers(adjusted)};this.#replaceModule(module.Slot,{...module,Engineering:replacement},cloneModuleStats(resolved),getPreEngineeredModifiers(adjusted))}else{const blueprint=engineering.BlueprintName;const grade=engineering.Level;const quality=engineering.Quality;if(typeof blueprint!=="string"||!Number.isInteger(grade)||grade<1||grade>5){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const currentEffect=previous===null?void 0:getExperimentalEffect(previous)??null;if(ordinaryEngineeringProof(module.Item,engineering,currentEffect)==="unproven"){return experimentalEffectUnsupported("unidentifiedPreEngineeredVariant",{slot:module.Slot,symbol:module.Item,blueprint:blueprint})}const recipe=resolveBlueprintForModule(module.Item,blueprint);const blueprintGrade=getBlueprintGrade(recipe,grade);if(!blueprintGrade||!blueprintAvailableFor(module.Item,blueprint)||!Number.isFinite(quality)||quality<0||quality>1){return experimentalEffectUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item,blueprint:blueprint,grade:grade})}const base=this.#engineeringBaseStats(module)??stats;const canonical=primitiveEngineeringInputsFor(base,blueprintGrade,effect);const missing=missingBaseLabels(base,baseStats(base),canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){return experimentalEffectUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}this.applyBlueprint(module.Slot,blueprint,{grade:grade,quality:quality,...wanted===null?{}:{experimentalEffectSymbol:wanted}})}return deepFreeze({kind:"updated",previousExperimentalEffectSymbol:previous,experimentalEffectSymbol:wanted})}completeEngineeringGrade(slotKey){const module=this.#fittedModuleFor(slotKey);if(!module)return engineeringNormalizationUnsupported("emptySlot",{slot:slotKey});const stats=this.#statsFor(module);if(!stats){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const engineering=module.Engineering;if(!engineering){return engineeringNormalizationUnsupported("notEngineered",{slot:module.Slot,symbol:module.Item})}if(stats.engineeringLocked){return engineeringNormalizationUnsupported("finalArticle",{slot:module.Slot,symbol:module.Item})}if(engineering.Quality===1&&engineering.Modifiers!==void 0){return deepFreeze({kind:"unchanged"})}const previousQuality=engineering.Quality;if(!Number.isFinite(previousQuality)||previousQuality<0||previousQuality>1){return engineeringNormalizationUnsupported("invalidQuality",{slot:module.Slot,symbol:module.Item})}const experimental=engineering.ExperimentalEffect??null;const effect=experimental===null?void 0:getExperimentalEffect(experimental)??void 0;if(experimental!==null&&!effect){return engineeringNormalizationUnsupported("unknownExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:experimental})}const blueprint=engineering.BlueprintName;const grade=engineering.Level;if(typeof blueprint!=="string"||!Number.isInteger(grade)||grade<1||grade>5){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const variant=preEngineeredVariantFor(module);const restoresBakedEffect=variant?.experimentalEffectSymbol!==void 0&&variant.experimentalEffectSymbol.trim().toLowerCase()===experimental?.trim().toLowerCase();if(experimental!==null&&!experimentalAvailableFor(module.Item,experimental)&&!restoresBakedEffect){return engineeringNormalizationUnsupported("unsupportedExperimentalEffect",{slot:module.Slot,symbol:module.Item,experimental:experimental})}if(variant&&variant.acquisition!=="mercenary"){const stock=this.#engineeringBaseStats(module);if(!stock){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const missing=missingBaseLabels(stock,baseStats(stock),[],effect?.modifiers);if(missing.length>0){return engineeringNormalizationUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}const{experimentalEffectSymbol:originalEffect,...withoutEffect}=variant;const adjusted=experimental===null?withoutEffect:{...withoutEffect,experimentalEffectSymbol:experimental};const resolved=getPreEngineeredStats(withoutEffect);if(!resolved){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item})}const replacement={BlueprintName:engineering.BlueprintName,Level:engineering.Level,Quality:1,...experimental===null?{}:{ExperimentalEffect:experimental},Modifiers:getPreEngineeredJournalModifiers(adjusted)};this.#replaceModule(module.Slot,{...module,Engineering:replacement},cloneModuleStats(resolved),getPreEngineeredModifiers(adjusted))}else{const proof=ordinaryEngineeringProof(module.Item,engineering,effect);if(proof==="unproven"||proof==="proven"&&!blueprintAvailableFor(module.Item,blueprint)){return engineeringNormalizationUnsupported("unidentifiedPreEngineeredVariant",{slot:module.Slot,symbol:module.Item,blueprint:blueprint})}const recipe=resolveBlueprintForModule(module.Item,blueprint);const blueprintGrade=getBlueprintGrade(recipe,grade);if(!blueprintGrade||!blueprintAvailableFor(module.Item,blueprint)){return engineeringNormalizationUnsupported("unsupportedEngineering",{slot:module.Slot,symbol:module.Item,blueprint:blueprint,grade:grade})}const base=this.#engineeringBaseStats(module)??stats;const canonical=primitiveEngineeringInputsFor(base,blueprintGrade,effect);const missing=missingBaseLabels(base,baseStats(base),canonical.grade.features,canonical.experimental?.modifiers);if(missing.length>0){return engineeringNormalizationUnsupported("unresolvedModifiers",{slot:module.Slot,symbol:module.Item,labels:missing})}this.applyBlueprint(module.Slot,blueprint,{grade:grade,quality:1,...experimental===null?{}:{experimentalEffectSymbol:experimental}})}return deepFreeze({kind:"normalized",previousQuality:previousQuality,quality:1})}setPreEngineeredVariant(slotKey,variant){if(variant===null||typeof variant!=="object"){throw new TypeError(`ShipLoadout.setPreEngineeredVariant: variant must be a pre-engineered variant, received ${describeValue(variant)}`)}requireString(variant.symbol,"ShipLoadout.setPreEngineeredVariant: variant.symbol");requireString(variant.blueprintSymbol,"ShipLoadout.setPreEngineeredVariant: variant.blueprintSymbol");requireString(variant.acquisition,"ShipLoadout.setPreEngineeredVariant: variant.acquisition");requireStringIfPresent(variant.experimentalEffectSymbol,"ShipLoadout.setPreEngineeredVariant: variant.experimentalEffectSymbol");const known=getPreEngineeredVariants(variant.symbol).find(candidate=>candidate.blueprintSymbol.toLowerCase()===variant.blueprintSymbol.toLowerCase()&&candidate.grade===variant.grade&&(candidate.experimentalEffectSymbol?.toLowerCase()??"")===(variant.experimentalEffectSymbol?.toLowerCase()??"")&&candidate.acquisition===variant.acquisition);if(!known){throw new RangeError(`ShipLoadout.setPreEngineeredVariant: no catalogued variant "${truncate(variant.blueprintSymbol)}" for module "${truncate(variant.symbol)}"`)}const stats=getPreEngineeredStats(known);const unresolved=unresolvedModifiers(known);if(unresolved.length>0){throw new TypeError(`ShipLoadout.setPreEngineeredVariant: cannot resolve "${truncate(variant.blueprintSymbol)}" for module "${truncate(variant.symbol)}"; missing base stats for ${unresolved.join(", ")}`)}this.setModule(slotKey,stats);const module=this.#fittedModuleFor(slotKey);const engineering={BlueprintName:known.blueprintSymbol,Level:known.grade,Quality:1,...known.experimentalEffectSymbol===void 0?{}:{ExperimentalEffect:known.experimentalEffectSymbol},...known.modifiers?.length?{Modifiers:getPreEngineeredJournalModifiers(known)}:{}};this.#replaceModule(module.Slot,{...module,Engineering:engineering},cloneModuleStats(stats),getPreEngineeredModifiers(known));return this}clearEngineering(slotKey){const module=this.#fittedModuleFor(slotKey);if(module&&this.#statsFor(module)?.engineeringLocked){throw new TypeError(`ShipLoadout.clearEngineering: module "${truncate(module.Item)}" is a final pre-engineered article and its engineering cannot be removed`)}if(module?.Engineering){const baseStats2=this.#engineeringBaseStats(module);const bare={Slot:module.Slot,Item:module.Item};if(module.On!==void 0)bare.On=module.On;if(module.Priority!==void 0){bare.Priority=module.Priority}if(module.Health!==void 0)bare.Health=module.Health;if(module.Value!==void 0)bare.Value=module.Value;this.#replaceModule(module.Slot,bare,baseStats2??void 0)}return this}setModuleEnabled(slotKey,on){this.#patchModule(slotKey,{On:on});return this}setModulePriority(slotKey,priority){if(!Number.isInteger(priority)||priority<0||priority>4){throw new RangeError(`ShipLoadout: power priority must be an integer 0-4, got ${truncate(priority)}`)}this.#patchModule(slotKey,{Priority:priority});return this}#patchModule(slotKey,patch){const module=this.#fittedModuleFor(slotKey);if(!module){throw new RangeError(`ShipLoadout: slot "${truncate(slotKey)}" is empty`)}this.#modules.set(module.Slot,cloneLoadoutModule({...module,...patch}));this.#slotCache.clear()}toLoadoutEvent(options={}){const unladenMass=this.#computedUnladenMass();const cargoCapacity=this.#computedCargoCapacity();const fuel=this.#computedFuelCapacity();const maxJumpRange=this.#exportableJumpRange(unladenMass);return exportLoadoutEvent({shipSymbol:this.#shipSymbol,...this.#top.ShipName===void 0?{}:{shipName:this.#top.ShipName},...this.#top.ShipIdent===void 0?{}:{shipIdent:this.#top.ShipIdent},modules:this.#modules,layout:this.#layout(),sourcePurchase:this.#sourcePurchase,retailHullValue:this.#ship.hullCost,unladenMass:unladenMass,cargoCapacity:cargoCapacity,fuelCapacity:fuel,maxJumpRange:maxJumpRange,sourceTotalsVoided:this.#importOutcomes.some(outcome=>outcome.sourceSymbol===null&&parseSlotName(outcome.slot)?.kind==="core"),statsFor:module=>this.#statsFor(module)},options)}toSlef(options){return toSlef(this.toLoadoutEvent(options),options.header)}toSlefString(options){return stringifySlef(this.toSlef(options),{indent:options.indent??0})}#exportableJumpRange(unladenMass){let drive;try{drive=this.#resolveDrive()}catch{return null}if(drive===null)return null;const tank=this.#computedFuelCapacity();return singleJumpRange(unladenMass,Math.min(tank.main,drive.maxFuel),drive)}#layout(){if(this.#layoutCache===void 0){this.#layoutCache=Object.freeze(enumerateSlots(this.#ship))}return this.#layoutCache}#requireSlot(slotKey){const wanted=normalizeKey(slotKey,SLOT_KEY);const slot=this.#layout().find(s=>normalizeKey(s.key,CATALOGUE_KEY)===wanted);if(!slot){throw new RangeError(`ShipLoadout: hull "${truncate(this.#shipSymbol)}" has no slot "${truncate(slotKey)}"`)}return slot}#fittedKey(slotKey){return matchingKeyIn(this.#modules,normalizeKey(slotKey,SLOT_KEY))}#fittedModuleFor(slotKey){const key=this.#fittedKey(slotKey);return key===null?void 0:this.#modules.get(key)}#calculationModules(){return[...this.#modules.values()].map(module=>({mass:this.#moduleMass(module),cargoCapacity:this.#moduleCapacity(module,"CargoCapacity","cargoCapacity"),fuelCapacity:this.#moduleCapacity(module,"FuelCapacity","fuelCapacity")}))}#moduleLimits(){const entries=[...this.#modules.values()].flatMap(module=>{const stats=this.#statsFor(module);return stats===null?[]:[stats]});return calculateModuleLimits(entries)}#moduleStatsAt(slotKey){const fitted=this.#fittedModuleFor(slotKey);return fitted===void 0?null:this.#statsFor(fitted)}#engineeringBaseStats(module){const fitted=this.#statsFor(module);if(!module.Engineering||preEngineeredVariantFor(module)===null)return fitted;const stock=builtInModuleBySymbol(module.Item,FITTED_ITEM);if(!stock)return fitted;return fitted?.engineeringLocked?cloneModuleStats({...stock,engineeringLocked:true}):stock}#moduleForEffectiveStats(module){const modifiers=this.#primitiveModifiers.get(module.Slot);if(modifiers===void 0||module.Engineering===void 0)return module;return{...module,Engineering:{...module.Engineering,Modifiers:modifiers}}}#modulesForEffectiveStats(){return[...this.#modules.values()].map(module=>this.#moduleForEffectiveStats(module))}#moduleLimitRegression(slotKey,replacement,current=this.#moduleLimits(),previous=this.#moduleStatsAt(slotKey)){if(previous?.limitGroup===void 0&&previous?.limitIncrease===void 0&&replacement?.limitGroup===void 0&&replacement?.limitIncrease===void 0){return null}for(const usage of current){const count=usage.count-Number(previous?.limitGroup===usage.group)+Number(replacement?.limitGroup===usage.group);const increase=usage.increase-(previous?.limitIncrease?.group===usage.group?previous.limitIncrease.amount:0)+(replacement?.limitIncrease?.group===usage.group?replacement.limitIncrease.amount:0);const limit=usage.baseLimit+increase;const excess=Math.max(0,count-limit);if(excess>usage.excess){return{...usage,increase:increase,limit:limit,count:count,excess:excess}}}return null}#replaceModule(slotKey,replacement,replacementStats,primitiveModifiers){const previous=this.#modules.get(slotKey)??null;this.#adjustImportedFigures(previous,replacement,replacementStats);if(replacement===null){this.#modules.delete(slotKey);this.#moduleStats.delete(slotKey);this.#primitiveModifiers.delete(slotKey)}else{this.#modules.set(slotKey,cloneLoadoutModule(replacement));if(replacementStats!==void 0)this.#moduleStats.set(slotKey,replacementStats);if(primitiveModifiers===void 0)this.#primitiveModifiers.delete(slotKey);else this.#primitiveModifiers.set(slotKey,primitiveModifiers)}this.#slotCache.clear()}#adjustImportedFigures(previous,next,nextStats){if(this.#top.UnladenMass!==void 0){this.#top.UnladenMass+=this.#moduleMass(next,nextStats)-this.#moduleMass(previous)}if(this.#top.CargoCapacity!==void 0){this.#top.CargoCapacity+=this.#moduleCapacity(next,"CargoCapacity","cargoCapacity",nextStats)-this.#moduleCapacity(previous,"CargoCapacity","cargoCapacity")}if(this.#top.FuelCapacity?.Main!==void 0){const reserve=this.#top.FuelCapacity.Reserve;this.#top.FuelCapacity={Main:this.#top.FuelCapacity.Main+this.#moduleCapacity(next,"FuelCapacity","fuelCapacity",nextStats)-this.#moduleCapacity(previous,"FuelCapacity","fuelCapacity"),...reserve===void 0?{}:{Reserve:reserve}}}if(normalizeKey(previous?.Item,FITTED_ITEM)===normalizeKey(next?.Item,FITTED_ITEM)){return}if(previous!==null&&isCargoHatchSlot(previous.Slot)||next!==null&&isCargoHatchSlot(next.Slot)){return}delete this.#top.ModulesValue;delete this.#top.Rebuy}#moduleMass(module,statsOverride){if(module===null)return 0;if(isCargoHatchSlot(module.Slot))return 0;const modified=getLoadoutModifier(module,"Mass");if(modified!==null)return modified;return(statsOverride??this.#statsFor(module))?.mass??0}#moduleCapacity(module,modifierLabel,field,statsOverride){if(module===null)return 0;if(isCargoHatchSlot(module.Slot))return 0;const modified=getLoadoutModifier(module,modifierLabel);if(modified!==null)return modified;return(statsOverride??this.#statsFor(module))?.[field]??0}#frameShiftDrive(){for(const m of this.#modules.values()){const stats=this.#statsFor(m);if(stats?.slot==="frameShiftDrive")return{module:m,stats:stats}}return void 0}#resolveDrive(){const fsd=this.#frameShiftDrive();if(!fsd)return null;const{module:fsdModule,stats:base}=fsd;if(base.fuelMul===void 0||base.fuelPower===void 0){throw new TypeError(`ShipLoadout: the fitted record for frame shift drive "${truncate(fsdModule.Item)}" has no jump constants`)}const optMass=getLoadoutModifier(fsdModule,"FSDOptimalMass")??base.optMass;const maxFuel=getLoadoutModifier(fsdModule,"MaxFuelPerJump")??base.maxFuel;if(optMass===void 0||maxFuel===void 0){const missing=[...optMass===void 0?["optMass"]:[],...maxFuel===void 0?["maxFuel"]:[]];throw new TypeError(`ShipLoadout: the fitted record for frame shift drive "${truncate(fsdModule.Item)}" has no ${missing.join(" or ")}`)}return{optMass:optMass,maxFuel:maxFuel,fuelMul:base.fuelMul,fuelPower:base.fuelPower,jumpBoost:this.#resolveJumpBoost()}}#resolveJumpBoost(){for(const m of this.#modules.values()){const stats=this.#statsFor(m);if(stats?.engineeringGroup!=="fsdBoosters"&&(stats?.jumpBoost===void 0||stats.jumpBoost===0)){continue}if(m.On===false)continue;if(stats?.jumpBoost===void 0){throw new TypeError(`ShipLoadout: the fitted record for FSD booster "${truncate(m.Item)}" has no jumpBoost`)}return stats.jumpBoost}return 0}#statsFor(module){if(module===null)return null;const stats=this.#moduleStats.get(module.Slot)??builtInModuleBySymbol(module.Item,FITTED_ITEM);if(stats)return stats;return isBuiltInHullModule(module)?builtInModuleBySymbol("ModularCargoBayDoor","ShipLoadout: built-in module"):null}};export{LoadoutEditError,ShipLoadout};//# sourceMappingURL=chunk-SG6YLUQ4.js.map
|