Remove OsuScore and change the way statistics are stored (dynamic dictionary).

This commit is contained in:
Dean Herbert
2017-04-20 11:02:56 +09:00
parent 3e65cab9b7
commit 6cf026e5c1
8 changed files with 23 additions and 44 deletions

View File

@ -2,12 +2,12 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Rulesets.Osu.Scoring;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Users;
@ -41,17 +41,20 @@ namespace osu.Desktop.VisualTests.Tests
base.Reset();
Add(new Results(new OsuScore
Add(new Results(new Score
{
TotalScore = 2845370,
Accuracy = 0.98,
MaxCombo = 123,
Rank = ScoreRank.A,
Date = DateTime.Now,
Count300 = 100,
Count100 = 10,
Count50 = 1,
CountMiss = 2,
Statistics = new Dictionary<string, dynamic>()
{
{ "300", 50 },
{ "100", 20 },
{ "50", 50 },
{ "x", 1 }
},
User = new User
{
Username = "peppy",
@ -62,4 +65,4 @@ namespace osu.Desktop.VisualTests.Tests
});
}
}
}
}

View File

@ -1,23 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Osu.Scoring
{
public class OsuScore : Score
{
public int Count300;
public int Count100;
public int Count50;
public int CountMiss;
public override IEnumerable<ScoreStatistic> Statistics => new[] {
new ScoreStatistic(@"300", Count300),
new ScoreStatistic(@"100", Count100),
new ScoreStatistic(@"50", Count50),
new ScoreStatistic(@"x", CountMiss),
};
}
}

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Objects;
@ -36,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 CreateEmptyScore() => new OsuScore();
public override Score GetPopulatedScore()
{
var score = (OsuScore)base.GetPopulatedScore();
var score = base.GetPopulatedScore();
scoreResultCounts.TryGetValue(OsuScoreResult.Hit300, out score.Count300);
scoreResultCounts.TryGetValue(OsuScoreResult.Hit100, out score.Count100);
scoreResultCounts.TryGetValue(OsuScoreResult.Hit50, out score.Count50);
scoreResultCounts.TryGetValue(OsuScoreResult.Miss, out score.CountMiss);
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;
}

View File

@ -72,7 +72,6 @@
<Compile Include="OsuAutoReplay.cs" />
<Compile Include="OsuDifficultyCalculator.cs" />
<Compile Include="OsuKeyConversionInputManager.cs" />
<Compile Include="Scoring\OsuScore.cs" />
<Compile Include="Scoring\OsuScoreProcessor.cs" />
<Compile Include="UI\OsuHitRenderer.cs" />
<Compile Include="UI\OsuPlayfield.cs" />

View File

@ -7,7 +7,6 @@ using Newtonsoft.Json;
using osu.Game.Database;
using osu.Game.Rulesets.Mods;
using osu.Game.Users;
using System.IO;
using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Scoring
@ -49,6 +48,6 @@ namespace osu.Game.Rulesets.Scoring
[JsonProperty(@"created_at")]
public DateTime Date;
public virtual IEnumerable<ScoreStatistic> Statistics => new ScoreStatistic[] { };
public Dictionary<string, dynamic> Statistics = new Dictionary<string, dynamic>();
}
}

View File

@ -18,6 +18,7 @@ using osu.Game.Users;
using OpenTK;
using OpenTK.Graphics;
using System;
using System.Collections.Generic;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Beatmaps;
using osu.Game.Screens.Play;
@ -187,9 +188,9 @@ namespace osu.Game.Screens.Ranking
private class DrawableScoreStatistic : Container
{
private readonly ScoreStatistic statistic;
private readonly KeyValuePair<string, dynamic> statistic;
public DrawableScoreStatistic(ScoreStatistic statistic)
public DrawableScoreStatistic(KeyValuePair<string, dynamic> statistic)
{
this.statistic = statistic;
@ -210,7 +211,7 @@ namespace osu.Game.Screens.Ranking
Origin = Anchor.TopCentre,
},
new SpriteText {
Text = statistic.Name,
Text = statistic.Key,
Colour = colours.Gray7,
Font = @"Exo2.0-Bold",
Y = 26,

View File

@ -57,6 +57,7 @@
<HintPath>$(SolutionDir)\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="DotNetZip">