mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
wip: get alternate objectIds
This commit is contained in:
parent
456e7ed809
commit
5d21adcbb1
3 changed files with 66 additions and 65 deletions
|
@ -6,6 +6,7 @@ import fs, { readdirSync } from "node:fs";
|
|||
import {
|
||||
findAchievementFileInExecutableDirectory,
|
||||
findAllAchievementFiles,
|
||||
getAlternativeObjectIds,
|
||||
} from "./find-achivement-files";
|
||||
import type { AchievementFile } from "@types";
|
||||
import { achievementsLogger, logger } from "../logger";
|
||||
|
@ -23,10 +24,11 @@ export const watchAchievements = async () => {
|
|||
|
||||
if (games.length === 0) return;
|
||||
|
||||
const achievementFiles = await findAllAchievementFiles();
|
||||
const achievementFiles = findAllAchievementFiles();
|
||||
|
||||
for (const game of games) {
|
||||
const gameAchievementFiles = achievementFiles.get(game.objectID) || [];
|
||||
for (const objectId of getAlternativeObjectIds(game.objectID)) {
|
||||
const gameAchievementFiles = achievementFiles.get(objectId) || [];
|
||||
const achievementFileInsideDirectory =
|
||||
findAchievementFileInExecutableDirectory(game);
|
||||
|
||||
|
@ -44,6 +46,7 @@ export const watchAchievements = async () => {
|
|||
compareFile(game, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const processAchievementFileDiff = async (
|
||||
|
|
|
@ -27,7 +27,7 @@ const crackers = [
|
|||
Cracker.flt,
|
||||
];
|
||||
|
||||
const getPathFromCracker = async (cracker: Cracker) => {
|
||||
const getPathFromCracker = (cracker: Cracker) => {
|
||||
if (cracker === Cracker.codex) {
|
||||
return [
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ const getPathFromCracker = async (cracker: Cracker) => {
|
|||
throw new Error(`Cracker ${cracker} not implemented`);
|
||||
};
|
||||
|
||||
const getAlternativeObjectIds = (objectId: string) => {
|
||||
export const getAlternativeObjectIds = (objectId: string) => {
|
||||
if (objectId === "205100") {
|
||||
return ["205100", "217980", "31292"];
|
||||
}
|
||||
|
@ -175,13 +175,11 @@ const getAlternativeObjectIds = (objectId: string) => {
|
|||
return [objectId];
|
||||
};
|
||||
|
||||
export const findAchievementFiles = async (game: Game) => {
|
||||
export const findAchievementFiles = (game: Game) => {
|
||||
const achievementFiles: AchievementFile[] = [];
|
||||
|
||||
for (const cracker of crackers) {
|
||||
for (const { folderPath, fileLocation } of await getPathFromCracker(
|
||||
cracker
|
||||
)) {
|
||||
for (const { folderPath, fileLocation } of getPathFromCracker(cracker)) {
|
||||
for (const objectId of getAlternativeObjectIds(game.objectID)) {
|
||||
const filePath = path.join(folderPath, objectId, ...fileLocation);
|
||||
|
||||
|
@ -229,13 +227,11 @@ export const findAchievementFileInExecutableDirectory = (
|
|||
];
|
||||
};
|
||||
|
||||
export const findAllAchievementFiles = async () => {
|
||||
export const findAllAchievementFiles = () => {
|
||||
const gameAchievementFiles = new Map<string, AchievementFile[]>();
|
||||
|
||||
for (const cracker of crackers) {
|
||||
for (const { folderPath, fileLocation } of await getPathFromCracker(
|
||||
cracker
|
||||
)) {
|
||||
for (const { folderPath, fileLocation } of getPathFromCracker(cracker)) {
|
||||
if (!fs.existsSync(folderPath)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import {
|
|||
findAllAchievementFiles,
|
||||
findAchievementFiles,
|
||||
findAchievementFileInExecutableDirectory,
|
||||
getAlternativeObjectIds,
|
||||
} from "./find-achivement-files";
|
||||
import { parseAchievementFile } from "./parse-achievement-file";
|
||||
import { mergeAchievements } from "./merge-achievements";
|
||||
|
@ -11,7 +12,7 @@ import { getGameAchievementData } from "./get-game-achievement-data";
|
|||
import { achievementsLogger } from "../logger";
|
||||
|
||||
export const updateAllLocalUnlockedAchievements = async () => {
|
||||
const gameAchievementFilesMap = await findAllAchievementFiles();
|
||||
const gameAchievementFilesMap = findAllAchievementFiles();
|
||||
|
||||
const games = await gameRepository.find({
|
||||
where: {
|
||||
|
@ -20,8 +21,8 @@ export const updateAllLocalUnlockedAchievements = async () => {
|
|||
});
|
||||
|
||||
for (const game of games) {
|
||||
const gameAchievementFiles =
|
||||
gameAchievementFilesMap.get(game.objectID) || [];
|
||||
for (const objectId of getAlternativeObjectIds(game.objectID)) {
|
||||
const gameAchievementFiles = gameAchievementFilesMap.get(objectId) || [];
|
||||
const achievementFileInsideDirectory =
|
||||
findAchievementFileInExecutableDirectory(game);
|
||||
|
||||
|
@ -68,6 +69,7 @@ export const updateAllLocalUnlockedAchievements = async () => {
|
|||
|
||||
mergeAchievements(game.objectID, "steam", unlockedAchievements, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const updateLocalUnlockedAchivements = async (objectId: string) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue