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