Cover sortie supply launch normalization

This commit is contained in:
2026-07-05 10:17:24 +09:00
parent a1f925c1ca
commit ffbe8a510e

View File

@@ -25,12 +25,30 @@ const server = await createServer({
}); });
try { try {
const { campaignStorageKey, loadCampaignState } = await server.ssrLoadModule('/src/game/state/campaignState.ts'); const { campaignStorageKey, loadCampaignState, normalizeCampaignSortieItemAssignments } = await server.ssrLoadModule('/src/game/state/campaignState.ts');
storage.clear(); storage.clear();
const empty = loadCampaignState(); const empty = loadCampaignState();
assert(empty.version === 1 && empty.step === 'new', `Expected empty storage to create initial campaign state: ${JSON.stringify(empty)}`); assert(empty.version === 1 && empty.step === 'new', `Expected empty storage to create initial campaign state: ${JSON.stringify(empty)}`);
const normalizedLaunchSupplies = normalizeCampaignSortieItemAssignments(
{
'liu-bei': { bean: '9', salve: '2', stone: '4' },
'guan-yu': { wine: '3' },
'ghost-unit': { bean: '1' },
'': { bean: '1' }
},
new Set(['liu-bei', 'guan-yu'])
);
assert(
normalizedLaunchSupplies['liu-bei']?.bean === 2 &&
normalizedLaunchSupplies['liu-bei']?.salve === 1 &&
normalizedLaunchSupplies['liu-bei']?.stone === undefined &&
normalizedLaunchSupplies['guan-yu']?.wine === 1 &&
normalizedLaunchSupplies['ghost-unit'] === undefined,
`Expected launch sortie supplies to share save normalization rules: ${JSON.stringify(normalizedLaunchSupplies)}`
);
storage.clear(); storage.clear();
storage.set( storage.set(
campaignStorageKey, campaignStorageKey,