import type { Achievement } from "@elysium/types"; import { useState } from "react"; import { useGame } from "../../context/GameContext.js"; import { LockToggle } from "../ui/LockToggle.js"; const conditionDescription = (achievement: Achievement, formatNumber: (n: number) => string): string => { const { condition } = achievement; switch (condition.type) { case "totalGoldEarned": return `Earn ${formatNumber(condition.amount)} total gold`; case "totalClicks": return `Click ${formatNumber(condition.amount)} times`; case "bossesDefeated": return `Defeat ${condition.amount} boss${condition.amount > 1 ? "es" : ""}`; case "questsCompleted": return `Complete ${condition.amount} quest${condition.amount > 1 ? "s" : ""}`; case "adventurerTotal": return `Recruit ${formatNumber(condition.amount)} total adventurers`; case "prestigeCount": return `Prestige ${condition.amount} time${condition.amount > 1 ? "s" : ""}`; case "equipmentOwned": return `Own ${condition.amount} equipment item${condition.amount > 1 ? "s" : ""}`; } }; interface AchievementCardProps { achievement: Achievement; formatNumber: (n: number) => string; } const AchievementCard = ({ achievement, formatNumber }: AchievementCardProps): React.JSX.Element => { const isUnlocked = achievement.unlockedAt !== null; return (
{achievement.icon}

{achievement.name}

{achievement.description}

{conditionDescription(achievement, formatNumber)}

{achievement.reward?.crystals != null && (

💎 +{achievement.reward.crystals} Crystals

)}
{isUnlocked ? ( ✓ Unlocked ) : ( 🔒 )}
); }; export const AchievementPanel = (): React.JSX.Element => { const { state, formatNumber } = useGame(); const [showLocked, setShowLocked] = useState(true); if (!state) return

Loading...

; const achievements = state.achievements ?? []; const unlocked = achievements.filter((a) => a.unlockedAt !== null); const locked = achievements.filter((a) => a.unlockedAt === null); const visible = showLocked ? achievements : unlocked; return (

Achievements

{ setShowLocked((v) => !v); }} />

{unlocked.length} / {achievements.length} unlocked

{visible.map((achievement) => ( ))}
); };