Harden sortie formation assignment recovery
This commit is contained in:
@@ -38,6 +38,7 @@ try {
|
||||
setFirstBattleReport
|
||||
} = await server.ssrLoadModule('/src/game/state/campaignState.ts');
|
||||
const { battleScenarios } = await server.ssrLoadModule('/src/game/data/battles.ts');
|
||||
const { normalizeSortieFormationAssignments } = await server.ssrLoadModule('/src/game/data/sortieDeployment.ts');
|
||||
|
||||
storage.clear();
|
||||
const empty = loadCampaignState();
|
||||
@@ -73,6 +74,35 @@ try {
|
||||
cappedLaunchSupplies['unit-96'] === undefined,
|
||||
`Expected launch sortie supplies without a roster filter to stay capped: ${JSON.stringify(cappedLaunchSupplies)}`
|
||||
);
|
||||
const normalizedLaunchFormation = normalizeSortieFormationAssignments(
|
||||
{
|
||||
'liu-bei': 'front',
|
||||
' liu-bei ': 'support',
|
||||
'guan-yu': 'flank',
|
||||
'ghost-unit': 'reserve',
|
||||
'zhang-fei': 'broken',
|
||||
['x'.repeat(97)]: 'front',
|
||||
'': 'front'
|
||||
},
|
||||
new Set(['liu-bei', 'guan-yu'])
|
||||
);
|
||||
assert(
|
||||
normalizedLaunchFormation['liu-bei'] === 'front' &&
|
||||
normalizedLaunchFormation['guan-yu'] === 'flank' &&
|
||||
normalizedLaunchFormation['ghost-unit'] === undefined &&
|
||||
normalizedLaunchFormation['zhang-fei'] === undefined &&
|
||||
normalizedLaunchFormation['x'.repeat(97)] === undefined,
|
||||
`Expected launch sortie formation assignments to trim, filter, and preserve first valid roles: ${JSON.stringify(normalizedLaunchFormation)}`
|
||||
);
|
||||
const cappedLaunchFormation = normalizeSortieFormationAssignments(
|
||||
Object.fromEntries(Array.from({ length: 120 }, (_, index) => [`unit-${index}`, 'front']))
|
||||
);
|
||||
assert(
|
||||
Object.keys(cappedLaunchFormation).length === 96 &&
|
||||
cappedLaunchFormation['unit-95'] === 'front' &&
|
||||
cappedLaunchFormation['unit-96'] === undefined,
|
||||
`Expected launch sortie formation assignments without a roster filter to stay capped: ${JSON.stringify(cappedLaunchFormation)}`
|
||||
);
|
||||
|
||||
resetCampaignState();
|
||||
const firstScenario = battleScenarios['first-battle-zhuo-commandery'];
|
||||
|
||||
Reference in New Issue
Block a user