feat: info for rare and platinum achievements

This commit is contained in:
Zamitto
2025-05-17 18:06:16 -03:00
parent 3cc4ee3ee4
commit 1247a105a0
3 changed files with 24 additions and 21 deletions

View File

@@ -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,
};
});

View File

@@ -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");

View File

@@ -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({