fix: handle duplicate component keys in conversion cost recipes
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m2s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m2s
This commit is contained in:
@@ -39,37 +39,46 @@ function baseElementCost(element: string): ConversionCost {
|
||||
|
||||
/** Build a ConversionCost for a composite element (distance 2) */
|
||||
function compositeElementCost(element: string, components: string[]): ConversionCost {
|
||||
const costPerComponent = computeComponentCost(2); // 30 each
|
||||
const componentCosts: Record<string, number> = {};
|
||||
for (const c of components) {
|
||||
componentCosts[c] = (componentCosts[c] || 0) + costPerComponent;
|
||||
}
|
||||
return {
|
||||
element,
|
||||
distance: 2,
|
||||
rawCost: computeRawCost(2), // 1,000
|
||||
componentCosts: Object.fromEntries(
|
||||
components.map(c => [c, computeComponentCost(2)]), // 30 each
|
||||
),
|
||||
componentCosts,
|
||||
};
|
||||
}
|
||||
|
||||
/** Build a ConversionCost for an exotic element (distance 3) */
|
||||
function exoticElementCost(element: string, components: string[]): ConversionCost {
|
||||
const costPerComponent = computeComponentCost(3); // 40 each
|
||||
const componentCosts: Record<string, number> = {};
|
||||
for (const c of components) {
|
||||
componentCosts[c] = (componentCosts[c] || 0) + costPerComponent;
|
||||
}
|
||||
return {
|
||||
element,
|
||||
distance: 3,
|
||||
rawCost: computeRawCost(3), // 10,000
|
||||
componentCosts: Object.fromEntries(
|
||||
components.map(c => [c, computeComponentCost(3)]), // 40 each
|
||||
),
|
||||
componentCosts,
|
||||
};
|
||||
}
|
||||
|
||||
/** Build a ConversionCost for time (distance 4) */
|
||||
function timeElementCost(element: string, components: string[]): ConversionCost {
|
||||
const costPerComponent = computeComponentCost(4); // 50 each
|
||||
const componentCosts: Record<string, number> = {};
|
||||
for (const c of components) {
|
||||
componentCosts[c] = (componentCosts[c] || 0) + costPerComponent;
|
||||
}
|
||||
return {
|
||||
element,
|
||||
distance: 4,
|
||||
rawCost: computeRawCost(4), // 100,000
|
||||
componentCosts: Object.fromEntries(
|
||||
components.map(c => [c, computeComponentCost(4)]), // 50 each
|
||||
),
|
||||
componentCosts,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user