steamworks-ffi-node 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +86 -10
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +6 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/SteamAPICore.d.ts +221 -8
  7. package/dist/internal/SteamAPICore.d.ts.map +1 -1
  8. package/dist/internal/SteamAPICore.js +234 -14
  9. package/dist/internal/SteamAPICore.js.map +1 -1
  10. package/dist/internal/SteamAchievementManager.d.ts +602 -31
  11. package/dist/internal/SteamAchievementManager.d.ts.map +1 -1
  12. package/dist/internal/SteamAchievementManager.js +601 -32
  13. package/dist/internal/SteamAchievementManager.js.map +1 -1
  14. package/dist/internal/SteamCallbackPoller.d.ts +68 -0
  15. package/dist/internal/SteamCallbackPoller.d.ts.map +1 -0
  16. package/dist/internal/SteamCallbackPoller.js +134 -0
  17. package/dist/internal/SteamCallbackPoller.js.map +1 -0
  18. package/dist/internal/SteamLeaderboardManager.d.ts +338 -0
  19. package/dist/internal/SteamLeaderboardManager.d.ts.map +1 -0
  20. package/dist/internal/SteamLeaderboardManager.js +734 -0
  21. package/dist/internal/SteamLeaderboardManager.js.map +1 -0
  22. package/dist/internal/SteamLibraryLoader.d.ts +15 -0
  23. package/dist/internal/SteamLibraryLoader.d.ts.map +1 -1
  24. package/dist/internal/SteamLibraryLoader.js +42 -5
  25. package/dist/internal/SteamLibraryLoader.js.map +1 -1
  26. package/dist/internal/SteamStatsManager.d.ts +357 -50
  27. package/dist/internal/SteamStatsManager.d.ts.map +1 -1
  28. package/dist/internal/SteamStatsManager.js +444 -106
  29. package/dist/internal/SteamStatsManager.js.map +1 -1
  30. package/dist/steam.d.ts +169 -9
  31. package/dist/steam.d.ts.map +1 -1
  32. package/dist/steam.js +178 -0
  33. package/dist/steam.js.map +1 -1
  34. package/dist/types.d.ts +91 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js +34 -0
  37. package/dist/types.js.map +1 -1
  38. package/package.json +4 -3
