Skip to content

Commit

Permalink
Able to get stats and achieve changes when all stats are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyTarget committed Apr 14, 2015
1 parent 4d89d22 commit a158eb8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions PollingEngine/Implementations/SteamPoller/SteamPoller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private async Task Steam_OnSessionEnded(GamingSessionEventArgs e)

try
{
if (_gamestatsBefore == null || _gamestatsBefore.Stats == null || !_gamestatsBefore.Stats.Any())
if (_gamestatsBefore == null)
{
Console.WriteLine("Missing game stats before game session, ignoring stats after");
}
Expand Down Expand Up @@ -267,11 +267,11 @@ private async Task Steam_OnSessionEnded(GamingSessionEventArgs e)
{
var diffs = _gamestatsAfter.Stats != null
? _gamestatsAfter.Stats
.Where(x => _gamestatsBefore.Stats.Any(y => y.Name == x.Name))
.Where(x => x.Value != _gamestatsBefore.Stats.First(y => y.Name == x.Name).Value)
//.Where(x => _gamestatsBefore.Stats.Any(y => y.Name == x.Name))
.Where(x => x.Value != _gamestatsBefore.Stats.Where(y => y.Name == x.Name).Select(y => y.Value).FirstOrDefault())
.Select(x => new StatDiff
{
Pre = _gamestatsBefore.Stats.First(y => y.Name == x.Name),
Pre = _gamestatsBefore.Stats.FirstOrDefault(y => y.Name == x.Name),
Post = x
})
.OrderByDescending(x => x.PercentualDiff)
Expand Down Expand Up @@ -434,7 +434,8 @@ public double Differance
{
get
{
var diff = Post.Value - (double)Pre.Value;
var pre = Pre != null ? (double) Pre.Value : 0;
var diff = Post.Value - pre;
return diff;
}
}
Expand All @@ -452,7 +453,7 @@ public double PercentualDiff

public override string ToString()
{
var res = string.Format("{0}: {1} => {2} = {3} ({4:p2})", Post.Name, Pre.Value, Post.Value, Differance, PercentualDiff);
var res = string.Format("{0}: {1} => {2} = {3} ({4:p2})", Post.Name, Pre != null ? Pre.Value : 0, Post.Value, Differance, PercentualDiff);
return res;
}
}
Expand Down

0 comments on commit a158eb8

Please sign in to comment.