steamworks-ffi-node 0.3.0 → 0.3.1
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.
- package/README.md +54 -10
- package/dist/internal/SteamAPICore.d.ts +198 -8
- package/dist/internal/SteamAPICore.d.ts.map +1 -1
- package/dist/internal/SteamAPICore.js +197 -8
- package/dist/internal/SteamAPICore.js.map +1 -1
- package/dist/internal/SteamAchievementManager.d.ts +602 -31
- package/dist/internal/SteamAchievementManager.d.ts.map +1 -1
- package/dist/internal/SteamAchievementManager.js +600 -31
- package/dist/internal/SteamAchievementManager.js.map +1 -1
- package/dist/internal/SteamLibraryLoader.d.ts.map +1 -1
- package/dist/internal/SteamLibraryLoader.js +16 -5
- package/dist/internal/SteamLibraryLoader.js.map +1 -1
- package/dist/internal/SteamStatsManager.d.ts +337 -42
- package/dist/internal/SteamStatsManager.d.ts.map +1 -1
- package/dist/internal/SteamStatsManager.js +335 -42
- package/dist/internal/SteamStatsManager.js.map +1 -1
- package/dist/steam.d.ts.map +1 -1
- package/dist/steam.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,40 +1,120 @@
|
|
|
1
1
|
import { SteamLibraryLoader } from './SteamLibraryLoader';
|
|
2
2
|
import { SteamAPICore } from './SteamAPICore';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* SteamStatsManager
|
|
5
|
+
*
|
|
6
|
+
* Manages all Steam user statistics operations including:
|
|
7
|
+
* - User stats (get/set integer and float values)
|
|
8
|
+
* - Average rate stats (for tracking rates over time)
|
|
9
|
+
* - Friend/user stats (view stats of other players)
|
|
10
|
+
* - Global stats (aggregate statistics across all players)
|
|
11
|
+
* - Global stat history (historical data over time)
|
|
12
|
+
*
|
|
13
|
+
* Stats are different from achievements - they are numeric values that can increase/decrease
|
|
14
|
+
* and are used for leaderboards, progress tracking, and game analytics.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const statsManager = new SteamStatsManager(libraryLoader, apiCore);
|
|
19
|
+
*
|
|
20
|
+
* // Set and get player stats
|
|
21
|
+
* await statsManager.setStatInt('total_kills', 100);
|
|
22
|
+
* const kills = await statsManager.getStatInt('total_kills');
|
|
23
|
+
*
|
|
24
|
+
* // Get global stats
|
|
25
|
+
* await statsManager.requestGlobalStats(7);
|
|
26
|
+
* const globalKills = await statsManager.getGlobalStatInt('total_kills');
|
|
27
|
+
* ```
|
|
6
28
|
*/
|
|
7
29
|
export declare class SteamStatsManager {
|
|
30
|
+
/** Steam library loader for FFI function calls */
|
|
8
31
|
private libraryLoader;
|
|
32
|
+
/** Steam API core for initialization and callback management */
|
|
9
33
|
private apiCore;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new SteamStatsManager instance
|
|
36
|
+
*
|
|
37
|
+
* @param libraryLoader - The Steam library loader for FFI calls
|
|
38
|
+
* @param apiCore - The Steam API core for lifecycle management
|
|
39
|
+
*/
|
|
10
40
|
constructor(libraryLoader: SteamLibraryLoader, apiCore: SteamAPICore);
|
|
11
41
|
/**
|
|
12
|
-
* Get an integer stat value
|
|
42
|
+
* Get an integer stat value for the current user
|
|
13
43
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
44
|
+
* Retrieves a 32-bit integer stat value from Steam. Stats are numeric values
|
|
45
|
+
* that track player progress and can be used for leaderboards and analytics.
|
|
46
|
+
*
|
|
47
|
+
* @param statName - Name of the stat to retrieve (as defined in Steamworks Partner site)
|
|
48
|
+
* @returns The stat value, or null if not found or on error
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const totalKills = await statsManager.getStatInt('total_kills');
|
|
53
|
+
* if (totalKills !== null) {
|
|
54
|
+
* console.log(`Total kills: ${totalKills}`);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* - Returns null if Steam API is not initialized
|
|
60
|
+
* - Stat names are case-sensitive and must match Steamworks configuration
|
|
61
|
+
* - Use getStatFloat() for decimal values
|
|
16
62
|
*
|
|
17
63
|
* Steamworks SDK Functions:
|
|
18
64
|
* - `SteamAPI_ISteamUserStats_GetStatInt32()` - Get int32 stat value
|
|
19
65
|
*/
|
|
20
66
|
getStatInt(statName: string): Promise<number | null>;
|
|
21
67
|
/**
|
|
22
|
-
* Get a float stat value
|
|
68
|
+
* Get a float stat value for the current user
|
|
23
69
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
70
|
+
* Retrieves a floating-point stat value from Steam. Use this for stats that
|
|
71
|
+
* require decimal precision (e.g., average accuracy, distance traveled).
|
|
72
|
+
*
|
|
73
|
+
* @param statName - Name of the stat to retrieve (as defined in Steamworks Partner site)
|
|
74
|
+
* @returns The stat value, or null if not found or on error
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const accuracy = await statsManager.getStatFloat('shooting_accuracy');
|
|
79
|
+
* if (accuracy !== null) {
|
|
80
|
+
* console.log(`Accuracy: ${(accuracy * 100).toFixed(2)}%`);
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* - Returns null if Steam API is not initialized
|
|
86
|
+
* - Use getStatInt() for whole number values
|
|
26
87
|
*
|
|
27
88
|
* Steamworks SDK Functions:
|
|
28
89
|
* - `SteamAPI_ISteamUserStats_GetStatFloat()` - Get float stat value
|
|
29
90
|
*/
|
|
30
91
|
getStatFloat(statName: string): Promise<number | null>;
|
|
31
92
|
/**
|
|
32
|
-
* Set an integer stat value
|
|
93
|
+
* Set an integer stat value for the current user
|
|
33
94
|
*
|
|
34
|
-
*
|
|
95
|
+
* Updates a 32-bit integer stat value and immediately stores it to Steam servers.
|
|
96
|
+
* The new value will be visible in your Steam profile and can trigger achievements.
|
|
97
|
+
*
|
|
98
|
+
* @param statName - Name of the stat to set (as defined in Steamworks Partner site)
|
|
35
99
|
* @param value - Integer value to set
|
|
36
100
|
* @returns true if successful, false otherwise
|
|
37
101
|
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Increment kill count
|
|
105
|
+
* const currentKills = await statsManager.getStatInt('total_kills') || 0;
|
|
106
|
+
* const success = await statsManager.setStatInt('total_kills', currentKills + 1);
|
|
107
|
+
* if (success) {
|
|
108
|
+
* console.log('Kill count updated!');
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @remarks
|
|
113
|
+
* - Automatically calls StoreStats() to save to Steam servers
|
|
114
|
+
* - Runs callbacks to process the store operation
|
|
115
|
+
* - Can trigger stat-based achievements
|
|
116
|
+
* - Use setStatFloat() for decimal values
|
|
117
|
+
*
|
|
38
118
|
* Steamworks SDK Functions:
|
|
39
119
|
* - `SteamAPI_ISteamUserStats_SetStatInt32()` - Set int32 stat value
|
|
40
120
|
* - `SteamAPI_ISteamUserStats_StoreStats()` - Store stats to Steam servers
|
|
@@ -42,12 +122,29 @@ export declare class SteamStatsManager {
|
|
|
42
122
|
*/
|
|
43
123
|
setStatInt(statName: string, value: number): Promise<boolean>;
|
|
44
124
|
/**
|
|
45
|
-
* Set a float stat value
|
|
125
|
+
* Set a float stat value for the current user
|
|
46
126
|
*
|
|
47
|
-
*
|
|
127
|
+
* Updates a floating-point stat value and immediately stores it to Steam servers.
|
|
128
|
+
* Use this for stats requiring decimal precision.
|
|
129
|
+
*
|
|
130
|
+
* @param statName - Name of the stat to set (as defined in Steamworks Partner site)
|
|
48
131
|
* @param value - Float value to set
|
|
49
132
|
* @returns true if successful, false otherwise
|
|
50
133
|
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* // Update accuracy based on hits/shots
|
|
137
|
+
* const hits = 85;
|
|
138
|
+
* const shots = 100;
|
|
139
|
+
* const accuracy = hits / shots; // 0.85
|
|
140
|
+
* await statsManager.setStatFloat('shooting_accuracy', accuracy);
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* - Automatically calls StoreStats() to save to Steam servers
|
|
145
|
+
* - Runs callbacks to process the store operation
|
|
146
|
+
* - Use setStatInt() for whole number values
|
|
147
|
+
*
|
|
51
148
|
* Steamworks SDK Functions:
|
|
52
149
|
* - `SteamAPI_ISteamUserStats_SetStatFloat()` - Set float stat value
|
|
53
150
|
* - `SteamAPI_ISteamUserStats_StoreStats()` - Store stats to Steam servers
|
|
@@ -56,13 +153,30 @@ export declare class SteamStatsManager {
|
|
|
56
153
|
setStatFloat(statName: string, value: number): Promise<boolean>;
|
|
57
154
|
/**
|
|
58
155
|
* Update an average rate stat
|
|
59
|
-
* This is used for stats like "average speed" or "kills per hour"
|
|
60
156
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
157
|
+
* Updates stats that represent rates or averages over time (e.g., "kills per hour",
|
|
158
|
+
* "average speed"). Steam automatically maintains the average calculation.
|
|
159
|
+
*
|
|
160
|
+
* @param statName - Name of the stat to update (as defined in Steamworks Partner site)
|
|
161
|
+
* @param countThisSession - Count/value for this session (e.g., kills this session)
|
|
63
162
|
* @param sessionLength - Length of session in seconds
|
|
64
163
|
* @returns true if successful, false otherwise
|
|
65
164
|
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* // Update kills per hour stat
|
|
168
|
+
* const sessionKills = 25;
|
|
169
|
+
* const sessionSeconds = 1800; // 30 minutes
|
|
170
|
+
* await statsManager.updateAvgRateStat('kills_per_hour', sessionKills, sessionSeconds);
|
|
171
|
+
* // Steam calculates: (25 / 1800) * 3600 = 50 kills/hour
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
* - Automatically calls StoreStats() to save to Steam servers
|
|
176
|
+
* - Steam maintains the running average across all sessions
|
|
177
|
+
* - sessionLength should be in seconds
|
|
178
|
+
* - Used for "per hour" or "per game" statistics
|
|
179
|
+
*
|
|
66
180
|
* Steamworks SDK Functions:
|
|
67
181
|
* - `SteamAPI_ISteamUserStats_UpdateAvgRateStat()` - Update average rate stat
|
|
68
182
|
* - `SteamAPI_ISteamUserStats_StoreStats()` - Store stats to Steam servers
|
|
@@ -71,22 +185,67 @@ export declare class SteamStatsManager {
|
|
|
71
185
|
updateAvgRateStat(statName: string, countThisSession: number, sessionLength: number): Promise<boolean>;
|
|
72
186
|
/**
|
|
73
187
|
* Request stats for another user (friend)
|
|
74
|
-
*
|
|
188
|
+
*
|
|
189
|
+
* Requests stat data from Steam servers for a specific user. Must be called
|
|
190
|
+
* before getting user stats with getUserStatInt() or getUserStatFloat().
|
|
191
|
+
* This is an asynchronous operation - wait a moment before reading the stats.
|
|
75
192
|
*
|
|
76
193
|
* @param steamId - Steam ID of the user (as string or BigInt)
|
|
77
|
-
* @returns true if request was sent, false otherwise
|
|
194
|
+
* @returns true if request was sent successfully, false otherwise
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const friendSteamId = '76561198012345678';
|
|
199
|
+
*
|
|
200
|
+
* // Request the friend's stats
|
|
201
|
+
* const success = await statsManager.requestUserStats(friendSteamId);
|
|
202
|
+
* if (success) {
|
|
203
|
+
* // Wait a moment for Steam to fetch the data
|
|
204
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
205
|
+
*
|
|
206
|
+
* // Now get the friend's stats
|
|
207
|
+
* const friendKills = await statsManager.getUserStatInt(friendSteamId, 'total_kills');
|
|
208
|
+
* console.log(`Friend has ${friendKills} kills`);
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @remarks
|
|
213
|
+
* - Must be called before getting user stats
|
|
214
|
+
* - Returns true immediately if request was sent (not when data arrives)
|
|
215
|
+
* - Wait 50-100ms after requesting before reading stats
|
|
216
|
+
* - User's stats must be public for this to work
|
|
78
217
|
*
|
|
79
218
|
* Steamworks SDK Functions:
|
|
80
|
-
* - `SteamAPI_ISteamUserStats_RequestUserStats()` - Request user stats from Steam
|
|
219
|
+
* - `SteamAPI_ISteamUserStats_RequestUserStats()` - Request user stats from Steam servers
|
|
81
220
|
*/
|
|
82
221
|
requestUserStats(steamId: string | bigint): Promise<boolean>;
|
|
83
222
|
/**
|
|
84
223
|
* Get an integer stat value for another user (friend)
|
|
85
|
-
*
|
|
224
|
+
*
|
|
225
|
+
* Retrieves a 32-bit integer stat value for a specific user. Must call
|
|
226
|
+
* requestUserStats() first and wait for the data to arrive.
|
|
86
227
|
*
|
|
87
228
|
* @param steamId - Steam ID of the user
|
|
88
229
|
* @param statName - Name of the stat to retrieve
|
|
89
|
-
* @returns The stat value, or null if not found
|
|
230
|
+
* @returns The stat value, or null if not found or on error
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* // Compare your kills to a friend's
|
|
235
|
+
* const friendId = '76561198012345678';
|
|
236
|
+
* await statsManager.requestUserStats(friendId);
|
|
237
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
238
|
+
*
|
|
239
|
+
* const myKills = await statsManager.getStatInt('total_kills') || 0;
|
|
240
|
+
* const friendKills = await statsManager.getUserStatInt(friendId, 'total_kills') || 0;
|
|
241
|
+
*
|
|
242
|
+
* console.log(`You: ${myKills}, Friend: ${friendKills}`);
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* - Must call requestUserStats() first
|
|
247
|
+
* - Wait 50-100ms after requesting before calling this
|
|
248
|
+
* - Returns null if stats haven't arrived yet or user's stats are private
|
|
90
249
|
*
|
|
91
250
|
* Steamworks SDK Functions:
|
|
92
251
|
* - `SteamAPI_ISteamUserStats_GetUserStatInt32()` - Get user's int32 stat value
|
|
@@ -94,11 +253,31 @@ export declare class SteamStatsManager {
|
|
|
94
253
|
getUserStatInt(steamId: string | bigint, statName: string): Promise<number | null>;
|
|
95
254
|
/**
|
|
96
255
|
* Get a float stat value for another user (friend)
|
|
97
|
-
*
|
|
256
|
+
*
|
|
257
|
+
* Retrieves a floating-point stat value for a specific user. Must call
|
|
258
|
+
* requestUserStats() first and wait for the data to arrive.
|
|
98
259
|
*
|
|
99
260
|
* @param steamId - Steam ID of the user
|
|
100
261
|
* @param statName - Name of the stat to retrieve
|
|
101
|
-
* @returns The stat value, or null if not found
|
|
262
|
+
* @returns The stat value, or null if not found or on error
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* // Compare accuracy with a friend
|
|
267
|
+
* const friendId = '76561198012345678';
|
|
268
|
+
* await statsManager.requestUserStats(friendId);
|
|
269
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
270
|
+
*
|
|
271
|
+
* const friendAccuracy = await statsManager.getUserStatFloat(friendId, 'shooting_accuracy');
|
|
272
|
+
* if (friendAccuracy !== null) {
|
|
273
|
+
* console.log(`Friend accuracy: ${(friendAccuracy * 100).toFixed(2)}%`);
|
|
274
|
+
* }
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @remarks
|
|
278
|
+
* - Must call requestUserStats() first
|
|
279
|
+
* - Wait 50-100ms after requesting before calling this
|
|
280
|
+
* - Returns null if stats haven't arrived yet or user's stats are private
|
|
102
281
|
*
|
|
103
282
|
* Steamworks SDK Functions:
|
|
104
283
|
* - `SteamAPI_ISteamUserStats_GetUserStatFloat()` - Get user's float stat value
|
|
@@ -106,59 +285,175 @@ export declare class SteamStatsManager {
|
|
|
106
285
|
getUserStatFloat(steamId: string | bigint, statName: string): Promise<number | null>;
|
|
107
286
|
/**
|
|
108
287
|
* Request global stats data from Steam
|
|
109
|
-
* Must be called before getting global stats
|
|
110
288
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
289
|
+
* Requests aggregated statistics across all players from Steam servers.
|
|
290
|
+
* Optionally includes historical data for trend analysis.
|
|
291
|
+
* Must be called before getting global stats.
|
|
292
|
+
*
|
|
293
|
+
* @param historyDays - Number of days of history to retrieve (0-60, default: 0)
|
|
294
|
+
* @returns true if request was sent successfully, false otherwise
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* // Request current global stats (no history)
|
|
299
|
+
* await statsManager.requestGlobalStats(0);
|
|
300
|
+
*
|
|
301
|
+
* // Request with 7 days of history for trends
|
|
302
|
+
* await statsManager.requestGlobalStats(7);
|
|
303
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
304
|
+
*
|
|
305
|
+
* const totalKills = await statsManager.getGlobalStatInt('total_kills');
|
|
306
|
+
* console.log(`All players combined: ${totalKills} kills`);
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @remarks
|
|
310
|
+
* - Must be called before getting global stats
|
|
311
|
+
* - Returns true immediately if request was sent (not when data arrives)
|
|
312
|
+
* - Wait 50-100ms after requesting before reading stats
|
|
313
|
+
* - historyDays is automatically clamped to 0-60 range
|
|
314
|
+
* - Historical data allows tracking trends over time
|
|
113
315
|
*
|
|
114
316
|
* Steamworks SDK Functions:
|
|
115
|
-
* - `SteamAPI_ISteamUserStats_RequestGlobalStats()` - Request global stats from Steam
|
|
317
|
+
* - `SteamAPI_ISteamUserStats_RequestGlobalStats()` - Request global stats from Steam servers
|
|
116
318
|
*/
|
|
117
319
|
requestGlobalStats(historyDays?: number): Promise<boolean>;
|
|
118
320
|
/**
|
|
119
|
-
* Get a global stat value (
|
|
120
|
-
*
|
|
321
|
+
* Get a global stat value (64-bit integer)
|
|
322
|
+
*
|
|
323
|
+
* Retrieves an aggregated integer stat value across all players.
|
|
324
|
+
* Must call requestGlobalStats() first and wait for the data to arrive.
|
|
121
325
|
*
|
|
122
326
|
* @param statName - Name of the global stat to retrieve
|
|
123
|
-
* @returns The stat value, or null if not found
|
|
327
|
+
* @returns The stat value as BigInt, or null if not found or on error
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```typescript
|
|
331
|
+
* // Get total kills across all players
|
|
332
|
+
* await statsManager.requestGlobalStats();
|
|
333
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
334
|
+
*
|
|
335
|
+
* const globalKills = await statsManager.getGlobalStatInt('total_kills');
|
|
336
|
+
* if (globalKills !== null) {
|
|
337
|
+
* console.log(`All players have ${globalKills} total kills`);
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @remarks
|
|
342
|
+
* - Returns BigInt for large numbers (can exceed JavaScript's safe integer range)
|
|
343
|
+
* - Must call requestGlobalStats() first
|
|
344
|
+
* - Wait 50-100ms after requesting before calling this
|
|
345
|
+
* - Useful for tracking game-wide statistics
|
|
124
346
|
*
|
|
125
347
|
* Steamworks SDK Functions:
|
|
126
348
|
* - `SteamAPI_ISteamUserStats_GetGlobalStatInt64()` - Get global int64 stat value
|
|
127
349
|
*/
|
|
128
350
|
getGlobalStatInt(statName: string): Promise<bigint | null>;
|
|
129
351
|
/**
|
|
130
|
-
* Get a global stat value (double)
|
|
131
|
-
*
|
|
352
|
+
* Get a global stat value (double-precision float)
|
|
353
|
+
*
|
|
354
|
+
* Retrieves an aggregated floating-point stat value across all players.
|
|
355
|
+
* Must call requestGlobalStats() first and wait for the data to arrive.
|
|
356
|
+
* Use this for averages or stats requiring decimal precision.
|
|
132
357
|
*
|
|
133
358
|
* @param statName - Name of the global stat to retrieve
|
|
134
|
-
* @returns The stat value, or null if not found
|
|
359
|
+
* @returns The stat value, or null if not found or on error
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* // Get average accuracy across all players
|
|
364
|
+
* await statsManager.requestGlobalStats();
|
|
365
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
366
|
+
*
|
|
367
|
+
* const avgAccuracy = await statsManager.getGlobalStatDouble('average_accuracy');
|
|
368
|
+
* if (avgAccuracy !== null) {
|
|
369
|
+
* console.log(`Global average accuracy: ${(avgAccuracy * 100).toFixed(2)}%`);
|
|
370
|
+
* }
|
|
371
|
+
* ```
|
|
372
|
+
*
|
|
373
|
+
* @remarks
|
|
374
|
+
* - Use for stats requiring decimal precision
|
|
375
|
+
* - Must call requestGlobalStats() first
|
|
376
|
+
* - Wait 50-100ms after requesting before calling this
|
|
377
|
+
* - Perfect for calculating game-wide averages
|
|
135
378
|
*
|
|
136
379
|
* Steamworks SDK Functions:
|
|
137
380
|
* - `SteamAPI_ISteamUserStats_GetGlobalStatDouble()` - Get global double stat value
|
|
138
381
|
*/
|
|
139
382
|
getGlobalStatDouble(statName: string): Promise<number | null>;
|
|
140
383
|
/**
|
|
141
|
-
* Get global stat history
|
|
142
|
-
*
|
|
384
|
+
* Get global stat history for an integer stat
|
|
385
|
+
*
|
|
386
|
+
* Retrieves historical daily values for a global stat. Array index [0] is today,
|
|
387
|
+
* [1] is yesterday, etc. Useful for tracking trends and creating graphs.
|
|
143
388
|
*
|
|
144
389
|
* @param statName - Name of the global stat
|
|
145
|
-
* @param days - Number of days of history to retrieve (
|
|
146
|
-
* @returns Array of daily values, or null if error
|
|
390
|
+
* @param days - Number of days of history to retrieve (1-60, default: 7)
|
|
391
|
+
* @returns Array of daily BigInt values, or null if error
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* // Get 7 days of global kill history
|
|
396
|
+
* await statsManager.requestGlobalStats(7);
|
|
397
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
398
|
+
*
|
|
399
|
+
* const history = await statsManager.getGlobalStatHistoryInt('total_kills', 7);
|
|
400
|
+
* if (history) {
|
|
401
|
+
* console.log('Kill history (newest to oldest):');
|
|
402
|
+
* history.forEach((kills, index) => {
|
|
403
|
+
* const daysAgo = index === 0 ? 'today' : `${index} days ago`;
|
|
404
|
+
* console.log(` ${daysAgo}: ${kills} kills`);
|
|
405
|
+
* });
|
|
406
|
+
* }
|
|
407
|
+
* ```
|
|
408
|
+
*
|
|
409
|
+
* @remarks
|
|
410
|
+
* - Array index [0] = today, [1] = yesterday, etc.
|
|
411
|
+
* - Must call requestGlobalStats(days) first with same or greater number of days
|
|
412
|
+
* - Returns BigInt values for large numbers
|
|
413
|
+
* - Maximum 60 days of history (automatically clamped)
|
|
414
|
+
* - Perfect for trend analysis and visualizations
|
|
147
415
|
*
|
|
148
416
|
* Steamworks SDK Functions:
|
|
149
|
-
* - `SteamAPI_ISteamUserStats_GetGlobalStatHistoryInt64()` - Get
|
|
417
|
+
* - `SteamAPI_ISteamUserStats_GetGlobalStatHistoryInt64()` - Get historical int64 values
|
|
150
418
|
*/
|
|
151
419
|
getGlobalStatHistoryInt(statName: string, days?: number): Promise<bigint[] | null>;
|
|
152
420
|
/**
|
|
153
|
-
* Get global stat history
|
|
154
|
-
*
|
|
421
|
+
* Get global stat history for a floating-point stat
|
|
422
|
+
*
|
|
423
|
+
* Retrieves historical daily values for a global stat with decimal precision.
|
|
424
|
+
* Array index [0] is today, [1] is yesterday, etc. Ideal for tracking averages
|
|
425
|
+
* and rates over time.
|
|
155
426
|
*
|
|
156
427
|
* @param statName - Name of the global stat
|
|
157
|
-
* @param days - Number of days of history to retrieve (
|
|
158
|
-
* @returns Array of daily values, or null if error
|
|
428
|
+
* @param days - Number of days of history to retrieve (1-60, default: 7)
|
|
429
|
+
* @returns Array of daily float values, or null if error
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* // Track average accuracy trend over 30 days
|
|
434
|
+
* await statsManager.requestGlobalStats(30);
|
|
435
|
+
* await new Promise(resolve => setTimeout(resolve, 100));
|
|
436
|
+
*
|
|
437
|
+
* const history = await statsManager.getGlobalStatHistoryDouble('average_accuracy', 30);
|
|
438
|
+
* if (history) {
|
|
439
|
+
* console.log('Accuracy trend:');
|
|
440
|
+
* history.forEach((accuracy, index) => {
|
|
441
|
+
* if (index % 7 === 0) { // Weekly intervals
|
|
442
|
+
* console.log(` Week ${index/7}: ${(accuracy * 100).toFixed(2)}%`);
|
|
443
|
+
* }
|
|
444
|
+
* });
|
|
445
|
+
* }
|
|
446
|
+
* ```
|
|
447
|
+
*
|
|
448
|
+
* @remarks
|
|
449
|
+
* - Array index [0] = today, [1] = yesterday, etc.
|
|
450
|
+
* - Must call requestGlobalStats(days) first with same or greater number of days
|
|
451
|
+
* - Returns floating-point values for decimal precision
|
|
452
|
+
* - Maximum 60 days of history (automatically clamped)
|
|
453
|
+
* - Perfect for tracking averages, rates, and percentages over time
|
|
159
454
|
*
|
|
160
455
|
* Steamworks SDK Functions:
|
|
161
|
-
* - `SteamAPI_ISteamUserStats_GetGlobalStatHistoryDouble()` - Get
|
|
456
|
+
* - `SteamAPI_ISteamUserStats_GetGlobalStatHistoryDouble()` - Get historical double values
|
|
162
457
|
*/
|
|
163
458
|
getGlobalStatHistoryDouble(statName: string, days?: number): Promise<number[] | null>;
|
|
164
459
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SteamStatsManager.d.ts","sourceRoot":"","sources":["../../src/internal/SteamStatsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C
|
|
1
|
+
{"version":3,"file":"SteamStatsManager.d.ts","sourceRoot":"","sources":["../../src/internal/SteamStatsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,iBAAiB;IAC5B,kDAAkD;IAClD,OAAO,CAAC,aAAa,CAAqB;IAE1C,gEAAgE;IAChE,OAAO,CAAC,OAAO,CAAe;IAE9B;;;;;OAKG;gBACS,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,YAAY;IASpE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,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