mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: info for rare and platinum achievements
This commit is contained in:
@@ -14,6 +14,12 @@ import { SubscriptionRequiredError } from "@shared";
|
||||
import { achievementsLogger } from "../logger";
|
||||
import { db, gameAchievementsSublevel, levelKeys } from "@main/level";
|
||||
|
||||
const isRareAchievement = (points: number) => {
|
||||
const rawPercentage = (50 - Math.sqrt(points)) * 2;
|
||||
|
||||
return rawPercentage < 10;
|
||||
};
|
||||
|
||||
const saveAchievementsOnLocal = async (
|
||||
objectId: string,
|
||||
shop: GameShop,
|
||||
@@ -87,7 +93,7 @@ export const mergeAchievements = async (
|
||||
publishNotification &&
|
||||
userPreferences?.achievementNotificationsEnabled
|
||||
) {
|
||||
const achievementsInfo: AchievementNotificationInfo[] = newAchievements
|
||||
const filteredAchievements = newAchievements
|
||||
.toSorted((a, b) => {
|
||||
return a.unlockTime - b.unlockTime;
|
||||
})
|
||||
@@ -99,16 +105,23 @@ export const mergeAchievements = async (
|
||||
);
|
||||
});
|
||||
})
|
||||
.filter((achievement) => Boolean(achievement))
|
||||
.map((achievement) => {
|
||||
.filter((achievement) => !!achievement);
|
||||
|
||||
const achievementsInfo: AchievementNotificationInfo[] =
|
||||
filteredAchievements.map((achievement, index) => {
|
||||
return {
|
||||
title: achievement!.displayName,
|
||||
description: achievement!.description,
|
||||
points: achievement!.points,
|
||||
isHidden: achievement!.hidden,
|
||||
isRare: false,
|
||||
isPlatinum: false,
|
||||
iconUrl: achievement!.icon,
|
||||
title: achievement.displayName,
|
||||
description: achievement.description,
|
||||
points: achievement.points,
|
||||
isHidden: achievement.hidden,
|
||||
isRare: achievement.points
|
||||
? isRareAchievement(achievement.points)
|
||||
: false,
|
||||
isPlatinum:
|
||||
index === filteredAchievements.length - 1 &&
|
||||
newAchievements.length + unlockedAchievements.length ===
|
||||
achievementsData.length,
|
||||
iconUrl: achievement.icon,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { injectCustomCss } from "@renderer/helpers";
|
||||
import { AchievementNotificationItem } from "@renderer/components/achievements/notification/achievement-notification";
|
||||
|
||||
const NOTIFICATION_TIMEOUT = 40000;
|
||||
const NOTIFICATION_TIMEOUT = 4000;
|
||||
|
||||
export function AchievementNotification() {
|
||||
const { t } = useTranslation("achievement");
|
||||
|
||||
@@ -50,16 +50,6 @@ const DEFAULT_THEME_CODE = `/*
|
||||
|
||||
/* Button */
|
||||
.button {}
|
||||
|
||||
/* Custom Achievement Notification */
|
||||
.achievement-notification {}
|
||||
.achievement-notification__container {}
|
||||
.achievement-notification__content {}
|
||||
.achievement-notification__icon {}
|
||||
.achievement-notification__text-container {}
|
||||
.achievement-notification__title {}
|
||||
.achievement-notification__description {}
|
||||
|
||||
`;
|
||||
|
||||
export function AddThemeModal({
|
||||
|
||||
Reference in New Issue
Block a user