feat: enrich campaign reward and roster visuals
This commit is contained in:
@@ -19,12 +19,12 @@ const server = await createServer({
|
||||
try {
|
||||
const { battleScenarios } = await server.ssrLoadModule('/src/game/data/battles.ts');
|
||||
const { battleMapAssets } = await server.ssrLoadModule('/src/game/data/battleMapAssets.ts');
|
||||
const { storyBackgroundAssets, storyBackgroundKeysFor } = await server.ssrLoadModule('/src/game/data/storyAssets.ts');
|
||||
const { storyBackgroundAssets, storyBackgroundKeysForPages } = await server.ssrLoadModule('/src/game/data/storyAssets.ts');
|
||||
const scenarioModule = await server.ssrLoadModule('/src/game/data/scenario.ts');
|
||||
|
||||
const reviewedBattleMapPrefixes = collectReviewedBattleMapPrefixes();
|
||||
const battleRows = collectBattleRows(battleScenarios, battleMapAssets, reviewedBattleMapPrefixes);
|
||||
const storyUsage = collectStoryUsage(scenarioModule, storyBackgroundAssets, storyBackgroundKeysFor);
|
||||
const storyUsage = collectStoryUsage(scenarioModule, storyBackgroundAssets, storyBackgroundKeysForPages);
|
||||
const storyRows = collectStoryRows(storyBackgroundAssets, storyUsage);
|
||||
const report = renderReport({ battleRows, storyRows, storyUsage });
|
||||
|
||||
@@ -122,7 +122,7 @@ function battleOrdinalPrefix(battleId) {
|
||||
return battleId.match(/^(.+)-battle-/)?.[1] ?? battleId;
|
||||
}
|
||||
|
||||
function collectStoryUsage(scenarioModule, storyBackgroundAssets, storyBackgroundKeysFor) {
|
||||
function collectStoryUsage(scenarioModule, storyBackgroundAssets, storyBackgroundKeysForPages) {
|
||||
const usageByPath = new Map();
|
||||
const pageReferences = [];
|
||||
|
||||
@@ -131,28 +131,30 @@ function collectStoryUsage(scenarioModule, storyBackgroundAssets, storyBackgroun
|
||||
return;
|
||||
}
|
||||
|
||||
value
|
||||
.filter((entry) => entry && typeof entry === 'object' && typeof entry.background === 'string')
|
||||
.forEach((page) => {
|
||||
const candidateKeys = storyBackgroundKeysFor(page.background);
|
||||
const resolvedKey = candidateKeys.find((key) => storyBackgroundAssets[key]) ?? page.background;
|
||||
const path = assetUrlToPath(storyBackgroundAssets[resolvedKey], 'src/assets/images/');
|
||||
const usage = usageByPath.get(path) ?? {
|
||||
path,
|
||||
keys: new Set(),
|
||||
baseBackgrounds: new Set(),
|
||||
pageCount: 0,
|
||||
pageExamples: []
|
||||
};
|
||||
usage.keys.add(resolvedKey);
|
||||
usage.baseBackgrounds.add(page.background);
|
||||
usage.pageCount += 1;
|
||||
if (usage.pageExamples.length < 3) {
|
||||
usage.pageExamples.push(`${exportName}/${page.id ?? 'unnamed'}`);
|
||||
}
|
||||
usageByPath.set(path, usage);
|
||||
pageReferences.push({ exportName, pageId: page.id, background: page.background, resolvedKey, path });
|
||||
});
|
||||
const pages = value.filter(
|
||||
(entry) => entry && typeof entry === 'object' && typeof entry.id === 'string' && typeof entry.background === 'string'
|
||||
);
|
||||
const selectedKeys = storyBackgroundKeysForPages(pages);
|
||||
|
||||
pages.forEach((page, index) => {
|
||||
const resolvedKey = selectedKeys[index] ?? page.background;
|
||||
const path = assetUrlToPath(storyBackgroundAssets[resolvedKey], 'src/assets/images/');
|
||||
const usage = usageByPath.get(path) ?? {
|
||||
path,
|
||||
keys: new Set(),
|
||||
baseBackgrounds: new Set(),
|
||||
pageCount: 0,
|
||||
pageExamples: []
|
||||
};
|
||||
usage.keys.add(resolvedKey);
|
||||
usage.baseBackgrounds.add(page.background);
|
||||
usage.pageCount += 1;
|
||||
if (usage.pageExamples.length < 3) {
|
||||
usage.pageExamples.push(`${exportName}/${page.id ?? 'unnamed'}`);
|
||||
}
|
||||
usageByPath.set(path, usage);
|
||||
pageReferences.push({ exportName, pageId: page.id, background: page.background, resolvedKey, path });
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user