Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pack pass check considering converted plays when pack is not associated with a ruleset #277

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,47 @@ public void TestPackMedalsDoNotIncludePreviousFails(int medalId, int packId)
AssertNoMedalsAwarded();
}

[Theory]
[MemberData(nameof(MEDAL_PACK_IDS))]
public void TestConvertsNotAllowedForPackMedals(int medalId, int packId)
{
var firstBeatmap = AddBeatmap(b =>
{
b.beatmap_id = 1234;
b.playmode = 0;
}, s => s.beatmapset_id = 4321);
var secondBeatmap = AddBeatmap(b =>
{
b.beatmap_id = 5678;
b.playmode = 0;
}, s => s.beatmapset_id = 8765);

AddPackMedal(medalId, packId, [firstBeatmap, secondBeatmap]);
setUpBeatmapsForPackMedal([firstBeatmap, secondBeatmap]);

AssertNoMedalsAwarded();

SetScoreForBeatmap(firstBeatmap.beatmap_id, s =>
{
s.Score.passed = true;
s.Score.preserve = true;
s.Score.build_id = TestBuildID;
s.Score.ruleset_id = 3;
s.Score.pp = 10;
});
AssertNoMedalsAwarded();

SetScoreForBeatmap(secondBeatmap.beatmap_id, s =>
{
s.Score.passed = true;
s.Score.preserve = true;
s.Score.build_id = TestBuildID;
s.Score.ruleset_id = 0;
s.Score.pp = 10;
});
AssertNoMedalsAwarded();
}

/// <summary>
/// This tests the simplest case of a medal being awarded for completing a pack.
/// This mimics the "video game" pack, but is intended to test the process rather than the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static bool IsPermittedInNoModContext(Mod m)
public static bool UserPassedPack(MedalAwarderContext context, bool noReductionMods, int packId)
{
string modsCriteria = string.Empty;
string rulesetCriteria = string.Empty;
string rulesetCriteria;

if (noReductionMods)
{
Expand All @@ -83,6 +83,10 @@ public static bool UserPassedPack(MedalAwarderContext context, bool noReductionM

rulesetCriteria = $"AND ruleset_id = {packRulesetId}";
}
else
{
rulesetCriteria = "AND `s`.`ruleset_id` = `b`.`playmode`";
}

// TODO: no index on (beatmap_id, user_id) may mean this is too slow.
// note that the `preserve = 1` condition relies on the flag being set before score processing (https://github.com/ppy/osu-web/pull/10946).
Expand Down