1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 12:47:23 +08:00

Apply mods to processor-based score algorithms

This commit is contained in:
Bartłomiej Dach 2023-09-26 08:20:09 +02:00
parent 55064c387d
commit 419cc8784a
No known key found for this signature in database
5 changed files with 31 additions and 15 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
@ -10,6 +11,7 @@ using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Scoring;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Tests.Visual.Gameplay;
@ -41,7 +43,8 @@ namespace osu.Game.Rulesets.Catch.Tests
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode) => new CatchProcessorBasedScoringAlgorithm(beatmap, mode);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
=> new CatchProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
[Test]
public void TestBasicScenarios()
@ -140,8 +143,8 @@ namespace osu.Game.Rulesets.Catch.Tests
private class CatchProcessorBasedScoringAlgorithm : ProcessorBasedScoringAlgorithm
{
public CatchProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode)
: base(beatmap, mode)
public CatchProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
: base(beatmap, mode, selectedMods)
{
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
@ -9,6 +10,7 @@ using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Judgements;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Tests.Visual.Gameplay;
@ -27,7 +29,9 @@ namespace osu.Game.Rulesets.Mania.Tests
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1(MaxCombo.Value);
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode) => new ManiaProcessorBasedScoringAlgorithm(beatmap, mode);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
=> new ManiaProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
[Test]
public void TestBasicScenarios()
@ -158,8 +162,8 @@ namespace osu.Game.Rulesets.Mania.Tests
private class ManiaProcessorBasedScoringAlgorithm : ProcessorBasedScoringAlgorithm
{
public ManiaProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode)
: base(beatmap, mode)
public ManiaProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
: base(beatmap, mode, selectedMods)
{
}

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Objects;
@ -34,7 +36,9 @@ namespace osu.Game.Rulesets.Osu.Tests
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1 { ScoreMultiplier = { BindTarget = scoreMultiplier } };
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode) => new OsuProcessorBasedScoringAlgorithm(beatmap, mode);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> mods)
=> new OsuProcessorBasedScoringAlgorithm(beatmap, mode, mods);
[Test]
public void TestBasicScenarios()
@ -162,8 +166,8 @@ namespace osu.Game.Rulesets.Osu.Tests
private class OsuProcessorBasedScoringAlgorithm : ProcessorBasedScoringAlgorithm
{
public OsuProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode)
: base(beatmap, mode)
public OsuProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
: base(beatmap, mode, selectedMods)
{
}

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Beatmaps;
using osu.Game.Rulesets.Taiko.Judgements;
@ -35,7 +37,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
protected override IScoringAlgorithm CreateScoreV1() => new ScoreV1 { ScoreMultiplier = { BindTarget = scoreMultiplier } };
protected override IScoringAlgorithm CreateScoreV2(int maxCombo) => new ScoreV2(maxCombo);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode) => new TaikoProcessorBasedScoringAlgorithm(beatmap, mode);
protected override ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
=> new TaikoProcessorBasedScoringAlgorithm(beatmap, mode, selectedMods);
[Test]
public void TestBasicScenarios()
@ -171,8 +174,8 @@ namespace osu.Game.Rulesets.Taiko.Tests
private class TaikoProcessorBasedScoringAlgorithm : ProcessorBasedScoringAlgorithm
{
public TaikoProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode)
: base(beatmap, mode)
public TaikoProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
: base(beatmap, mode, selectedMods)
{
}

View File

@ -23,6 +23,7 @@ using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring.Legacy;
using osuTK;
@ -37,7 +38,7 @@ namespace osu.Game.Tests.Visual.Gameplay
protected abstract IScoringAlgorithm CreateScoreV1();
protected abstract IScoringAlgorithm CreateScoreV2(int maxCombo);
protected abstract ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode);
protected abstract ProcessorBasedScoringAlgorithm CreateScoreAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> mods);
protected Bindable<int> MaxCombo => sliderMaxCombo.Current;
protected BindableList<double> NonPerfectLocations => graphs.NonPerfectLocations;
@ -270,7 +271,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
int maxCombo = sliderMaxCombo.Current.Value;
var beatmap = CreateBeatmap(maxCombo);
var algorithm = CreateScoreAlgorithm(beatmap, scoringMode);
var algorithm = CreateScoreAlgorithm(beatmap, scoringMode, SelectedMods.Value);
runForAlgorithm(new ScoringAlgorithmInfo
{
@ -343,11 +344,12 @@ namespace osu.Game.Tests.Visual.Gameplay
private readonly ScoreProcessor scoreProcessor;
private readonly ScoringMode mode;
protected ProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode)
protected ProcessorBasedScoringAlgorithm(IBeatmap beatmap, ScoringMode mode, IReadOnlyList<Mod> selectedMods)
{
this.mode = mode;
scoreProcessor = CreateScoreProcessor();
scoreProcessor.ApplyBeatmap(beatmap);
scoreProcessor.Mods.Value = selectedMods;
}
public void ApplyHit() => scoreProcessor.ApplyResult(CreatePerfectJudgementResult());