feat: creamapi process

This commit is contained in:
Zamitto 2024-10-06 11:18:14 -03:00
parent b3a1111bfc
commit 387ee86c0f

View File

@ -66,6 +66,11 @@ export const parseAchievementFile = async (
}); });
} }
if (type === Cracker.creamAPI) {
const parsed = await iniParse(filePath);
return processCreamAPI(parsed);
}
achievementsLogger.log(`${type} achievements found on ${filePath}`); achievementsLogger.log(`${type} achievements found on ${filePath}`);
return []; return [];
}; };
@ -125,6 +130,27 @@ const processOnlineFix = (unlockedAchievements: any): UnlockedAchievement[] => {
return parsedUnlockedAchievements; return parsedUnlockedAchievements;
}; };
const processCreamAPI = (unlockedAchievements: any): UnlockedAchievement[] => {
const parsedUnlockedAchievements: UnlockedAchievement[] = [];
for (const achievement of Object.keys(unlockedAchievements)) {
const unlockedAchievement = unlockedAchievements[achievement];
if (unlockedAchievement?.achieved) {
const unlockTime = unlockedAchievement.unlocktime;
parsedUnlockedAchievements.push({
name: achievement,
unlockTime:
unlockTime.length === 7
? unlockTime * 1000 * 1000
: unlockTime * 1000,
});
}
}
return parsedUnlockedAchievements;
};
const processSkidrow = (unlockedAchievements: any): UnlockedAchievement[] => { const processSkidrow = (unlockedAchievements: any): UnlockedAchievement[] => {
const parsedUnlockedAchievements: UnlockedAchievement[] = []; const parsedUnlockedAchievements: UnlockedAchievement[] = [];
const achievements = unlockedAchievements["Achievements"]; const achievements = unlockedAchievements["Achievements"];