mirror of
https://github.com/ppy/osu
synced 2024-12-14 10:57:41 +00:00
Merge pull request #16519 from peppy/fix-legacy-score-import-classic-mod
Fix legacy score imports not correctly getting classic mod assigned
This commit is contained in:
commit
7509b31176
@ -12,6 +12,7 @@ using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
@ -51,6 +52,11 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
Assert.AreEqual(829_931, score.ScoreInfo.TotalScore);
|
||||
Assert.AreEqual(3, score.ScoreInfo.MaxCombo);
|
||||
|
||||
Assert.IsTrue(score.ScoreInfo.Mods.Any(m => m is ManiaModClassic));
|
||||
Assert.IsTrue(score.ScoreInfo.APIMods.Any(m => m.Acronym == "CL"));
|
||||
Assert.IsTrue(score.ScoreInfo.ModsJson.Contains("CL"));
|
||||
|
||||
Assert.IsTrue(Precision.AlmostEquals(0.8889, score.ScoreInfo.Accuracy, 0.0001));
|
||||
Assert.AreEqual(ScoreRank.B, score.ScoreInfo.Rank);
|
||||
|
||||
|
@ -2,6 +2,10 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Mania.Mods;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
@ -29,5 +33,41 @@ namespace osu.Game.Tests.NonVisual
|
||||
Assert.That(scoreCopy.Rank, Is.EqualTo(ScoreRank.B));
|
||||
Assert.That(score.Rank, Is.EqualTo(ScoreRank.X));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestModsInitiallyEmpty()
|
||||
{
|
||||
var score = new ScoreInfo();
|
||||
|
||||
Assert.That(score.Mods, Is.Empty);
|
||||
Assert.That(score.APIMods, Is.Empty);
|
||||
Assert.That(score.ModsJson, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestModsUpdatedCorrectly()
|
||||
{
|
||||
var score = new ScoreInfo
|
||||
{
|
||||
Mods = new Mod[] { new ManiaModClassic() },
|
||||
Ruleset = new ManiaRuleset().RulesetInfo,
|
||||
};
|
||||
|
||||
Assert.That(score.Mods, Contains.Item(new ManiaModClassic()));
|
||||
Assert.That(score.APIMods, Contains.Item(new APIMod(new ManiaModClassic())));
|
||||
Assert.That(score.ModsJson, Contains.Substring("CL"));
|
||||
|
||||
score.APIMods = new[] { new APIMod(new ManiaModDoubleTime()) };
|
||||
|
||||
Assert.That(score.Mods, Contains.Item(new ManiaModDoubleTime()));
|
||||
Assert.That(score.APIMods, Contains.Item(new APIMod(new ManiaModDoubleTime())));
|
||||
Assert.That(score.ModsJson, Contains.Substring("DT"));
|
||||
|
||||
score.Mods = new Mod[] { new ManiaModClassic() };
|
||||
|
||||
Assert.That(score.Mods, Contains.Item(new ManiaModClassic()));
|
||||
Assert.That(score.APIMods, Contains.Item(new APIMod(new ManiaModClassic())));
|
||||
Assert.That(score.ModsJson, Contains.Substring("CL"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,9 +191,8 @@ namespace osu.Game.Scoring
|
||||
}
|
||||
set
|
||||
{
|
||||
apiMods = null;
|
||||
clearAllMods();
|
||||
mods = value;
|
||||
|
||||
updateModsJson();
|
||||
}
|
||||
}
|
||||
@ -220,17 +219,24 @@ namespace osu.Game.Scoring
|
||||
}
|
||||
set
|
||||
{
|
||||
clearAllMods();
|
||||
apiMods = value;
|
||||
mods = null;
|
||||
|
||||
// We potentially can't update this yet due to Ruleset being late-bound, so instead update on read as necessary.
|
||||
updateModsJson();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearAllMods()
|
||||
{
|
||||
ModsJson = string.Empty;
|
||||
mods = null;
|
||||
apiMods = null;
|
||||
}
|
||||
|
||||
private void updateModsJson()
|
||||
{
|
||||
ModsJson = JsonConvert.SerializeObject(APIMods);
|
||||
ModsJson = APIMods.Length > 0
|
||||
? JsonConvert.SerializeObject(APIMods)
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
|
||||
|
Loading…
Reference in New Issue
Block a user