This repository was archived by the owner on Jul 1, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuildLabSheetUpdates.ts
More file actions
38 lines (34 loc) · 1.23 KB
/
Copy pathbuildLabSheetUpdates.ts
File metadata and controls
38 lines (34 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { quoteSheetTitleForRange } from './buildRelicUnlockedUpdates'
import { columnIndexToA1Letter } from './relicSheetLayout'
import { getEffectiveLevel } from '../types/research'
import type { ResearchData } from '../types/research'
import type { EffectivePathsLabSheetRow } from './labSheetLayout'
export type LabSheetBatchUpdate = {
range: string
values: (string | number | boolean)[][]
}
/** Build per-row Level column updates for Laboratory v3.x Master Sheet. */
export function buildLabSheetUpdates(
sheetTitle: string,
labRows: readonly EffectivePathsLabSheetRow[],
data: ResearchData,
levelOverrides: Readonly<Record<string, number>>,
): LabSheetBatchUpdate[] {
const quoted = quoteSheetTitleForRange(sheetTitle)
const out: LabSheetBatchUpdate[] = []
for (const row of labRows) {
const { sectionIndex, itemIndex } = row.itemRef
const item = data.sections[sectionIndex]?.items[itemIndex]
if (!item) continue
const level = Math.max(
0,
Math.round(getEffectiveLevel(sectionIndex, itemIndex, item, { ...levelOverrides })),
)
const levelCol = columnIndexToA1Letter(row.levelCol)
out.push({
range: `${quoted}!${levelCol}${row.rowIndex}`,
values: [[level]],
})
}
return out
}