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 2
Expand file tree
/
Copy pathguardiansEpStateFromSheet.test.ts
More file actions
73 lines (66 loc) · 2.98 KB
/
Copy pathguardiansEpStateFromSheet.test.ts
File metadata and controls
73 lines (66 loc) · 2.98 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { describe, expect, it } from 'vitest'
import {
buildGuardianLevelCellUpdates,
buildGuardianSheetUpdates,
} from './buildGuardianSheetUpdates'
import { guardiansEpStateAppliedToPersisted } from './epImportAppliedToPersisted'
import { guardiansEpStateFromSheetGrid } from './guardiansEpStateFromSheet'
import type { GuardiansEpSyncState } from './guardiansEpStateFromPersisted'
import { readGuardianChipState } from '../guardianChipStorage'
import {
GUARDIAN_EP_CHIP_START_ROWS,
GUARDIAN_EP_V302_LEVEL_COL,
GUARDIAN_EP_V302_UNLOCK_COL,
GUARDIAN_EP_V302_UNLOCKED_ROWS,
} from './guardianEpSheetNames'
function gridFromGuardianExport(state: GuardiansEpSyncState): string[][] {
const grid = Array.from({ length: 24 }, () => Array<string>(8).fill(''))
for (const entry of buildGuardianSheetUpdates('Master Sheet', state)) {
const match = /!B(\d+)$/.exec(entry.range)
if (!match) continue
const row = Number(match[1]) - 1
grid[row]![GUARDIAN_EP_V302_UNLOCK_COL] = String(entry.values[0]![0])
}
for (const { rowIndex, label } of buildGuardianLevelCellUpdates(state)) {
grid[rowIndex - 1]![GUARDIAN_EP_V302_LEVEL_COL] = label
}
return grid
}
describe('guardiansEpStateFromSheetGrid', () => {
it('round-trips unlock checkboxes from column B', () => {
const state: GuardiansEpSyncState = {
upgrades: {
attack: { percent: 1, cooldown: 1, targets: 1 },
ally: { recovery: 1, maxRecovery: 1, cooldown: 1 },
bounty: { multiplier: 1, cooldown: 1, targets: 1 },
fetch: { cooldown: 1, findChance: 1, doubleFindChance: 1 },
summon: { cooldown: 1, duration: 1, cashBonus: 1 },
scout: { cooldown: 1, rangeBonus: 1, duration: 1 },
},
unlockedChipIds: ['attack', 'ally', 'scout'],
}
const imported = guardiansEpStateFromSheetGrid(gridFromGuardianExport(state))
expect(imported.unlockedChipIds).toEqual(['attack', 'ally', 'scout'])
})
it('reads attack percent level from column F dropdown', () => {
const grid = Array.from({ length: 24 }, () => Array<string>(8).fill(''))
grid[GUARDIAN_EP_CHIP_START_ROWS.attack - 1]![GUARDIAN_EP_V302_LEVEL_COL] =
'01 | 2% | Cost 25 ⧈ | Next 50 ⧈'
const imported = guardiansEpStateFromSheetGrid(grid)
expect(imported.upgrades.attack.percent).toBe(2)
expect(imported.unlockedChipIds).toContain('attack')
expect(imported.unlockedChipIds).toContain('ally')
})
it('reads bounty unlock from B10 TRUE/FALSE', () => {
const grid = Array.from({ length: 24 }, () => Array<string>(8).fill(''))
grid[GUARDIAN_EP_V302_UNLOCKED_ROWS.bounty - 1]![GUARDIAN_EP_V302_UNLOCK_COL] = 'TRUE'
grid[GUARDIAN_EP_CHIP_START_ROWS.bounty - 1]![GUARDIAN_EP_V302_LEVEL_COL] =
'00 | 0.01x | Cost 0 ⧈ | Next 1 ⧈'
const applied = guardiansEpStateAppliedToPersisted(
readGuardianChipState(),
guardiansEpStateFromSheetGrid(grid),
)
expect(applied.unlockedChipIds).toContain('bounty')
expect(applied.upgrades.bounty.multiplier).toBe(1)
})
})