From f10af2210b13acb9ddfa5c0b6641043b7d4f33c9 Mon Sep 17 00:00:00 2001 From: Starwort Date: Thu, 10 May 2018 18:54:23 +0100 Subject: [PATCH] Fix abbreviation inconsistencies and add catches for PF+SD, CN+AU (#3) * Fix abbreviation inconsistencies and add catches for PF+SD, CN+AU * Add TP TO -> TP * Rename Ap=>Au; Lm=>Cm * Add test for "hiding" of mod pairs Piotrekol/StreamCompanion#21 --- CollectionManagerDll/DataTypes/Mods.cs | 6 +- .../Modules/ModParser/ModParser.cs | 58 +++++++++++-------- .../Modules/ModParser/ModParserTests.cs | 32 +++++++++- 3 files changed, 66 insertions(+), 30 deletions(-) diff --git a/CollectionManagerDll/DataTypes/Mods.cs b/CollectionManagerDll/DataTypes/Mods.cs index 29a5fdd..61dd2f4 100644 --- a/CollectionManagerDll/DataTypes/Mods.cs +++ b/CollectionManagerDll/DataTypes/Mods.cs @@ -17,7 +17,7 @@ public enum Mods Ht = 1 << 8, Nc = 1 << 9, Fl = 1 << 10, - Ap = 1 << 11,//autoplay + Au = 1 << 11, So = 1 << 12, Rx2 = 1 << 13, Pf = 1 << 14, @@ -28,8 +28,8 @@ public enum Mods K8 = 1 << 19, Fi = 1 << 20, Rn = 1 << 21, - Lm = 1 << 22, - //= 1 << 23, + Cm = 1 << 22, + Tp = 1 << 23, K9 = 1 << 24, Coop = 1 << 25, K1 = 1 << 26, diff --git a/CollectionManagerDll/Modules/ModParser/ModParser.cs b/CollectionManagerDll/Modules/ModParser/ModParser.cs index 7769616..4ad4416 100644 --- a/CollectionManagerDll/Modules/ModParser/ModParser.cs +++ b/CollectionManagerDll/Modules/ModParser/ModParser.cs @@ -39,35 +39,35 @@ public string LongNoModText private readonly List _mods = new List() { new OsuMod(Mods.Omod, "None", "None"), - new OsuMod(Mods.Nf, "NF", "NoFail"), + new OsuMod(Mods.Nf, "NF", "No Fail"), new OsuMod(Mods.Ez, "EZ", "Easy"), - new OsuMod(Mods.Nv,"NV","NoVideo"), + new OsuMod(Mods.Nv,"NV","NoVideo"), //What's the purpose of this line?; the mod is now used as "Touch Device" (as seen on the api wiki, NoVideo = 4, // Not used anymore, but can be found on old plays like Mesita on b/78239) new OsuMod(Mods.Hd, "HD", "Hidden"), - new OsuMod(Mods.Hr, "HR", "HardRock"), - new OsuMod(Mods.Sd, "SD", "SuddenDeath"), - new OsuMod(Mods.Dt, "DT", "DoubleTime"), - new OsuMod(Mods.RX, "RX", "Relax"), - new OsuMod(Mods.Ht, "HT", "HalfTime"), + new OsuMod(Mods.Hr, "HR", "Hard Rock"), + new OsuMod(Mods.Sd, "SD", "Sudden Death"), + new OsuMod(Mods.Dt, "DT", "Double Time"), + new OsuMod(Mods.RX, "RL", "Relax"), + new OsuMod(Mods.Ht, "HT", "Half Time"), new OsuMod(Mods.Nc, "NC", "Nightcore"), new OsuMod(Mods.Fl, "FL", "Flashlight"), - new OsuMod(Mods.Ap, "AP", "Autoplay"), - new OsuMod(Mods.So, "SO", "SpunOut"), - new OsuMod(Mods.Rx2, "RX2", "Relax2"), + new OsuMod(Mods.Au, "AU", "Auto"), + new OsuMod(Mods.So, "SO", "Spun Out"), + new OsuMod(Mods.Rx2, "AP", "Autopilot"), new OsuMod(Mods.Pf, "PF", "Perfect"), - new OsuMod(Mods.K4, "K4", "Key4"), - new OsuMod(Mods.K5, "K5", "Key5"), - new OsuMod(Mods.K6, "K6", "Key6"), - new OsuMod(Mods.K7, "K7", "Key7"), - new OsuMod(Mods.K8, "K8", "Key8"), - new OsuMod(Mods.Fi, "FI", "FadeIn"), - new OsuMod(Mods.Rn, "RN", "Random"), - new OsuMod(Mods.Lm, "LM", "LastMod"), - //new OsuMod(Mods.=, "--", "--"), - new OsuMod(Mods.K9, "K9", "Key9"), - new OsuMod(Mods.Coop, "Coop", "Coop"), - new OsuMod(Mods.K1, "K1", "Key1"), - new OsuMod(Mods.K3, "K3", "Key3"), - new OsuMod(Mods.K2, "K2", "Key2") + new OsuMod(Mods.K4, "4K", "4 Keys"), + new OsuMod(Mods.K5, "5K", "5 Keys"), + new OsuMod(Mods.K6, "6K", "6 Keys"), + new OsuMod(Mods.K7, "7K", "7 Keys"), + new OsuMod(Mods.K8, "8K", "8 Keys"), + new OsuMod(Mods.Fi, "FI", "Fade In"), + new OsuMod(Mods.Rn, "RD", "Random"), + new OsuMod(Mods.Cm, "CN", "Cinema"), + new OsuMod(Mods.Tp, "TP", "Target Practice"), + new OsuMod(Mods.K9, "9K", "9 Keys"), + new OsuMod(Mods.Coop, "CO", "Co-Op"), + new OsuMod(Mods.K1, "1K", "1 Key"), + new OsuMod(Mods.K3, "3K", "3 Keys"), + new OsuMod(Mods.K2, "2K", "2 Keys") }; public bool IsModHidden(OsuMod mod) => HiddenMods.Exists(m => m.Value == mod.Value); @@ -109,6 +109,14 @@ public string GetModsFromEnum(int modsEnum, bool shortMod = false) { retVal = retVal.Replace("DT,", ""); } + if (retVal.Contains("PF")) + { + retVal = retVal.Replace("SD,", ""); + } + if (retVal.Contains("CN")) + { + retVal = retVal.Replace("AU,", ""); + } } else retVal = modStr.Append(shortMod ? _mods[0].ShortMod : _mods[0].LongMod).ToString(); @@ -116,4 +124,4 @@ public string GetModsFromEnum(int modsEnum, bool shortMod = false) return retVal; } } -} \ No newline at end of file +} diff --git a/CollectionManagerDllTests/Modules/ModParser/ModParserTests.cs b/CollectionManagerDllTests/Modules/ModParser/ModParserTests.cs index debbda2..c565e79 100644 --- a/CollectionManagerDllTests/Modules/ModParser/ModParserTests.cs +++ b/CollectionManagerDllTests/Modules/ModParser/ModParserTests.cs @@ -81,6 +81,34 @@ public void GetModsFromEnum3() Assert.IsTrue(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Hd).ShortMod)); } [TestMethod()] + public void ModsHiding1() + { + _modParser = new ModParser(); + var mods = Mods.Dt | Mods.Nc | Mods.Hd | Mods.Hr | Mods.Pf | Mods.Sd | Mods.Cm | Mods.Au; + + var result = _modParser.GetModsFromEnum((int)mods, true); + + Assert.IsTrue(result.Count(s => s == ',') == 4); + Assert.IsFalse(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Dt).ShortMod)); + Assert.IsTrue(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Nc).ShortMod)); + + Assert.IsFalse(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Sd).ShortMod)); + Assert.IsTrue(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Pf).ShortMod)); + + Assert.IsFalse(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Au).ShortMod)); + Assert.IsTrue(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Cm).ShortMod)); + + + Assert.IsTrue(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Hd).ShortMod)); + Assert.IsTrue(result.Contains(_modParser.AllMods.First(t => t.Value == Mods.Hr).ShortMod)); + + + + + Assert.IsTrue(result.Substring(result.Length - 1) != ","); + Assert.IsTrue(result.Substring(result.Length - 1) != " "); + } + [TestMethod()] public void NoModText1() { _modParser = new ModParser(); @@ -95,7 +123,7 @@ public void NoModText2() { _modParser = new ModParser(); var mods = Mods.Omod; - var result = _modParser.GetModsFromEnum((int)mods,true); + var result = _modParser.GetModsFromEnum((int)mods, true); Assert.IsTrue(result.Count(s => s == ',') == 0); Assert.IsTrue(result == _modParser.ShortNoModText); @@ -125,7 +153,7 @@ public void NoModText4() _modParser.ShortNoModText = "N/A"; Assert.IsTrue(_modParser.ShortNoModText == "N/A"); - var result = _modParser.GetModsFromEnum((int)mods,true); + var result = _modParser.GetModsFromEnum((int)mods, true); Assert.IsTrue(result.Count(s => s == ',') == 0); Assert.IsTrue(result == _modParser.ShortNoModText);