diff --git a/libs/pando/engine/src/node/optimization.ts b/libs/pando/engine/src/node/optimization.ts index b8063591ce..318cc72c44 100644 --- a/libs/pando/engine/src/node/optimization.ts +++ b/libs/pando/engine/src/node/optimization.ts @@ -316,6 +316,15 @@ function dedupMapArray(x: I[], map: (_: I) => O): O[] { return x.every((x, i) => (x as any) === newX[i]) ? (x as any) : newX } +/** + * Generates a custom function, "cuz speed". + * NOTE: `slotCount` should be `n.length` for optimization reaons. the size of `n` should not change when fed into the resulting custom function. + * @param n + * @param dynTagCategory + * @param slotCount + * @param initial + * @param header + */ export function compile( n: NumTagFree[], dynTagCategory: string, diff --git a/libs/sr/solver/src/childWorker.ts b/libs/sr/solver/src/childWorker.ts index 6fe64b7f69..5b1903d137 100644 --- a/libs/sr/solver/src/childWorker.ts +++ b/libs/sr/solver/src/childWorker.ts @@ -82,7 +82,7 @@ async function init({ compiledCalcFunction = compile( combinedNodes, 'q', // Tag category for object key - 6, // Number of slots + 7, // Number of slots {} // Initial values // Header; includes custom formulas, such as `res` ) diff --git a/libs/sr/solver/src/parentWorker.ts b/libs/sr/solver/src/parentWorker.ts index 6715c3178c..74681004b1 100644 --- a/libs/sr/solver/src/parentWorker.ts +++ b/libs/sr/solver/src/parentWorker.ts @@ -6,11 +6,6 @@ import { type RelicSlotKey, } from '@genshin-optimizer/sr/consts' import type { ICachedLightCone, ICachedRelic } from '@genshin-optimizer/sr/db' -import { - lightConeData, - own, - srCalculatorWithEntries, -} from '@genshin-optimizer/sr/formula' import { getRelicMainStatVal } from '@genshin-optimizer/sr/util' import type { ChildCommandInit, ChildMessage } from './childWorker' import { MAX_BUILDS } from './common' @@ -230,15 +225,12 @@ function convertRelicToStats(relic: ICachedRelic): RelicStats { } function convertLightConeToStats(lightCone: ICachedLightCone): LightConeStats { - const calc = srCalculatorWithEntries(lightConeData(lightCone)) - return { id: lightCone.id, stats: { - ...objKeyMap( - ['hp', 'atk', 'def'] as const, - (stat) => calc.compute(own.base[stat].with('sheet', 'lightCone')).val - ), + lvl: lightCone.level, + superimpose: lightCone.superimpose, + ascension: lightCone.ascension, [lightCone.key]: 1, }, } diff --git a/libs/sr/solver/src/solver.ts b/libs/sr/solver/src/solver.ts index 1f372dc2ae..5cdd949d38 100644 --- a/libs/sr/solver/src/solver.ts +++ b/libs/sr/solver/src/solver.ts @@ -1,6 +1,6 @@ import { detach, sum } from '@genshin-optimizer/pando/engine' import type { CharacterKey, RelicSlotKey } from '@genshin-optimizer/sr/consts' -import { allRelicSetKeys } from '@genshin-optimizer/sr/consts' +import { allLightConeKeys, allRelicSetKeys } from '@genshin-optimizer/sr/consts' import type { ICachedLightCone, ICachedRelic, @@ -128,6 +128,7 @@ export class Solver { private detachNodes() { // Step 2: Detach nodes from Calculator const relicSetKeys = new Set(allRelicSetKeys) + const lightConeKeys = new Set(allLightConeKeys) const detachedNodes = detach( [ // team @@ -148,6 +149,14 @@ export class Solver { return { q: tag['q']! } // Relic stat bonus if (tag['q'] === 'count' && relicSetKeys.has(tag['sheet'] as any)) return { q: tag['sheet']! } // Relic set counter + if ( + tag['qt'] == 'lightCone' && + ['lvl', 'ascension', 'superimpose'].includes(tag['q'] as string) + ) + return { q: tag['q']! } // Light cone bonus + if (tag['q'] === 'count' && lightConeKeys.has(tag['sheet'] as any)) + return { q: tag['sheet']! } // Relic set counter + return undefined } )