-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #308 from bdach/medals-2024
Add new medals
- Loading branch information
Showing
11 changed files
with
333 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
osu.Server.Queues.ScoreStatisticsProcessor.Tests/DailySproutTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Dapper; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
using Xunit; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Tests | ||
{ | ||
public class DailySproutTest : MedalAwarderTest | ||
{ | ||
private readonly Beatmap beatmap; | ||
|
||
public DailySproutTest() | ||
{ | ||
beatmap = AddBeatmap(); | ||
AddMedal(336); | ||
} | ||
|
||
[Fact] | ||
public void MedalNotAwardedIfNoDailyChallengesOnRecord() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id); | ||
AssertNoMedalsAwarded(); | ||
} | ||
|
||
[Fact] | ||
public void MedalAwardedIfAtLeastOneDailyChallengeOnRecord() | ||
{ | ||
using (var db = Processor.GetDatabaseConnection()) | ||
db.Execute("INSERT INTO `daily_challenge_user_stats` (`user_id`, `daily_streak_best`) VALUES (2, 1)"); | ||
SetScoreForBeatmap(beatmap.beatmap_id); | ||
AssertSingleMedalAwarded(336); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
osu.Server.Queues.ScoreStatisticsProcessor.Tests/GameNightTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Online.API; | ||
using osu.Game.Rulesets.Osu.Mods; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
using Xunit; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Tests | ||
{ | ||
public class GameNightTest : MedalAwarderTest | ||
{ | ||
private readonly Beatmap beatmap; | ||
|
||
public GameNightTest() | ||
{ | ||
AddMedal(340); | ||
beatmap = AddBeatmap(); | ||
} | ||
|
||
[Fact] | ||
public void TestMedalAwarded() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id, s => s.Score.ScoreData.Mods = [new APIMod(new OsuModBubbles())]); | ||
AssertSingleMedalAwarded(340); | ||
} | ||
|
||
[Fact] | ||
public void TestMedalAwardedWithExtraMods() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id, s => s.Score.ScoreData.Mods = [new APIMod(new OsuModBubbles()), new APIMod(new OsuModClassic())]); | ||
AssertSingleMedalAwarded(340); | ||
} | ||
|
||
[Fact] | ||
public void TestMedalNotAwardedIfFunModsMissing() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id, s => s.Score.ScoreData.Mods = [new APIMod(new OsuModClassic())]); | ||
AssertNoMedalsAwarded(); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
osu.Server.Queues.ScoreStatisticsProcessor.Tests/GearShiftTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Online.API; | ||
using osu.Game.Rulesets.Osu.Mods; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
using Xunit; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Tests | ||
{ | ||
public class GearShiftTest : MedalAwarderTest | ||
{ | ||
private readonly Beatmap beatmap; | ||
|
||
public GearShiftTest() | ||
{ | ||
AddMedal(339); | ||
beatmap = AddBeatmap(); | ||
} | ||
|
||
[Fact] | ||
public void TestMedalAwarded() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id, s => s.Score.ScoreData.Mods = [new APIMod(new OsuModAlternate())]); | ||
AssertMedalAwarded(339); | ||
} | ||
|
||
[Fact] | ||
public void TestMedalAwardedWithExtraMods() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id, s => s.Score.ScoreData.Mods = [new APIMod(new OsuModAlternate()), new APIMod(new OsuModDoubleTime())]); | ||
AssertMedalAwarded(339); | ||
} | ||
|
||
[Fact] | ||
public void TestMedalNotAwardedIfConversionModsMissing() | ||
{ | ||
SetScoreForBeatmap(beatmap.beatmap_id, s => s.Score.ScoreData.Mods = [new APIMod(new OsuModFreezeFrame())]); | ||
AssertNoMedalsAwarded(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
osu.Server.Queues.ScoreStatisticsProcessor.Tests/MonthlyShrubTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Dapper; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
using Xunit; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Tests | ||
{ | ||
public class MonthlyShrubTest : MedalAwarderTest | ||
{ | ||
private readonly Beatmap beatmap; | ||
|
||
public MonthlyShrubTest() | ||
{ | ||
beatmap = AddBeatmap(); | ||
AddMedal(338); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(9)] | ||
[InlineData(26)] | ||
public void MedalNotAwardedIfNotEnoughDailyChallengesOnRecord(int dailyChallengeCount) | ||
{ | ||
using (var db = Processor.GetDatabaseConnection()) | ||
db.Execute($"INSERT INTO `daily_challenge_user_stats` (`user_id`, `daily_streak_best`) VALUES (2, {dailyChallengeCount})"); | ||
SetScoreForBeatmap(beatmap.beatmap_id); | ||
AssertNoMedalsAwarded(); | ||
} | ||
|
||
[Fact] | ||
public void MedalAwardedIfAtLeastThirtyDailyChallengesOnRecord() | ||
{ | ||
using (var db = Processor.GetDatabaseConnection()) | ||
db.Execute("INSERT INTO `daily_challenge_user_stats` (`user_id`, `daily_streak_best`) VALUES (2, 30)"); | ||
SetScoreForBeatmap(beatmap.beatmap_id); | ||
AssertSingleMedalAwarded(338); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
osu.Server.Queues.ScoreStatisticsProcessor.Tests/WeeklySaplingTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using Dapper; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
using Xunit; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Tests | ||
{ | ||
public class WeeklySaplingTest : MedalAwarderTest | ||
{ | ||
private readonly Beatmap beatmap; | ||
|
||
public WeeklySaplingTest() | ||
{ | ||
beatmap = AddBeatmap(); | ||
AddMedal(337); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(4)] | ||
[InlineData(6)] | ||
public void MedalNotAwardedIfNotEnoughDailyChallengesOnRecord(int dailyChallengeCount) | ||
{ | ||
using (var db = Processor.GetDatabaseConnection()) | ||
db.Execute($"INSERT INTO `daily_challenge_user_stats` (`user_id`, `daily_streak_best`) VALUES (2, {dailyChallengeCount})"); | ||
SetScoreForBeatmap(beatmap.beatmap_id); | ||
AssertNoMedalsAwarded(); | ||
} | ||
|
||
[Fact] | ||
public void MedalAwardedIfAtLeastSevenDailyChallengesOnRecord() | ||
{ | ||
using (var db = Processor.GetDatabaseConnection()) | ||
db.Execute("INSERT INTO `daily_challenge_user_stats` (`user_id`, `daily_streak_best`) VALUES (2, 7)"); | ||
SetScoreForBeatmap(beatmap.beatmap_id); | ||
AssertSingleMedalAwarded(337); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
osu.Server.Queues.ScoreStatisticsProcessor/Models/DailyChallengeUserStats.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Dapper.Contrib.Extensions; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Models | ||
{ | ||
[SuppressMessage("ReSharper", "InconsistentNaming")] | ||
[Serializable] | ||
[Table("daily_challenge_user_stats")] | ||
public record DailyChallengeUserStats | ||
{ | ||
public uint daily_streak_current { get; set; } | ||
public uint daily_streak_best { get; set; } | ||
public uint playcount { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...er.Queues.ScoreStatisticsProcessor/Processors/MedalAwarders/DailyChallengeMedalAwarder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Processors.MedalAwarders | ||
{ | ||
[UsedImplicitly] | ||
public class DailyChallengeMedalAwarder : IMedalAwarder | ||
{ | ||
public bool RunOnFailedScores => false; | ||
public bool RunOnLegacyScores => false; | ||
|
||
public IEnumerable<Medal> Check(IEnumerable<Medal> medals, MedalAwarderContext context) | ||
{ | ||
foreach (var medal in medals) | ||
{ | ||
switch (medal.achievement_id) | ||
{ | ||
case 336: | ||
{ | ||
if (context.DailyChallengeUserStats.daily_streak_best >= 1) | ||
yield return medal; | ||
|
||
break; | ||
} | ||
|
||
case 337: | ||
{ | ||
if (context.DailyChallengeUserStats.daily_streak_best >= 7) | ||
yield return medal; | ||
|
||
break; | ||
} | ||
|
||
case 338: | ||
{ | ||
if (context.DailyChallengeUserStats.daily_streak_best >= 30) | ||
yield return medal; | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ues.ScoreStatisticsProcessor/Processors/MedalAwarders/LazerModIntroductionMedalAwarder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using JetBrains.Annotations; | ||
using osu.Game.Rulesets; | ||
using osu.Game.Rulesets.Mods; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Helpers; | ||
using osu.Server.Queues.ScoreStatisticsProcessor.Models; | ||
|
||
namespace osu.Server.Queues.ScoreStatisticsProcessor.Processors.MedalAwarders | ||
{ | ||
[UsedImplicitly] | ||
public class LazerModIntroductionMedalAwarder : IMedalAwarder | ||
{ | ||
public bool RunOnFailedScores => false; | ||
public bool RunOnLegacyScores => false; | ||
|
||
public IEnumerable<Medal> Check(IEnumerable<Medal> medals, MedalAwarderContext context) | ||
{ | ||
Ruleset ruleset = LegacyRulesetHelper.GetRulesetFromLegacyId(context.Score.ruleset_id); | ||
Mod[] mods = context.Score.ScoreData.Mods.Select(m => m.ToMod(ruleset)).ToArray(); | ||
|
||
foreach (var medal in medals) | ||
{ | ||
switch (medal.achievement_id) | ||
{ | ||
// Gear Shift | ||
case 339: | ||
{ | ||
if (mods.Any(m => m.Type == ModType.Conversion)) | ||
yield return medal; | ||
|
||
break; | ||
} | ||
|
||
// Game Night | ||
case 340: | ||
{ | ||
if (mods.Any(m => m.Type == ModType.Fun)) | ||
yield return medal; | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters