import React from "react"; import { Accordion, AccordionSummary, AccordionDetails, Box, Typography } from "@mui/material"; import { AchievementEntry } from "./AchievementEntry"; import { Achievement, PlayerAchievement } from "./Achievements"; import { Settings } from "../Settings/Settings"; import { getFiltersFromHex } from "../ThirdParty/colorUtils"; import { CorruptableText } from "../ui/React/CorruptableText"; interface IProps { achievements: Achievement[]; playerAchievements: PlayerAchievement[]; } export function AchievementList({ achievements, playerAchievements }: IProps): JSX.Element { // Need to transform the primary color into css filters to change the color of the SVG. const cssPrimary = getFiltersFromHex(Settings.theme.primary); const cssSecondary = getFiltersFromHex(Settings.theme.secondary); const data = achievements .map((achievement) => ({ achievement, unlockedOn: playerAchievements.find((playerAchievement) => playerAchievement.ID === achievement.ID)?.unlockedOn, })) .sort((a, b) => (b.unlockedOn ?? 0) - (a.unlockedOn ?? 0)); const unlocked = data.filter((entry) => entry.unlockedOn); // Hidden achievements const secret = data.filter((entry) => !entry.unlockedOn && entry.achievement.Secret); // Locked behind locked content (bitnode x) const unavailable = data.filter( (entry) => !entry.unlockedOn && !entry.achievement.Secret && entry.achievement.Visible && !entry.achievement.Visible(), ); // Remaining achievements const locked = data .filter((entry) => !unlocked.map((u) => u.achievement.ID).includes(entry.achievement.ID)) .filter((entry) => !secret.map((u) => u.achievement.ID).includes(entry.achievement.ID)) .filter((entry) => !unavailable.map((u) => u.achievement.ID).includes(entry.achievement.ID)); return ( {unlocked.length > 0 && ( Acquired ({unlocked.length}/{data.length}) {unlocked.map((item) => ( ))} )} {locked.length > 0 && ( Locked ({locked.length} remaining) {locked.map((item) => ( ))} )} {unavailable.length > 0 && ( Unavailable ({unavailable.length} remaining) {unavailable.length} additional achievements hidden behind content you don't have access to. )} {secret.length > 0 && ( Secret ({secret.length} remaining) {secret.map((item) => (
))}
)}
); }