55using System . Linq ;
66using System . Text ;
77using System . Threading . Tasks ;
8+ using SteamWebAPI2 . Models . Utilities ;
89
910namespace SteamWebAPI2
1011{
@@ -22,11 +23,26 @@ public async Task<IReadOnlyCollection<GlobalAchievementPercentage>> GetGlobalAch
2223 return new ReadOnlyCollection < GlobalAchievementPercentage > ( achievementPercentagesResult . Result . AchievementPercentages ) ;
2324 }
2425
25- public async Task < GlobalStatsForGameResult > GetGlobalStatsForGameAsync ( long appId , IReadOnlyList < string > statNames )
26+ public async Task < GlobalStatsForGameResult > GetGlobalStatsForGameAsync ( long appId , IReadOnlyList < string > statNames , DateTime ? startDate = null , DateTime ? endDate = null )
2627 {
28+ long ? startDateUnixTimeStamp = null ;
29+ long ? endDateUnixTimeStamp = null ;
30+
31+ if ( startDate . HasValue )
32+ {
33+ startDateUnixTimeStamp = startDate . Value . ToUnixTimeStamp ( ) ;
34+ }
35+
36+ if ( endDate . HasValue )
37+ {
38+ endDateUnixTimeStamp = endDate . Value . ToUnixTimeStamp ( ) ;
39+ }
40+
2741 List < SteamWebRequestParameter > parameters = new List < SteamWebRequestParameter > ( ) ;
2842 AddToParametersIfHasValue ( "appid" , appId , parameters ) ;
2943 AddToParametersIfHasValue ( "count" , statNames . Count , parameters ) ;
44+ AddToParametersIfHasValue ( "startdate" , startDateUnixTimeStamp , parameters ) ;
45+ AddToParametersIfHasValue ( "enddate" , endDateUnixTimeStamp , parameters ) ;
3046
3147 for ( int i = 0 ; i < statNames . Count ; i ++ )
3248 {
@@ -36,5 +52,13 @@ public async Task<GlobalStatsForGameResult> GetGlobalStatsForGameAsync(long appI
3652 var globalStatsResult = await CallMethodAsync < GlobalStatsForGameResultContainer > ( "GetGlobalStatsForGame" , 1 , parameters ) ;
3753 return globalStatsResult . Result ;
3854 }
55+
56+ public async Task < int > GetNumberOfCurrentPlayersForGameAsync ( long appId )
57+ {
58+ List < SteamWebRequestParameter > parameters = new List < SteamWebRequestParameter > ( ) ;
59+ AddToParametersIfHasValue ( "appid" , appId , parameters ) ;
60+ var globalStatsResult = await CallMethodAsync < CurrentPlayersResultContainer > ( "GetNumberOfCurrentPlayers" , 1 , parameters ) ;
61+ return globalStatsResult . Result . PlayerCount ;
62+ }
3963 }
4064}
0 commit comments