Skip to content

Commit

Permalink
Merge pull request #30906 from Hiviexd/daily-challenge-tier-thresholds
Browse files Browse the repository at this point in the history
Adjust daily challenge tier thresholds to match expectations
  • Loading branch information
frenzibyte authored Nov 28, 2024
2 parents d0e80ce + 51bcde6 commit f664e97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void LoadComplete()
AddSliderStep("weekly best", 0, 250, 1, v => update(s => s.WeeklyStreakBest = v));
AddSliderStep("top 10%", 0, 999, 0, v => update(s => s.Top10PercentPlacements = v));
AddSliderStep("top 50%", 0, 999, 0, v => update(s => s.Top50PercentPlacements = v));
AddSliderStep("playcount", 0, 999, 0, v => update(s => s.PlayCount = v));
AddSliderStep("playcount", 0, 1500, 1, v => update(s => s.PlayCount = v));
AddStep("create", () =>
{
Clear();
Expand Down Expand Up @@ -66,8 +66,8 @@ private void update(Action<APIUserDailyChallengeStatistics> change)
[Test]
public void TestPlayCountRankingTier()
{
AddAssert("1 before silver", () => DailyChallengeStatsTooltip.TierForPlayCount(30) == RankingTier.Bronze);
AddAssert("first silver", () => DailyChallengeStatsTooltip.TierForPlayCount(31) == RankingTier.Silver);
AddAssert("1 before silver", () => DailyChallengeStatsTooltip.TierForPlayCount(29) == RankingTier.Bronze);
AddAssert("first silver", () => DailyChallengeStatsTooltip.TierForPlayCount(30) == RankingTier.Silver);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,34 +138,31 @@ public void SetContent(DailyChallengeTooltipData content)
topFifty.ValueColour = colourProvider.Content2;
}

// reference: https://github.com/ppy/osu-web/blob/adf1e94754ba9625b85eba795f4a310caf169eec/resources/js/profile-page/daily-challenge.tsx#L13-L47
// reference: https://github.com/ppy/osu-web/blob/a97f156014e00ea1aa315140da60542e798a9f06/resources/js/profile-page/daily-challenge.tsx#L13-L47

// Rounding up is needed here to ensure the overlay shows the same colour as osu-web for the play count.
// This is because, for example, 31 / 3 > 10 in JavaScript because floats are used, while here it would
// get truncated to 10 with an integer division and show a lower tier.
public static RankingTier TierForPlayCount(int playCount) => TierForDaily((int)Math.Ceiling(playCount / 3.0d));
public static RankingTier TierForPlayCount(int playCount) => TierForDaily((int)Math.Floor(playCount / 3.0d));

public static RankingTier TierForDaily(int daily)
{
if (daily > 360)
if (daily >= 360)
return RankingTier.Lustrous;

if (daily > 240)
if (daily >= 240)
return RankingTier.Radiant;

if (daily > 120)
if (daily >= 120)
return RankingTier.Rhodium;

if (daily > 60)
if (daily >= 60)
return RankingTier.Platinum;

if (daily > 30)
if (daily >= 30)
return RankingTier.Gold;

if (daily > 10)
if (daily >= 10)
return RankingTier.Silver;

if (daily > 5)
if (daily >= 5)
return RankingTier.Bronze;

return RankingTier.Iron;
Expand Down

0 comments on commit f664e97

Please sign in to comment.