Skip to content

Commit

Permalink
Fix abbreviation inconsistencies and add catches for PF+SD, CN+AU (#3)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Starwort authored and Piotrekol committed May 10, 2018
1 parent 522ce33 commit f10af22
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 30 deletions.
6 changes: 3 additions & 3 deletions CollectionManagerDll/DataTypes/Mods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
58 changes: 33 additions & 25 deletions CollectionManagerDll/Modules/ModParser/ModParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@ public string LongNoModText
private readonly List<OsuMod> _mods = new List<OsuMod>()
{
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);
Expand Down Expand Up @@ -109,11 +109,19 @@ 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();

return retVal;
}
}
}
}
32 changes: 30 additions & 2 deletions CollectionManagerDllTests/Modules/ModParser/ModParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f10af22

Please sign in to comment.