Skip to content

Commit

Permalink
Fix flooring causing delta to not work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Aug 22, 2024
1 parent 610ebc5 commit 67f0ea5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void TestStates()
public void TestTransientUserStatisticsDisplay()
{
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));

AddStep("Gain", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
Expand All @@ -113,6 +114,7 @@ public void TestTransientUserStatisticsDisplay()
PP = 1357
});
});

AddStep("Loss", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
Expand All @@ -129,22 +131,42 @@ public void TestTransientUserStatisticsDisplay()
PP = 1234
});
});
AddStep("No change", () =>

// Tests flooring logic works as expected.
AddStep("Tiny increase in PP", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357
PP = 1357.6m
},
new UserStatistics
{
GlobalRank = 111_111,
PP = 1358.1m
});
});

AddStep("No change 1", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357m
},
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357.1m
});
});

AddStep("Was null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
Expand All @@ -161,6 +183,7 @@ public void TestTransientUserStatisticsDisplay()
PP = 1357
});
});

AddStep("Became null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override void LoadComplete()
}

if (update.After.PP != null)
pp.Display((int)(update.Before.PP ?? update.After.PP.Value), (int)Math.Abs((update.After.PP - update.Before.PP) ?? 0M), (int)update.After.PP.Value);
pp.Display((int)(update.Before.PP ?? update.After.PP.Value), (int)Math.Abs(((int?)update.After.PP - (int?)update.Before.PP) ?? 0M), (int)update.After.PP.Value);

this.Delay(5000).FadeOut(500, Easing.OutQuint);
});
Expand Down

0 comments on commit 67f0ea5

Please sign in to comment.