Added Friend.RequestUserStats()

This commit is contained in:
Garry Newman 2020-02-24 12:00:13 +00:00
parent 86a8f80584
commit 18fbabaf2c
2 changed files with 35 additions and 0 deletions

View File

@ -168,6 +168,30 @@ public void GetStatInt()
Assert.AreNotEqual( 0, deaths.GetInt() );
}
[TestMethod]
public async Task GetFriendStats()
{
var friend = new Friend( 76561197965732579 ); // Hezzy
// Download stats
var status = await friend.RequestUserStats();
Assert.AreNotEqual( false, status );
var deaths = friend.GetStatInt( "deaths" );
Console.WriteLine( $"Hezzy has died {deaths} times" );
Assert.AreNotEqual( 0, deaths );
var unlocked = friend.GetAchievement( "COLLECT_100_WOOD" );
Assert.AreNotEqual( false, unlocked );
var when = friend.GetAchievementUnlockTime( "COLLECT_100_WOOD" );
Assert.AreNotEqual( when, DateTime.MinValue );
Console.WriteLine( $"Hezzy unlocked COLLECT_100_WOOD {when}" );
}
[TestMethod]
public async Task GetStatGlobalInt()
{

View File

@ -184,5 +184,16 @@ public bool SendMessage( string message )
return SteamFriends.Internal.ReplyToFriendMessage( Id, message );
}
/// <summary>
/// Tries to get download the latest user stats
/// </summary>
/// <returns>True if successful, False if failure</returns>
public async Task<bool> RequestUserStats()
{
var result = await SteamUserStats.Internal.RequestUserStats( Id );
return result.HasValue && result.Value.Result == Result.OK;
}
}
}