-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add difficulty attributes to facilitate conversion from legacy score, and convert existing scores #24072
Merged
Merged
Add difficulty attributes to facilitate conversion from legacy score, and convert existing scores #24072
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
02111e3
Implement ScoreV1 calculation for OsuRuleset
smoogipoo e402c6d
Write max combo attribute from base class
smoogipoo 77c745c
"TotalScoreV1" -> "LegacyTotalScore"
smoogipoo d10c63e
Fix difficulty calculation when mods are involved
smoogipoo 446807e
Add combo score / bonus score attributes
smoogipoo b9f485b
Merge classes + split out
smoogipoo aa64483
Add ScoreV1 calculation for TaikoRuleset
smoogipoo 3ec9712
Add ScoreV1 calculation for CatchRuleset
smoogipoo 13d1f9c
Add ScoreV1 calculation for ManiaRuleset
smoogipoo 0844a21
Merge branch 'master' into diffcalc-total-scorev1
smoogipoo 975e9ba
Fix exception with no matching mods
smoogipoo bfa449e
Adjust attribute data
smoogipoo 87447f4
Fix incorrect calculation of difficulty
smoogipoo 0656587
Add flag to disable computing legacy scoring values
smoogipoo 5fadadc
Merge branch 'master' into diffcalc-total-scorev1
smoogipoo e1d723a
Merge branch 'master' into diffcalc-total-scorev1
smoogipoo 8e79510
Add migration for total score conversion
smoogipoo a9c65d2
Initial conversion of scores
smoogipoo 0c5c095
Store old total score as LegacyTotalScore
smoogipoo 5f350aa
Fix float division
smoogipoo 6e2369e
Add xmldoc on LegacyTotalScore
smoogipoo e291dff
Fix imported scores not getting LegacyTotalScore
smoogipoo 09bc8e4
Refactoring
smoogipoo af25ffb
Remove JSON output
smoogipoo 1ca4e39
Allow legacy scores to be displayed in "classic" scoring mode
smoogipoo 829044d
Revert unintented change
smoogipoo c816281
Make BackgroundBeatmapProcessor task long-running
smoogipoo ddd870e
Make LegacyTotalScore nullable
smoogipoo 6822871
Move population of LegacyTotalScore to ScoreImporter
smoogipoo c6ad184
Move Ruleset method to ILegacyRuleset interface
smoogipoo 426f11b
Apply a few other code reviews
smoogipoo 4203e21
Merge branch 'master' into diffcalc-total-scorev1
peppy 6765083
Remove unnecessary null check
peppy 1a6381b
Reduce code repetition for sleep logic
peppy 3b5f3b6
Tidy up and improve messaging on completion notification
peppy 1629024
`ILegacyScoreProcessor` -> `ILegacyScoreSimulator`
peppy a0c3fa9
Move preconditions to realm migration step to simplify marker version…
peppy 4de15f9
Fix realm silly business
peppy 257a96e
Fix background beatmap processor thread not correctly exiting
peppy 56bfb92
Allow user cancellation
peppy d3eb065
Improve messaging around failed scores
peppy dd99981
Count missing beatmaps as errored items
peppy aee89e5
Rewrite comment regarding `LegacyTotalScore`
peppy f2aa80f
Rename and adjust xmldoc on `TotalScoreVersion`
peppy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
142 changes: 142 additions & 0 deletions
142
osu.Game.Rulesets.Catch/Difficulty/CatchLegacyScoreSimulator.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,142 @@ | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Catch.Objects; | ||
using osu.Game.Rulesets.Judgements; | ||
using osu.Game.Rulesets.Mods; | ||
using osu.Game.Rulesets.Objects; | ||
using osu.Game.Rulesets.Objects.Types; | ||
using osu.Game.Rulesets.Scoring; | ||
|
||
namespace osu.Game.Rulesets.Catch.Difficulty | ||
{ | ||
internal class CatchLegacyScoreSimulator : ILegacyScoreSimulator | ||
{ | ||
public int AccuracyScore { get; private set; } | ||
|
||
public int ComboScore { get; private set; } | ||
|
||
public double BonusScoreRatio => legacyBonusScore == 0 ? 0 : (double)modernBonusScore / legacyBonusScore; | ||
|
||
private int legacyBonusScore; | ||
private int modernBonusScore; | ||
private int combo; | ||
|
||
private double scoreMultiplier; | ||
|
||
public void Simulate(IWorkingBeatmap workingBeatmap, IBeatmap playableBeatmap, IReadOnlyList<Mod> mods) | ||
{ | ||
IBeatmap baseBeatmap = workingBeatmap.Beatmap; | ||
|
||
int countNormal = 0; | ||
int countSlider = 0; | ||
int countSpinner = 0; | ||
|
||
foreach (HitObject obj in baseBeatmap.HitObjects) | ||
{ | ||
switch (obj) | ||
{ | ||
case IHasPath: | ||
countSlider++; | ||
break; | ||
|
||
case IHasDuration: | ||
countSpinner++; | ||
break; | ||
|
||
default: | ||
countNormal++; | ||
break; | ||
} | ||
} | ||
|
||
int objectCount = countNormal + countSlider + countSpinner; | ||
|
||
int drainLength = 0; | ||
|
||
if (baseBeatmap.HitObjects.Count > 0) | ||
{ | ||
int breakLength = baseBeatmap.Breaks.Select(b => (int)Math.Round(b.EndTime) - (int)Math.Round(b.StartTime)).Sum(); | ||
drainLength = ((int)Math.Round(baseBeatmap.HitObjects[^1].StartTime) - (int)Math.Round(baseBeatmap.HitObjects[0].StartTime) - breakLength) / 1000; | ||
} | ||
|
||
int difficultyPeppyStars = (int)Math.Round( | ||
(baseBeatmap.Difficulty.DrainRate | ||
+ baseBeatmap.Difficulty.OverallDifficulty | ||
+ baseBeatmap.Difficulty.CircleSize | ||
+ Math.Clamp((float)objectCount / drainLength * 8, 0, 16)) / 38 * 5); | ||
|
||
scoreMultiplier = difficultyPeppyStars * mods.Aggregate(1.0, (current, mod) => current * mod.ScoreMultiplier); | ||
|
||
foreach (var obj in playableBeatmap.HitObjects) | ||
simulateHit(obj); | ||
} | ||
|
||
private void simulateHit(HitObject hitObject) | ||
{ | ||
bool increaseCombo = true; | ||
bool addScoreComboMultiplier = false; | ||
|
||
bool isBonus = false; | ||
HitResult bonusResult = HitResult.None; | ||
|
||
int scoreIncrease = 0; | ||
|
||
switch (hitObject) | ||
{ | ||
case TinyDroplet: | ||
scoreIncrease = 10; | ||
increaseCombo = false; | ||
break; | ||
|
||
case Droplet: | ||
scoreIncrease = 100; | ||
break; | ||
|
||
case Fruit: | ||
scoreIncrease = 300; | ||
addScoreComboMultiplier = true; | ||
increaseCombo = true; | ||
break; | ||
|
||
case Banana: | ||
scoreIncrease = 1100; | ||
increaseCombo = false; | ||
isBonus = true; | ||
bonusResult = HitResult.LargeBonus; | ||
break; | ||
|
||
case JuiceStream: | ||
foreach (var nested in hitObject.NestedHitObjects) | ||
simulateHit(nested); | ||
return; | ||
|
||
case BananaShower: | ||
foreach (var nested in hitObject.NestedHitObjects) | ||
simulateHit(nested); | ||
return; | ||
} | ||
|
||
if (addScoreComboMultiplier) | ||
{ | ||
// ReSharper disable once PossibleLossOfFraction (intentional to match osu-stable...) | ||
ComboScore += (int)(Math.Max(0, combo - 1) * (scoreIncrease / 25 * scoreMultiplier)); | ||
} | ||
|
||
if (isBonus) | ||
{ | ||
legacyBonusScore += scoreIncrease; | ||
modernBonusScore += Judgement.ToNumericResult(bonusResult); | ||
} | ||
else | ||
AccuracyScore += scoreIncrease; | ||
|
||
if (increaseCombo) | ||
combo++; | ||
} | ||
} | ||
} |
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
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
28 changes: 28 additions & 0 deletions
28
osu.Game.Rulesets.Mania/Difficulty/ManiaLegacyScoreSimulator.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,28 @@ | ||
// 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 osu.Game.Beatmaps; | ||
using osu.Game.Rulesets.Mania.Mods; | ||
using osu.Game.Rulesets.Mods; | ||
using osu.Game.Rulesets.Scoring; | ||
|
||
namespace osu.Game.Rulesets.Mania.Difficulty | ||
{ | ||
internal class ManiaLegacyScoreSimulator : ILegacyScoreSimulator | ||
{ | ||
public int AccuracyScore => 0; | ||
public int ComboScore { get; private set; } | ||
public double BonusScoreRatio => 0; | ||
|
||
public void Simulate(IWorkingBeatmap workingBeatmap, IBeatmap playableBeatmap, IReadOnlyList<Mod> mods) | ||
{ | ||
double multiplier = mods.Where(m => m is not (ModHidden or ModHardRock or ModDoubleTime or ModFlashlight or ManiaModFadeIn)) | ||
.Select(m => m.ScoreMultiplier) | ||
.Aggregate(1.0, (c, n) => c * n); | ||
|
||
ComboScore = (int)(1000000 * multiplier); | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute hasn't been removed, just moved from each ruleset down to the base
DifficultyAttributes
class.The reasoning for why it was this way is that, historically, some rulesets (e.g. mania) didn't store max combo. This has changed over the years and we now store max combo for all rulesets, but this code hadn't been adjusted in line with that.