Add combo score / bonus score attributes

This commit is contained in:
Dan Balasescu 2023-06-12 23:00:29 +09:00
parent d10c63ed2d
commit 446807e7f6
2 changed files with 59 additions and 13 deletions

View File

@ -93,11 +93,12 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double hitWindowGreat = hitWindows.WindowFor(HitResult.Great) / clockRate;
OsuScoreV1Processor sv1Processor = new OsuScoreV1Processor(workingBeatmap.Beatmap, beatmap, mods);
return new OsuDifficultyAttributes
{
StarRating = starRating,
Mods = mods,
LegacyTotalScore = new OsuScoreV1Processor(workingBeatmap.Beatmap, beatmap, mods).TotalScore,
AimDifficulty = aimRating,
SpeedDifficulty = speedRating,
SpeedNoteCount = speedNotes,
@ -110,6 +111,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty
HitCircleCount = hitCirclesCount,
SliderCount = sliderCount,
SpinnerCount = spinnerCount,
LegacyTotalScore = sv1Processor.TotalScore,
LegacyComboScore = sv1Processor.ComboScore,
LegacyBonusScore = sv1Processor.BonusScore
};
}
@ -198,20 +202,38 @@ namespace osu.Game.Rulesets.Osu.Difficulty
public class OsuScoreV1Processor : ScoreV1Processor
{
public int TotalScore { get; private set; }
public int TotalScore => BaseScore + ComboScore + BonusScore;
/// <summary>
/// Amount of score that is combo-and-difficulty-multiplied, excluding mod multipliers.
/// </summary>
public int ComboScore { get; private set; }
/// <summary>
/// Amount of score that is NOT combo-and-difficulty-multiplied.
/// </summary>
public int BaseScore { get; private set; }
/// <summary>
/// Amount of score whose judgements would be treated as "bonus" in ScoreV2.
/// </summary>
public int BonusScore { get; private set; }
private int combo;
public OsuScoreV1Processor(IBeatmap baseBeatmap, IBeatmap playableBeatmap, IReadOnlyList<Mod> mods)
: base(baseBeatmap, playableBeatmap, mods)
{
foreach (var obj in playableBeatmap.HitObjects)
increaseScore(obj);
simulateHit(obj);
}
private void increaseScore(HitObject hitObject)
private void simulateHit(HitObject hitObject)
{
bool increaseCombo = true;
bool addScoreComboMultiplier = false;
bool isBonus = false;
int scoreIncrease = 0;
switch (hitObject)
@ -229,11 +251,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty
case SpinnerBonusTick:
scoreIncrease = 1100;
increaseCombo = false;
isBonus = true;
break;
case SpinnerTick:
scoreIncrease = 100;
increaseCombo = false;
isBonus = true;
break;
case HitCircle:
@ -243,7 +267,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty
case Slider:
foreach (var nested in hitObject.NestedHitObjects)
increaseScore(nested);
simulateHit(nested);
scoreIncrease = 300;
increaseCombo = false;
@ -267,9 +291,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty
for (int i = 0; i <= totalHalfSpinsPossible; i++)
{
if (i > halfSpinsRequiredBeforeBonus && (i - halfSpinsRequiredBeforeBonus) % 2 == 0)
increaseScore(new SpinnerBonusTick());
simulateHit(new SpinnerBonusTick());
else if (i > 1 && i % 2 == 0)
increaseScore(new SpinnerTick());
simulateHit(new SpinnerTick());
}
scoreIncrease = 300;
@ -280,13 +304,16 @@ namespace osu.Game.Rulesets.Osu.Difficulty
if (addScoreComboMultiplier)
{
// ReSharper disable once PossibleLossOfFraction (intentional to match osu-stable...)
scoreIncrease += (int)(Math.Max(0, combo - 1) * (scoreIncrease / 25 * ScoreMultiplier));
ComboScore += (int)(Math.Max(0, combo - 1) * (scoreIncrease / 25 * ScoreMultiplier));
}
if (isBonus)
BonusScore += scoreIncrease;
else
BaseScore += scoreIncrease;
if (increaseCombo)
combo++;
TotalScore += scoreIncrease;
}
}
}

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Difficulty
{
@ -27,6 +28,8 @@ namespace osu.Game.Rulesets.Difficulty
protected const int ATTRIB_ID_SLIDER_FACTOR = 19;
protected const int ATTRIB_ID_SPEED_NOTE_COUNT = 21;
protected const int ATTRIB_ID_LEGACY_TOTAL_SCORE = 23;
protected const int ATTRIB_ID_LEGACY_COMBO_SCORE = 25;
protected const int ATTRIB_ID_LEGACY_BONUS_SCORE = 27;
/// <summary>
/// The mods which were applied to the beatmap.
@ -36,21 +39,33 @@ namespace osu.Game.Rulesets.Difficulty
/// <summary>
/// The combined star rating of all skills.
/// </summary>
[JsonProperty("star_rating", Order = -4)]
[JsonProperty("star_rating", Order = -7)]
public double StarRating { get; set; }
/// <summary>
/// The maximum achievable combo.
/// </summary>
[JsonProperty("max_combo", Order = -3)]
[JsonProperty("max_combo", Order = -6)]
public int MaxCombo { get; set; }
/// <summary>
/// The maximum achievable legacy total score.
/// </summary>
[JsonProperty("legacy_total_score", Order = -2)]
[JsonProperty("legacy_total_score", Order = -5)]
public int LegacyTotalScore { get; set; }
/// <summary>
/// The combo-multiplied portion of <see cref="LegacyTotalScore"/>.
/// </summary>
[JsonProperty("legacy_combo_score", Order = -4)]
public int LegacyComboScore { get; set; }
/// <summary>
/// The "bonus" portion of <see cref="LegacyTotalScore"/> consisting of all judgements that would be <see cref="HitResult.SmallBonus"/> or <see cref="HitResult.LargeBonus"/>.
/// </summary>
[JsonProperty("legacy_bonus_score", Order = -3)]
public int LegacyBonusScore { get; set; }
/// <summary>
/// Creates new <see cref="DifficultyAttributes"/>.
/// </summary>
@ -79,6 +94,8 @@ namespace osu.Game.Rulesets.Difficulty
{
yield return (ATTRIB_ID_MAX_COMBO, MaxCombo);
yield return (ATTRIB_ID_LEGACY_TOTAL_SCORE, LegacyTotalScore);
yield return (ATTRIB_ID_LEGACY_COMBO_SCORE, LegacyComboScore);
yield return (ATTRIB_ID_LEGACY_BONUS_SCORE, LegacyBonusScore);
}
/// <summary>
@ -90,6 +107,8 @@ namespace osu.Game.Rulesets.Difficulty
{
MaxCombo = (int)values[ATTRIB_ID_MAX_COMBO];
LegacyTotalScore = (int)values[ATTRIB_ID_LEGACY_TOTAL_SCORE];
LegacyComboScore = (int)values[ATTRIB_ID_LEGACY_COMBO_SCORE];
LegacyBonusScore = (int)values[ATTRIB_ID_LEGACY_BONUS_SCORE];
}
}
}