@@ -2,87 +2,524 @@ import { SteamAchievement, AchievementProgressLimits, UserAchievement, Achieveme
2
2
  import { SteamLibraryLoader } from './SteamLibraryLoader';
3
3
  import { SteamAPICore } from './SteamAPICore';
4
4
  /**
5
- * Manages all Steam achievement operations
5
+ * SteamAchievementManager
6
+ *
7
+ * Manages all Steam achievement operations including:
8
+ * - Core operations (get, unlock, clear, check status)
9
+ * - Visual features (icons, progress notifications)
10
+ * - Progress tracking (get limits for progress bars)
11
+ * - Friend comparisons (see friend achievements)
12
+ * - Global statistics (unlock percentages, popularity sorting)
13
+ * - Testing tools (reset stats/achievements)
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const achievementManager = new SteamAchievementManager(libraryLoader, apiCore);
18
+ * const achievements = await achievementManager.getAllAchievements();
19
+ * await achievementManager.unlockAchievement('ACH_WIN_ONE_GAME');
20
+ * ```
6
21
  */
7
22
  export declare class SteamAchievementManager {
23
+ /** Steam library loader for FFI function calls */
8
24
  private libraryLoader;
25
+ /** Steam API core for initialization and callback management */
9
26
  private apiCore;
27
+ /**
28
+ * Creates a new SteamAchievementManager instance
29
+ *
30
+ * @param libraryLoader - The Steam library loader for FFI calls
31
+ * @param apiCore - The Steam API core for lifecycle management
32
+ */
10
33
  constructor(libraryLoader: SteamLibraryLoader, apiCore: SteamAPICore);
11
34
  /**
12
35
  * Get all achievements from Steam
36
+ *
37
+ * Retrieves complete achievement data including unlock status and timestamps.
38
+ * Automatically runs Steam callbacks to ensure latest data is available.
39
+ *
40
+ * @returns Promise resolving to array of all achievements, or empty array on error
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const achievements = await achievementManager.getAllAchievements();
45
+ * console.log(`[Steamworks] Found ${achievements.length} achievements`);
46
+ * achievements.forEach(ach => {
47
+ * console.log(`[Steamworks] ${ach.displayName}: ${ach.unlocked ? 'Unlocked' : 'Locked'}`);
48
+ * });
49
+ * ```
50
+ *
51
+ * @remarks
52
+ * - Returns empty array if Steam API is not initialized
53
+ * - Includes display name, description, unlock status, and unlock time
54
+ * - Unlock time is a Unix timestamp (seconds since epoch)
55
+ *
56
+ * Steamworks SDK Functions:
57
+ * - `SteamAPI_RunCallbacks()` - Process Steam callbacks
58
+ * - `SteamAPI_ISteamUserStats_GetNumAchievements()` - Get total achievement count
59
+ * - `SteamAPI_ISteamUserStats_GetAchievementName()` - Get achievement API name
60
+ * - `SteamAPI_ISteamUserStats_GetAchievementDisplayAttribute()` - Get display attributes
61
+ * - `SteamAPI_ISteamUserStats_GetAchievementAndUnlockTime()` - Get unlock status and time
13
62
  */
14
63
  getAllAchievements(): Promise<SteamAchievement[]>;
15
64
  /**
16
- * Unlock achievement in Steam
65
+ * Unlock an achievement in Steam
66
+ *
67
+ * Permanently unlocks the specified achievement and syncs to Steam servers.
68
+ * Shows Steam overlay notification if enabled.
69
+ *
70
+ * @param achievementName - The API name of the achievement to unlock
71
+ * @returns Promise resolving to true if successful, false otherwise
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const success = await achievementManager.unlockAchievement('ACH_WIN_ONE_GAME');
76
+ * if (success) {
77
+ * console.log('[Steamworks] Achievement unlocked!');
78
+ * }
79
+ * ```
80
+ *
81
+ * @remarks
82
+ * - Achievement must be configured in Steamworks Partner site
83
+ * - Changes are immediately stored to Steam servers
84
+ * - Steam overlay will show unlock notification
85
+ * - Cannot unlock already unlocked achievements (returns true)
86
+ *
87
+ * Steamworks SDK Functions:
88
+ * - `SteamAPI_ISteamUserStats_SetAchievement()` - Mark achievement as unlocked
89
+ * - `SteamAPI_ISteamUserStats_StoreStats()` - Store achievement to Steam servers
90
+ * - `SteamAPI_RunCallbacks()` - Process unlock notification
17
91
  */
18
92
  unlockAchievement(achievementName: string): Promise<boolean>;
19
93
  /**
20
- * Clear achievement in Steam (for testing)
94
+ * Clear an achievement in Steam (for testing purposes)
95
+ *
96
+ * Removes the unlock status of an achievement. Should only be used for testing.
97
+ * Changes are immediately stored to Steam servers.
98
+ *
99
+ * @param achievementName - The API name of the achievement to clear
100
+ * @returns Promise resolving to true if successful, false otherwise
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * // Clear achievement for testing
105
+ * await achievementManager.clearAchievement('ACH_WIN_ONE_GAME');
106
+ * ```
107
+ *
108
+ * @remarks
109
+ * - Only use for testing/debugging purposes
110
+ * - Achievement must be configured in Steamworks Partner site
111
+ * - Changes are immediately stored to Steam servers
112
+ * - Cannot clear already locked achievements (returns true)
113
+ *
114
+ * @warning This permanently removes the achievement unlock from user's profile
115
+ *
116
+ * Steamworks SDK Functions:
117
+ * - `SteamAPI_ISteamUserStats_ClearAchievement()` - Mark achievement as locked
118
+ * - `SteamAPI_ISteamUserStats_StoreStats()` - Store change to Steam servers
119
+ * - `SteamAPI_RunCallbacks()` - Process the change
21
120
  */
22
121
  clearAchievement(achievementName: string): Promise<boolean>;
23
122
  /**
24
- * Check if achievement is unlocked
123
+ * Check if an achievement is unlocked
124
+ *
125
+ * Queries Steam for the current unlock status of a specific achievement.
126
+ *
127
+ * @param achievementName - The API name of the achievement to check
128
+ * @returns Promise resolving to true if unlocked, false if locked or error
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const isUnlocked = await achievementManager.isAchievementUnlocked('ACH_WIN_ONE_GAME');
133
+ * if (isUnlocked) {
134
+ * console.log('[Steamworks] Player has already won one game');
135
+ * }
136
+ * ```
137
+ *
138
+ * @remarks
139
+ * - Returns false if Steam API is not initialized
140
+ * - Returns false if achievement doesn't exist
141
+ * - Returns false on any error (check console for details)
142
+ *
143
+ * Steamworks SDK Functions:
144
+ * - `SteamAPI_ISteamUserStats_GetAchievement()` - Get achievement unlock status
25
145
  */
26
146
  isAchievementUnlocked(achievementName: string): Promise<boolean>;
27
147
  /**
28
- * Get achievement by API name
148
+ * Get a specific achievement by its API name
149
+ *
150
+ * Retrieves complete data for a single achievement.
151
+ *
152
+ * @param achievementName - The API name of the achievement to retrieve
153
+ * @returns Promise resolving to achievement data, or null if not found
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * const achievement = await achievementManager.getAchievementByName('ACH_WIN_ONE_GAME');
158
+ * if (achievement) {
159
+ * console.log(`[Steamworks] ${achievement.displayName}: ${achievement.description}`);
160
+ * }
161
+ * ```
162
+ *
163
+ * @remarks
164
+ * - Calls getAllAchievements() internally, so may be slower than batch operations
165
+ * - Returns null if achievement doesn't exist
166
+ * - Returns null if Steam API is not initialized
167
+ *
168
+ * Steamworks SDK Functions:
169
+ * - Uses getAllAchievements() which calls multiple SDK functions
29
170
  */
30
171
  getAchievementByName(achievementName: string): Promise<SteamAchievement | null>;
31
172
  /**
32
- * Get total number of achievements
173
+ * Get the total number of achievements configured for this game
174
+ *
175
+ * Returns the count of all achievements defined in Steamworks Partner site.
176
+ *
177
+ * @returns Promise resolving to total achievement count, or 0 on error
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * const total = await achievementManager.getTotalAchievementCount();
182
+ * console.log(`[Steamworks] This game has ${total} achievements`);
183
+ * ```
184
+ *
185
+ * @remarks
186
+ * - Returns 0 if Steam API is not initialized
187
+ * - Count includes both locked and unlocked achievements
188
+ *
189
+ * Steamworks SDK Functions:
190
+ * - `SteamAPI_ISteamUserStats_GetNumAchievements()` - Get total achievement count
33
191
  */
34
192
  getTotalAchievementCount(): Promise<number>;
35
193
  /**
36
- * Get number of unlocked achievements
194
+ * Get the number of achievements the user has unlocked
195
+ *
196
+ * Counts how many achievements the current user has unlocked.
197
+ *
198
+ * @returns Promise resolving to count of unlocked achievements
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const total = await achievementManager.getTotalAchievementCount();
203
+ * const unlocked = await achievementManager.getUnlockedAchievementCount();
204
+ * console.log(`[Steamworks] Progress: ${unlocked}/${total} (${(unlocked/total*100).toFixed(1)}%)`);
205
+ * ```
206
+ *
207
+ * @remarks
208
+ * - Calls getAllAchievements() internally to count unlocked achievements
209
+ * - Returns 0 if Steam API is not initialized
210
+ *
211
+ * Steamworks SDK Functions:
212
+ * - Uses getAllAchievements() which calls multiple SDK functions
37
213
  */
38
214
  getUnlockedAchievementCount(): Promise<number>;
39
215
  /**
40
- * Get achievement icon handle
41
- * Returns icon handle for use with ISteamUtils::GetImageRGBA()
42
- * Returns 0 if no icon set or still loading
216
+ * Get the icon handle for an achievement
217
+ *
218
+ * Returns an icon handle that can be used with ISteamUtils::GetImageRGBA()
219
+ * to retrieve the actual icon image data.
220
+ *
221
+ * @param achievementName - The API name of the achievement
222
+ * @returns Promise resolving to icon handle (0 if no icon or still loading)
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * const iconHandle = await achievementManager.getAchievementIcon('ACH_WIN_ONE_GAME');
227
+ * if (iconHandle > 0) {
228
+ * // Use ISteamUtils::GetImageRGBA() to get actual image data
229
+ * console.log(`[Steamworks] Icon handle: ${iconHandle}`);
230
+ * }
231
+ * ```
232
+ *
233
+ * @remarks
234
+ * - Returns 0 if no icon is set for the achievement
235
+ * - Returns 0 if icon is still being fetched from Steam
236
+ * - Wait for UserAchievementIconFetched_t callback if 0 is returned
237
+ * - Icon handle is valid until Steam API shutdown
238
+ *
239
+ * Steamworks SDK Functions:
240
+ * - `SteamAPI_ISteamUserStats_GetAchievementIcon()` - Get achievement icon handle
43
241
  */
44
242
  getAchievementIcon(achievementName: string): Promise<number>;
45
243
  /**
46
- * Indicate achievement progress to user
47
- * Shows a progress notification in Steam overlay
244
+ * Show achievement progress notification to user
245
+ *
246
+ * Displays a progress notification in the Steam overlay showing current/max progress.
247
+ * Useful for achievements that require multiple steps or cumulative actions.
248
+ *
249
+ * @param achievementName - The API name of the achievement
250
+ * @param currentProgress - Current progress value
251
+ * @param maxProgress - Maximum progress value needed to unlock
252
+ * @returns Promise resolving to true if successful, false otherwise
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * // Show "Win 50 games" progress: 25/50
257
+ * await achievementManager.indicateAchievementProgress('ACH_WIN_50_GAMES', 25, 50);
258
+ *
259
+ * // Update progress when player wins another game
260
+ * await achievementManager.indicateAchievementProgress('ACH_WIN_50_GAMES', 26, 50);
261
+ * ```
262
+ *
263
+ * @remarks
264
+ * - Shows notification in Steam overlay (if enabled)
265
+ * - Does NOT unlock the achievement automatically
266
+ * - Call unlockAchievement() when currentProgress >= maxProgress
267
+ * - Notification only shows if progress has changed
268
+ *
269
+ * Steamworks SDK Functions:
270
+ * - `SteamAPI_ISteamUserStats_IndicateAchievementProgress()` - Show progress notification
48
271
  */
49
272
  indicateAchievementProgress(achievementName: string, currentProgress: number, maxProgress: number): Promise<boolean>;
50
273
  /**
51
- * Get achievement progress limits (for integer-based progress)
274
+ * Get achievement progress limits (integer-based)
275
+ *
276
+ * Retrieves the minimum and maximum progress values for an achievement that
277
+ * uses integer-based progress tracking.
278
+ *
279
+ * @param achievementName - The API name of the achievement
280
+ * @returns Promise resolving to progress limits object, or null if not configured
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const limits = await achievementManager.getAchievementProgressLimitsInt('ACH_WIN_50_GAMES');
285
+ * if (limits) {
286
+ * console.log(`[Steamworks] Progress range: ${limits.minProgress} to ${limits.maxProgress}`);
287
+ * }
288
+ * ```
289
+ *
290
+ * @remarks
291
+ * - Returns null if achievement has no progress tracking configured
292
+ * - Use for achievements with integer progress (e.g., "Win 50 games")
293
+ * - For float-based progress, use getAchievementProgressLimitsFloat()
294
+ * - Must be configured in Steamworks Partner site
295
+ *
296
+ * Steamworks SDK Functions:
297
+ * - `SteamAPI_ISteamUserStats_GetAchievementProgressLimitsInt32()` - Get integer progress limits
52
298
  */
53
299
  getAchievementProgressLimitsInt(achievementName: string): Promise<AchievementProgressLimits | null>;
54
300
  /**
55
- * Get achievement progress limits (for float-based progress)
301
+ * Get achievement progress limits (float-based)
302
+ *
303
+ * Retrieves the minimum and maximum progress values for an achievement that
304
+ * uses floating-point progress tracking.
305
+ *
306
+ * @param achievementName - The API name of the achievement
307
+ * @returns Promise resolving to progress limits object, or null if not configured
308
+ *
309
+ * @example
310
+ * ```typescript
311
+ * const limits = await achievementManager.getAchievementProgressLimitsFloat('ACH_TRAVEL_100KM');
312
+ * if (limits) {
313
+ * console.log(`[Steamworks] Need to travel ${limits.maxProgress}km`);
314
+ * }
315
+ * ```
316
+ *
317
+ * @remarks
318
+ * - Returns null if achievement has no progress tracking configured
319
+ * - Use for achievements with decimal progress (e.g., "Travel 100.5km")
320
+ * - For integer-based progress, use getAchievementProgressLimitsInt()
321
+ * - Must be configured in Steamworks Partner site
322
+ *
323
+ * Steamworks SDK Functions:
324
+ * - `SteamAPI_ISteamUserStats_GetAchievementProgressLimitsFloat()` - Get float progress limits
56
325
  */
57
326
  getAchievementProgressLimitsFloat(achievementName: string): Promise<AchievementProgressLimits | null>;
58
327
  /**
59
- * Request stats for another user (friend)
60
- * This is async - you need to wait for the callback before calling getUserAchievement
328
+ * Request achievement stats for another user (friend)
329
+ *
330
+ * Initiates an asynchronous request to fetch achievement data for another Steam user.
331
+ * Must be called before getUserAchievement() can return data for that user.
332
+ *
333
+ * @param steamId - The Steam ID of the user (as string, e.g., "76561197960287930")
334
+ * @returns Promise resolving to true if request sent, false on error
335
+ *
336
+ * @example
337
+ * ```typescript
338
+ * const friendId = '76561197960287930';
339
+ *
340
+ * // Request friend's stats
341
+ * await achievementManager.requestUserStats(friendId);
342
+ *
343
+ * // Wait for callback and process
344
+ * await new Promise(resolve => setTimeout(resolve, 2000));
345
+ * steam.runCallbacks();
346
+ *
347
+ * // Now can get friend's achievement
348
+ * const achievement = await achievementManager.getUserAchievement(friendId, 'ACH_WIN_ONE_GAME');
349
+ * ```
350
+ *
351
+ * @remarks
352
+ * - This is an asynchronous operation - wait for callback
353
+ * - Friend must have played the game to have stats
354
+ * - Wait 1-2 seconds and call runCallbacks() before querying
355
+ * - Request times out after some period (varies)
356
+ *
357
+ * Steamworks SDK Functions:
358
+ * - `SteamAPI_ISteamUserStats_RequestUserStats()` - Request user's achievement data
61
359
  */
62
360
  requestUserStats(steamId: string): Promise<boolean>;
63
361
  /**
64
362
  * Get achievement status for another user (friend)
65
- * Must call requestUserStats() first and wait for callback
363
+ *
364
+ * Retrieves complete achievement data for another Steam user, including their
365
+ * unlock status and unlock time.
366
+ *
367
+ * @param steamId - The Steam ID of the user (as string)
368
+ * @param achievementName - The API name of the achievement
369
+ * @returns Promise resolving to user achievement data, or null if not available
370
+ *
371
+ * @example
372
+ * ```typescript
373
+ * // First request the user's stats
374
+ * await achievementManager.requestUserStats('76561197960287930');
375
+ * await new Promise(resolve => setTimeout(resolve, 2000));
376
+ * steam.runCallbacks();
377
+ *
378
+ * // Now get specific achievement
379
+ * const achievement = await achievementManager.getUserAchievement(
380
+ * '76561197960287930',
381
+ * 'ACH_WIN_ONE_GAME'
382
+ * );
383
+ *
384
+ * if (achievement && achievement.unlocked) {
385
+ * const date = new Date(achievement.unlockTime * 1000);
386
+ * console.log(`[Steamworks] Friend unlocked on: ${date.toLocaleDateString()}`);
387
+ * }
388
+ * ```
389
+ *
390
+ * @remarks
391
+ * - Must call requestUserStats() first and wait for callback
392
+ * - Returns null if stats not yet loaded or achievement doesn't exist
393
+ * - Friend must have played the game
394
+ * - Includes unlock time as Unix timestamp
395
+ *
396
+ * Steamworks SDK Functions:
397
+ * - `SteamAPI_ISteamUserStats_GetUserAchievementAndUnlockTime()` - Get user's achievement status
66
398
  */
67
399
  getUserAchievement(steamId: string, achievementName: string): Promise<UserAchievement | null>;
68
400
  /**
69
- * Request global achievement percentages
70
- * This is async - wait for callback before calling getAchievementAchievedPercent
401
+ * Request global achievement unlock percentages
402
+ *
403
+ * Initiates an asynchronous request to fetch global achievement statistics
404
+ * (what percentage of all players have unlocked each achievement).
405
+ *
406
+ * @returns Promise resolving to true if request sent, false on error
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * // Request global percentages
411
+ * await achievementManager.requestGlobalAchievementPercentages();
412
+ *
413
+ * // Wait for callback
414
+ * await new Promise(resolve => setTimeout(resolve, 2000));
415
+ * steam.runCallbacks();
416
+ *
417
+ * // Now can get percentages
418
+ * const percent = await achievementManager.getAchievementAchievedPercent('ACH_WIN_ONE_GAME');
419
+ * console.log(`[Steamworks] ${percent}% of players have unlocked this achievement`);
420
+ * ```
421
+ *
422
+ * @remarks
423
+ * - This is an asynchronous operation - wait for callback
424
+ * - Required before calling getAchievementAchievedPercent()
425
+ * - Required before calling getAllAchievementsSortedByPopularity()
426
+ * - Wait 2-3 seconds and call runCallbacks() before querying
427
+ * - Data is cached after first successful request
428
+ *
429
+ * Steamworks SDK Functions:
430
+ * - `SteamAPI_ISteamUserStats_RequestGlobalAchievementPercentages()` - Request global percentages
71
431
  */
72
432
  requestGlobalAchievementPercentages(): Promise<boolean>;
73
433
  /**
74
- * Get percentage of users who unlocked a specific achievement
75
- * Must call requestGlobalAchievementPercentages() first
434
+ * Get global unlock percentage for a specific achievement
435
+ *
436
+ * Returns what percentage of all players have unlocked this achievement.
437
+ *
438
+ * @param achievementName - The API name of the achievement
439
+ * @returns Promise resolving to percentage (0-100), or null if not available
440
+ *
441
+ * @example
442
+ * ```typescript
443
+ * const percent = await achievementManager.getAchievementAchievedPercent('ACH_WIN_ONE_GAME');
444
+ * if (percent !== null) {
445
+ * if (percent < 10) {
446
+ * console.log(`[Steamworks] Rare achievement! Only ${percent.toFixed(2)}% have this`);
447
+ * } else {
448
+ * console.log(`[Steamworks] Common achievement: ${percent.toFixed(2)}% unlocked`);
449
+ * }
450
+ * }
451
+ * ```
452
+ *
453
+ * @remarks
454
+ * - Must call requestGlobalAchievementPercentages() first
455
+ * - Returns null if global stats not yet loaded
456
+ * - Percentage is between 0.0 and 100.0
457
+ * - Data represents all players across all platforms
458
+ *
459
+ * Steamworks SDK Functions:
460
+ * - `SteamAPI_ISteamUserStats_GetAchievementAchievedPercent()` - Get global unlock percentage
76
461
  */
77
462
  getAchievementAchievedPercent(achievementName: string): Promise<number | null>;
78
463
  /**
79
- * Get all achievements with global unlock percentages
80
- * Must call requestGlobalAchievementPercentages() first and wait for callback
464
+ * Get all achievements with their global unlock percentages
465
+ *
466
+ * Combines achievement data with global statistics to show what percentage
467
+ * of players have unlocked each achievement.
468
+ *
469
+ * @returns Promise resolving to array of achievements with global stats
470
+ *
471
+ * @example
472
+ * ```typescript
473
+ * // Request global data first
474
+ * await achievementManager.requestGlobalAchievementPercentages();
475
+ * await new Promise(resolve => setTimeout(resolve, 2000));
476
+ * steam.runCallbacks();
477
+ *
478
+ * // Get all achievements with percentages
479
+ * const achievements = await achievementManager.getAllAchievementsWithGlobalStats();
480
+ *
481
+ * // Find rarest achievement
482
+ * const rarest = achievements.reduce((prev, curr) =>
483
+ * curr.globalUnlockPercentage < prev.globalUnlockPercentage ? curr : prev
484
+ * );
485
+ * console.log(`[Steamworks] Rarest: ${rarest.displayName} (${rarest.globalUnlockPercentage.toFixed(2)}%)`);
486
+ * ```
487
+ *
488
+ * @remarks
489
+ * - Must call requestGlobalAchievementPercentages() first
490
+ * - Iterates through all achievements to fetch percentages
491
+ * - May return 0% for achievements where data is unavailable
492
+ *
493
+ * Steamworks SDK Functions:
494
+ * - Uses getAllAchievements() and getAchievementAchievedPercent()
81
495
  */
82
496
  getAllAchievementsWithGlobalStats(): Promise<AchievementGlobalStats[]>;
83
497
  /**
84
- * Get most achieved achievement info
85
- * Returns iterator for use with getNextMostAchievedAchievementInfo
498
+ * Get the most achieved achievement
499
+ *
500
+ * Returns the achievement with the highest global unlock percentage.
501
+ * Provides an iterator for use with getNextMostAchievedAchievementInfo().
502
+ *
503
+ * @returns Promise resolving to most achieved achievement data with iterator, or null
504
+ *
505
+ * @example
506
+ * ```typescript
507
+ * const mostAchieved = await achievementManager.getMostAchievedAchievementInfo();
508
+ * if (mostAchieved) {
509
+ * console.log(`[Steamworks] Most achieved: ${mostAchieved.apiName}`);
510
+ * console.log(`[Steamworks] Unlocked by: ${mostAchieved.percent.toFixed(2)}% of players`);
511
+ * console.log(`[Steamworks] You ${mostAchieved.unlocked ? 'have' : 'don\'t have'} it`);
512
+ * }
513
+ * ```
514
+ *
515
+ * @remarks
516
+ * - Must call requestGlobalAchievementPercentages() first
517
+ * - Returns -1 iterator if no data available
518
+ * - Use iterator with getNextMostAchievedAchievementInfo() to iterate
519
+ * - Ordered by highest percentage first
520
+ *
521
+ * Steamworks SDK Functions:
522
+ * - `SteamAPI_ISteamUserStats_GetMostAchievedAchievementInfo()` - Get most achieved achievement
86
523
  */
87
524
  getMostAchievedAchievementInfo(): Promise<{
88
525
  apiName: string;
@@ -91,7 +528,43 @@ export declare class SteamAchievementManager {
91
528
  iterator: number;
92
529
  } | null>;
93
530
  /**
94
- * Get next most achieved achievement info (iterate by popularity)
531
+ * Get the next most achieved achievement (iterate by popularity)
532
+ *
533
+ * Continues iteration through achievements ordered by global unlock percentage.
534
+ * Use the iterator from getMostAchievedAchievementInfo() or previous call.
535
+ *
536
+ * @param previousIterator - Iterator from previous call
537
+ * @returns Promise resolving to next achievement data with iterator, or null if end
538
+ *
539
+ * @example
540
+ * ```typescript
541
+ * // Get top 5 most achieved achievements
542
+ * const top5 = [];
543
+ * let current = await achievementManager.getMostAchievedAchievementInfo();
544
+ *
545
+ * if (current) {
546
+ * top5.push(current);
547
+ *
548
+ * for (let i = 0; i < 4; i++) {
549
+ * const next = await achievementManager.getNextMostAchievedAchievementInfo(current.iterator);
550
+ * if (!next) break;
551
+ * top5.push(next);
552
+ * current = next;
553
+ * }
554
+ * }
555
+ *
556
+ * top5.forEach((ach, i) => {
557
+ * console.log(`[Steamworks] ${i + 1}. ${ach.apiName}: ${ach.percent.toFixed(2)}%`);
558
+ * });
559
+ * ```
560
+ *
561
+ * @remarks
562
+ * - Must call requestGlobalAchievementPercentages() first
563
+ * - Returns null when iteration is complete (iterator === -1)
564
+ * - Achievements ordered from highest to lowest percentage
565
+ *
566
+ * Steamworks SDK Functions:
567
+ * - `SteamAPI_ISteamUserStats_GetNextMostAchievedAchievementInfo()` - Get next achievement by popularity
95
568
  */
96
569
  getNextMostAchievedAchievementInfo(previousIterator: number): Promise<{
97
570
  apiName: string;
@@ -100,17 +573,115 @@ export declare class SteamAchievementManager {
100
573
  iterator: number;
101
574
  } | null>;
102
575
  /**
103
- * Get all achievements sorted by global unlock percentage (most achieved first)
104
- * Must call requestGlobalAchievementPercentages() first
576
+ * Get all achievements sorted by global unlock percentage
577
+ *
578
+ * Returns complete achievement list ordered from most to least achieved.
579
+ * Includes full achievement details with global unlock percentages.
580
+ *
581
+ * @returns Promise resolving to sorted array of achievements with global stats
582
+ *
583
+ * @example
584
+ * ```typescript
585
+ * // Request global data
586
+ * await achievementManager.requestGlobalAchievementPercentages();
587
+ * await new Promise(resolve => setTimeout(resolve, 2000));
588
+ * steam.runCallbacks();
589
+ *
590
+ * // Get sorted achievements
591
+ * const sorted = await achievementManager.getAllAchievementsSortedByPopularity();
592
+ *
593
+ * console.log('[Steamworks] Most to Least Achieved:');
594
+ * sorted.forEach((ach, i) => {
595
+ * console.log(`[Steamworks] ${i + 1}. ${ach.displayName}: ${ach.globalUnlockPercentage.toFixed(2)}%`);
596
+ * });
597
+ *
598
+ * // Find rarest achievements
599
+ * const rare = sorted.filter(a => a.globalUnlockPercentage < 5);
600
+ * console.log(`[Steamworks] ${rare.length} rare achievements (< 5% unlock rate)`);
601
+ * ```
602
+ *
603
+ * @remarks
604
+ * - Must call requestGlobalAchievementPercentages() first
605
+ * - Returns empty array if no global data available
606
+ * - Sorted from highest to lowest percentage
607
+ * - Includes display names and descriptions
608
+ *
609
+ * Steamworks SDK Functions:
610
+ * - Uses getMostAchievedAchievementInfo() and getNextMostAchievedAchievementInfo()
611
+ * - `SteamAPI_ISteamUserStats_GetAchievementDisplayAttribute()` - Get display attributes
105
612
  */
106
613
  getAllAchievementsSortedByPopularity(): Promise<AchievementGlobalStats[]>;
107
614
  /**
108
- * Reset all stats and optionally achievements
109
- * WARNING: This clears ALL user stats and achievements!
615
+ * Reset all user stats and optionally achievements
616
+ *
617
+ * Permanently clears all statistics and optionally all achievements for the current user.
618
+ * Changes are immediately stored to Steam servers.
619
+ *
620
+ * @param includeAchievements - If true, also clears all achievements (default: false)
621
+ * @returns Promise resolving to true if successful, false otherwise
622
+ *
623
+ * @example
624
+ * ```typescript
625
+ * // Reset only stats, keep achievements
626
+ * await achievementManager.resetAllStats(false);
627
+ *
628
+ * // Reset everything including achievements
629
+ * await achievementManager.resetAllStats(true);
630
+ * ```
631
+ *
632
+ * @warning
633
+ * **THIS PERMANENTLY DELETES USER DATA!**
634
+ * - All stats are set to 0
635
+ * - If includeAchievements=true, all achievements are locked
636
+ * - Changes are immediately synced to Steam servers
637
+ * - Cannot be undone
638
+ * - Only use for testing/debugging
639
+ *
640
+ * @remarks
641
+ * - Use with extreme caution - this affects user's permanent record
642
+ * - Recommended only for development/testing accounts
643
+ * - Does not affect other users or global statistics
644
+ * - Changes visible immediately in Steam overlay
645
+ *
646
+ * Steamworks SDK Functions:
647
+ * - `SteamAPI_ISteamUserStats_ResetAllStats()` - Reset all stats and optionally achievements
648
+ * - `SteamAPI_ISteamUserStats_StoreStats()` - Store reset to Steam servers
649
+ * - `SteamAPI_RunCallbacks()` - Process the reset operation
110
650
  */
111
651
  resetAllStats(includeAchievements?: boolean): Promise<boolean>;
112
652
  /**
113
- * Get all achievements with icon handles
653
+ * Get all achievements with their icon handles
654
+ *
655
+ * Returns complete achievement list with icon handles that can be used
656
+ * to retrieve actual icon image data via ISteamUtils::GetImageRGBA().
657
+ *
658
+ * @returns Promise resolving to array of achievements with icon handles
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const achievements = await achievementManager.getAllAchievementsWithIcons();
663
+ *
664
+ * achievements.forEach(ach => {
665
+ * console.log(`[Steamworks] ${ach.displayName}:`);
666
+ * console.log(`[Steamworks] Status: ${ach.unlocked ? 'Unlocked' : 'Locked'}`);
667
+ * console.log(`[Steamworks] Icon Handle: ${ach.iconHandle}`);
668
+ *
669
+ * if (ach.iconHandle > 0) {
670
+ * // Use ISteamUtils::GetImageRGBA() to get actual image
671
+ * // const imageData = steamUtils.getImageRGBA(ach.iconHandle);
672
+ * }
673
+ * });
674
+ * ```
675
+ *
676
+ * @remarks
677
+ * - Icon handle of 0 means no icon or still loading
678
+ * - Icon handles are valid until Steam API shutdown
679
+ * - Use ISteamUtils interface to convert handles to image data
680
+ * - May trigger icon fetching if not yet cached
681
+ *
682
+ * Steamworks SDK Functions:
683
+ * - Uses getAllAchievements() and getAchievementIcon()
684
+ * - `SteamAPI_ISteamUserStats_GetAchievementIcon()` - Get icon handle for each achievement
114
685
  */
115
686
  getAllAchievementsWithIcons(): Promise<AchievementWithIcon[]>;
116
687
  }