Files
HolodoriCalc/scripts/collect-holo-work-achievements.mjs
T
dal4segno 07b98db520
Publish GitHub Pages output / publish (push) Successful in 44s
data: switch to recovered game DB and refresh cards and charts
2026-09-29 22:48:08 +09:00

23 lines
1.5 KiB
JavaScript

import { writeFileSync } from 'node:fs';
import { prepareGameDbSource, readGameDbText, sourceMetadata } from './game-db-source.mjs';
const source = prepareGameDbSource('kor');
const missions = JSON.parse(readGameDbText(source, 'Mission.json')).map((row) => row.data)
.filter((mission) => mission.characterId
&& mission.categoryType === 'MissionCategoryType_MISSION_CATEGORY_TYPE_ACHIEVEMENT'
&& mission.type === 'MissionType_MISSION_TYPE_INCREMENT_WORK_FINISH_COUNT');
const progress = JSON.parse(readGameDbText(source, 'MissionProgress.json')).map((row) => row.data);
if (!missions.length) throw new Error('No member Holo-work achievements found.');
const thresholdsByMember = Object.fromEntries(missions.sort((a, b) => a.characterId.localeCompare(b.characterId)).map((mission) => {
const thresholds = [...new Set(progress.filter((row) => row.missionId === mission.id).map((row) => Number(row.threshold)))].sort((a, b) => a - b);
if (!thresholds.length || thresholds.some((value) => !Number.isSafeInteger(value) || value <= 0)) {
throw new Error(`Invalid Holo-work thresholds: ${mission.id}`);
}
return [mission.characterId, thresholds];
}));
writeFileSync(new URL('../src/lib/data/holo-work-achievements.json', import.meta.url), JSON.stringify({
source: { ...sourceMetadata(source), files: ['Mission.json', 'MissionProgress.json'] },
thresholdsByMember
}, null, 2) + '\n');
console.log(`Collected Holo-work achievements for ${missions.length} members at ${source.masterDataVersion}.`);