mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-23 02:41:02 +00:00
feat: update compare achievement response
This commit is contained in:
@@ -22,10 +22,10 @@ const getComparedUnlockedAchievements = async (
|
||||
}
|
||||
).then((achievements) => {
|
||||
const sortedAchievements = achievements.achievements.sort((a, b) => {
|
||||
if (a.otherUserStat.unlocked && !b.otherUserStat.unlocked) return -1;
|
||||
if (!a.otherUserStat.unlocked && b.otherUserStat.unlocked) return 1;
|
||||
if (a.otherUserStat.unlocked && b.otherUserStat.unlocked) {
|
||||
return b.otherUserStat.unlockTime! - a.otherUserStat.unlockTime!;
|
||||
if (a.targetStat.unlocked && !b.targetStat.unlocked) return -1;
|
||||
if (!a.targetStat.unlocked && b.targetStat.unlocked) return 1;
|
||||
if (a.targetStat.unlocked && b.targetStat.unlocked) {
|
||||
return b.targetStat.unlockTime! - a.targetStat.unlockTime!;
|
||||
}
|
||||
|
||||
return Number(a.hidden) - Number(b.hidden);
|
||||
|
||||
@@ -11,11 +11,12 @@ import {
|
||||
import type { AchievementFile } from "@types";
|
||||
import { achievementsLogger } from "../logger";
|
||||
import { Cracker } from "@shared";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
|
||||
const fileStats: Map<string, number> = new Map();
|
||||
const fltFiles: Map<string, Set<string>> = new Map();
|
||||
|
||||
export const watchAchievements = async () => {
|
||||
const watchAchiievementsWindows = async () => {
|
||||
const games = await gameRepository.find({
|
||||
where: {
|
||||
isDeleted: false,
|
||||
@@ -23,7 +24,6 @@ export const watchAchievements = async () => {
|
||||
});
|
||||
|
||||
if (games.length === 0) return;
|
||||
|
||||
const achievementFiles = findAllAchievementFiles();
|
||||
|
||||
for (const game of games) {
|
||||
@@ -36,12 +36,6 @@ export const watchAchievements = async () => {
|
||||
|
||||
if (!gameAchievementFiles.length) continue;
|
||||
|
||||
// console.log(
|
||||
// "Achievements files to observe for:",
|
||||
// game.title,
|
||||
// gameAchievementFiles
|
||||
// );
|
||||
|
||||
for (const file of gameAchievementFiles) {
|
||||
compareFile(game, file);
|
||||
}
|
||||
@@ -49,6 +43,27 @@ export const watchAchievements = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const watchAchievementsWithWine = async () => {
|
||||
const games = await gameRepository.find({
|
||||
where: {
|
||||
isDeleted: false,
|
||||
winePrefixPath: Not(IsNull()),
|
||||
},
|
||||
});
|
||||
|
||||
if (games.length === 0) return;
|
||||
|
||||
// TODO: watch achievements with wine
|
||||
};
|
||||
|
||||
export const watchAchievements = async () => {
|
||||
if (process.platform === "win32") {
|
||||
return watchAchiievementsWindows();
|
||||
}
|
||||
|
||||
watchAchievementsWithWine();
|
||||
};
|
||||
|
||||
const processAchievementFileDiff = async (
|
||||
game: Game,
|
||||
file: AchievementFile
|
||||
|
||||
Reference in New Issue
Block a user