ships.blueprint costs.Function.getBlueprintCost - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / ships/blueprint-costs / getBlueprintCost

Function: getBlueprintCost()

getBlueprintCost(blueprintSymbol, grade, currentGrade?): BlueprintCost | null

Defined in: src/ships/blueprint-costs.ts:212

Compute the total cost of engineering a module up to a grade โ€” every grade the module still has to climb, each rolled the number of times it takes to complete, summed into one shopping list and one Merc Coin total.

Grade N takes N rolls to fill its progress bar (grade 1 โ†’ 1 roll, grade 2 โ†’ 2 rolls, โ€ฆ grade 5 โ†’ 5 rolls), and each roll costs that grade's recipe once, so the climb is weighted rather than a plain sum โ€” for the materials and the Merc Coin alike.

By default it prices the whole climb from unengineered; pass currentGrade to price only what remains. Each grade g in currentGrade + 1 โ€ฆ grade contributes g ยท (grade g's cost). To price a single grade's complete progression, set currentGrade to grade โˆ’ 1; use getBlueprintGradeCost for one roll.

A Mercenary article is bought at grade 1 and its recipe defines grades 2โ€“5, so pass 1 to price what an engineer can still add. The ordinary-menu recipes that also bill Merc Coin, FuelScoop_Efficiency and the *Laser_ThermalPlasmaConversion recipes, define grades 1โ€“5 on a stock module and climb from 0 like any other recipe.

This is blueprint cost only. An experimental effect is a separate application, and it costs materials alone; combine its getExperimentalEffectCost result with materials here using sumMaterials, and mercCoins needs no such folding.

The game writes three colliding ids for two different recipes, but each pair costs the same at every grade. Either spelling therefore prices correctly without a fitted module; cross-catalogue tests pin that invariant.

Parameters

blueprintSymbol

string

The blueprint id, e.g. "FSD_LongRange", matched case-insensitively after trimming surrounding whitespace.

grade

number

The target grade, 1โ€“5.

currentGrade?

number = 0

The completed grade, 0โ€“5; defaults to 0 for an unengineered module. Only grades above it are charged; currentGrade >= grade costs nothing ({ materials: [], mercCoins: 0 }).

Returns

BlueprintCost | null

The summed materials and Merc Coin total, or null if no ordinary craft cost is catalogued for the blueprint and target grade. A blueprint that starts above grade 1 charges only the grades it defines. mercCoins is 0 where the recipe charges no currency, so null remains the one answer meaning "not catalogued".

Throws

If grade is not an integer from 1 through 5, or currentGrade is not an integer from 0 through 5.

Throws

If blueprintSymbol is present and not a string. A nullish blueprintSymbol is a miss, answered the way an unrecognised one is.

Example

import { getBlueprintCost } from '@elite-dangerous-almanac/core/ships/blueprint-costs';

getBlueprintCost('FSD_LongRange', 5);    // grades 1โ€“5
getBlueprintCost('FSD_LongRange', 5, 3); // grades 4 and 5 only
getBlueprintCost('FSD_LongRange', 5, 4); // grade 5 progression only

getBlueprintCost('FSD_LongRange', 5)?.mercCoins; // -> 0
getBlueprintCost('RailGun_LongShot', 5, 1)?.mercCoins; // -> 415
getBlueprintCost('FuelScoop_Efficiency', 5)?.mercCoins; // -> 350
โš ๏ธ **GitHub.com Fallback** โš ๏ธ