mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Apply Ruleset to Scores. Reduce complexity of score creation.
This commit is contained in:
parent
6cf026e5c1
commit
a47870b376
@ -37,16 +37,14 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
private readonly Dictionary<OsuScoreResult, int> scoreResultCounts = new Dictionary<OsuScoreResult, int>();
|
||||
private readonly Dictionary<ComboResult, int> comboResultCounts = new Dictionary<ComboResult, int>();
|
||||
|
||||
public override Score GetPopulatedScore()
|
||||
public override void PopulateScore(Score score)
|
||||
{
|
||||
var score = base.GetPopulatedScore();
|
||||
base.PopulateScore(score);
|
||||
|
||||
score.Statistics[@"300"] = scoreResultCounts.GetOrDefault(OsuScoreResult.Hit300);
|
||||
score.Statistics[@"100"] = scoreResultCounts.GetOrDefault(OsuScoreResult.Hit100);
|
||||
score.Statistics[@"50"] = scoreResultCounts.GetOrDefault(OsuScoreResult.Hit50);
|
||||
score.Statistics[@"x"] = scoreResultCounts.GetOrDefault(OsuScoreResult.Miss);
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
protected override void OnNewJudgement(OsuJudgement judgement)
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Database
|
||||
using (SerializationReader sr = new SerializationReader(s))
|
||||
{
|
||||
var ruleset = rulesets.GetRuleset(sr.ReadByte()).CreateInstance();
|
||||
score = ruleset.CreateScoreProcessor().CreateEmptyScore();
|
||||
score = new Score();
|
||||
|
||||
/* score.Pass = true;*/
|
||||
var version = sr.ReadInt32();
|
||||
|
@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Scoring
|
||||
[JsonProperty(@"mods")]
|
||||
protected string[] ModStrings { get; set; } //todo: parse to Mod objects
|
||||
|
||||
public RulesetInfo Ruleset { get; set; }
|
||||
|
||||
public Mod[] Mods { get; set; }
|
||||
|
||||
[JsonProperty(@"user")]
|
||||
|
@ -61,12 +61,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Score applicable to the ruleset in which this ScoreProcessor resides.
|
||||
/// </summary>
|
||||
/// <returns>The Score.</returns>
|
||||
public virtual Score CreateEmptyScore() => new Score();
|
||||
|
||||
private ScoreRank rankFrom(double acc)
|
||||
{
|
||||
if (acc == 1)
|
||||
@ -114,10 +108,8 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// <summary>
|
||||
/// Retrieve a score populated with data for the current play this processor is responsible for.
|
||||
/// </summary>
|
||||
public virtual Score GetPopulatedScore()
|
||||
public virtual void PopulateScore(Score score)
|
||||
{
|
||||
var score = CreateEmptyScore();
|
||||
|
||||
score.TotalScore = TotalScore;
|
||||
score.Combo = Combo;
|
||||
score.MaxCombo = HighestCombo;
|
||||
@ -125,8 +117,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
score.Rank = rankFrom(Accuracy);
|
||||
score.Date = DateTime.Now;
|
||||
score.Health = Health;
|
||||
|
||||
return score;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
|
||||
private IAdjustableClock sourceClock;
|
||||
private IFrameBasedClock interpolatedSourceClock;
|
||||
|
||||
private Ruleset ruleset;
|
||||
private RulesetInfo ruleset;
|
||||
|
||||
private ScoreProcessor scoreProcessor;
|
||||
protected HitRenderer HitRenderer;
|
||||
@ -68,6 +68,8 @@ namespace osu.Game.Screens.Play
|
||||
dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
|
||||
mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel);
|
||||
|
||||
Ruleset rulesetInstance;
|
||||
|
||||
try
|
||||
{
|
||||
if (Beatmap == null)
|
||||
@ -82,15 +84,17 @@ namespace osu.Game.Screens.Play
|
||||
try
|
||||
{
|
||||
// Try using the preferred user ruleset
|
||||
ruleset = osu == null ? Beatmap.BeatmapInfo.Ruleset.CreateInstance() : osu.Ruleset.Value.CreateInstance();
|
||||
HitRenderer = ruleset.CreateHitRendererWith(Beatmap);
|
||||
ruleset = osu == null ? Beatmap.BeatmapInfo.Ruleset : osu.Ruleset.Value;
|
||||
}
|
||||
catch (BeatmapInvalidForModeException)
|
||||
{
|
||||
// Default to the beatmap ruleset
|
||||
ruleset = Beatmap.BeatmapInfo.Ruleset.CreateInstance();
|
||||
HitRenderer = ruleset.CreateHitRendererWith(Beatmap);
|
||||
ruleset = Beatmap.BeatmapInfo.Ruleset;
|
||||
}
|
||||
|
||||
rulesetInstance = ruleset.CreateInstance();
|
||||
|
||||
HitRenderer = rulesetInstance.CreateHitRendererWith(Beatmap);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -125,7 +129,7 @@ namespace osu.Game.Screens.Play
|
||||
Origin = Anchor.Centre
|
||||
};
|
||||
|
||||
hudOverlay.KeyCounter.Add(ruleset.CreateGameplayKeys());
|
||||
hudOverlay.KeyCounter.Add(rulesetInstance.CreateGameplayKeys());
|
||||
hudOverlay.BindProcessor(scoreProcessor);
|
||||
hudOverlay.BindHitRenderer(HitRenderer);
|
||||
|
||||
@ -266,7 +270,12 @@ namespace osu.Game.Screens.Play
|
||||
Delay(1000);
|
||||
onCompletionEvent = Schedule(delegate
|
||||
{
|
||||
var score = scoreProcessor.GetPopulatedScore();
|
||||
var score = new Score
|
||||
{
|
||||
Beatmap = Beatmap.BeatmapInfo,
|
||||
Ruleset = ruleset
|
||||
};
|
||||
scoreProcessor.PopulateScore(score);
|
||||
score.User = HitRenderer.Replay?.User ?? (Game as OsuGame)?.API?.LocalUser?.Value;
|
||||
Push(new Results(score));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user