59 lines
2.6 KiB
JavaScript
59 lines
2.6 KiB
JavaScript
import { createServer } from 'vite';
|
|
|
|
const server = await createServer({
|
|
logLevel: 'error',
|
|
server: { middlewareMode: true, hmr: false },
|
|
appType: 'custom'
|
|
});
|
|
|
|
function assert(condition, message) {
|
|
if (!condition) {
|
|
throw new Error(message);
|
|
}
|
|
}
|
|
|
|
try {
|
|
const presentation = await server.ssrLoadModule('/src/game/settings/combatPresentation.ts');
|
|
const values = new Map();
|
|
const storage = {
|
|
getItem: (key) => values.get(key) ?? null,
|
|
setItem: (key, value) => values.set(key, value)
|
|
};
|
|
|
|
assert(presentation.loadCombatPresentationMode(storage) === 'important', 'The default mode must show only important cut-ins.');
|
|
assert(
|
|
presentation.nextCombatPresentationMode('always') === 'important' &&
|
|
presentation.nextCombatPresentationMode('important') === 'map' &&
|
|
presentation.nextCombatPresentationMode('map') === 'always',
|
|
'The three presentation modes must cycle in the displayed order.'
|
|
);
|
|
|
|
for (const mode of presentation.combatPresentationModes) {
|
|
presentation.saveCombatPresentationMode(mode, storage);
|
|
assert(presentation.loadCombatPresentationMode(storage) === mode, `Mode ${mode} did not persist.`);
|
|
}
|
|
|
|
values.set(presentation.combatPresentationStorageKey, 'invalid');
|
|
assert(presentation.loadCombatPresentationMode(storage) === 'important', 'Invalid stored values must normalize to the default.');
|
|
|
|
const normal = {};
|
|
const critical = { critical: true };
|
|
const defeated = { defeated: true };
|
|
const signature = { signature: true };
|
|
const resonance = { resonance: true };
|
|
const growth = { growth: true };
|
|
|
|
assert(presentation.shouldUseFullCombatCutIn('always', normal), 'Always mode must promote normal attacks.');
|
|
assert(!presentation.shouldUseFullCombatCutIn('important', normal), 'Important mode must keep normal attacks on the map.');
|
|
assert(presentation.shouldUseFullCombatCutIn('important', critical), 'Critical hits must be promoted.');
|
|
assert(presentation.shouldUseFullCombatCutIn('important', defeated), 'Defeats must be promoted.');
|
|
assert(presentation.shouldUseFullCombatCutIn('important', signature), 'Signature tactics must be promoted.');
|
|
assert(presentation.shouldUseFullCombatCutIn('important', resonance), 'Resonance actions must be promoted.');
|
|
assert(presentation.shouldUseFullCombatCutIn('important', growth), 'Level-up actions must be promoted.');
|
|
assert(!presentation.shouldUseFullCombatCutIn('map', signature), 'Map mode must suppress even signature cut-ins.');
|
|
|
|
console.info('Verified combat presentation settings, persistence, cycling, and importance promotion.');
|
|
} finally {
|
|
await server.close();
|
|
}
|