Skip to content

Commit

Permalink
Merge pull request #277 from bdach/fix-non-ruleset-packs-including-co…
Browse files Browse the repository at this point in the history
…nverts

Fix pack pass check considering converted plays when pack is not associated with a ruleset
  • Loading branch information
peppy authored Sep 9, 2024
2 parents 9482429 + 6b66e9e commit ff7f268
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
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

0 comments on commit ff7f268

Please sign in to comment.