UNPKG

gamify-ui-core

Version:

🚀 The ultimate gamification engine for modern web applications. Framework-agnostic, real-time leaderboards, custom rule engine, streaks, missions, and AI-powered features.

76 lines • 2.26 kB
import { Achievement, User, GameEvent } from '../types'; export interface AchievementCondition { type: 'xp_threshold' | 'badge_count' | 'streak_duration' | 'event_count' | 'custom'; value: number; operator: 'equals' | 'greater_than' | 'less_than' | 'greater_than_or_equal'; metadata?: Record<string, any>; } export interface AchievementTemplate { id: string; title: string; description: string; conditions: AchievementCondition[]; rewards: { xp?: number; badges?: string[]; custom?: Record<string, any>; }; rarity: 'common' | 'uncommon' | 'rare' | 'epic' | 'legendary'; category: string; icon?: string; secret?: boolean; } /** * Manages achievements and their conditions */ export declare class AchievementManager { private readonly achievements; private readonly userAchievements; /** * Register an achievement template */ registerAchievement(template: AchievementTemplate): void; /** * Get all achievement templates */ getAchievementTemplates(): AchievementTemplate[]; /** * Get achievement template by ID */ getAchievementTemplate(id: string): AchievementTemplate | undefined; /** * Check if user has earned an achievement */ hasAchievement(userId: string, achievementId: string): boolean; /** * Get user's achievements */ getUserAchievements(userId: string): Achievement[]; /** * Process user data and check for new achievements */ processUserAchievements(user: User, event?: GameEvent): Achievement[]; /** * Check if achievement conditions are met */ private checkAchievementConditions; private checkXpCondition; private checkBadgeCountCondition; private checkStreakCondition; private checkEventCountCondition; private checkCustomCondition; /** * Get achievement statistics */ getAchievementStats(userId: string): { total: number; earned: number; progress: number; byRarity: Record<string, number>; }; /** * Reset user achievements (for testing) */ resetUserAchievements(userId: string): void; } //# sourceMappingURL=AchievementManager.d.ts.map