public void SetNewMap(MapSearchResult map) { lock (_lockingObject) { if ((map.Action & OsuStatus.ResultsScreen) != 0) { return; } OutputPatterns.Clear(); if (map.FoundBeatmaps && map.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation)) { var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var mods = map.Mods?.WorkingMods ?? ""; _rawData.SetCurrentMap(map.BeatmapsFound[0], mods, mapLocation, (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, map.PlayMode.HasValue ? (int?)map.PlayMode : null)); CopyPatterns(map.FormatedStrings); } else { _rawData.SetCurrentMap(null, "", null, PlayMode.Osu); } } }
public void SetNewMap(MapSearchResult map) { lock (_lockingObject) { if ((map.Action & OsuStatus.ResultsScreen) != 0) { return; } if (map.FoundBeatmaps && map.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation)) { _sliderBreaks = 0; _lastMisses = 0; _lastCombo = 0; if (map.SearchArgs.EventType == OsuEventType.MapChange) { var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var mods = map.Mods?.WorkingMods ?? ""; _rawData.SetCurrentMap(map.BeatmapsFound[0], mods, mapLocation, (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, map.PlayMode.HasValue ? (int?)map.PlayMode : null)); } _newPlayStarted.Set(); } } }
private static StrainsResult GetStrains(string mapLocation, PlayMode?desiredPlayMode) { var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var playMode = (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, desiredPlayMode.HasValue ? (int?)desiredPlayMode : null); var ppCalculator = PpCalculatorHelpers.GetPpCalculator((int)playMode, mapLocation, null); //Length refers to beatmap time, not song total time var mapLength = workingBeatmap.Length; var strainLength = 5000; var interval = 1500; var time = 0; var strains = new Dictionary <int, double>(300); if (ppCalculator == null) { while (time + strainLength / 2 < mapLength) { strains.Add(time, 50); time += interval; } } else if (playMode == PlayMode.Osu || playMode == PlayMode.Taiko || playMode == PlayMode.OsuMania) { var a = new Dictionary <string, double>(); while (time + strainLength / 2 < mapLength) { var strain = ppCalculator.Calculate(time, time + strainLength, a); if (double.IsNaN(strain) || strain < 0) { strain = 0; } else if (strain > 2000) { strain = 2000; //lets not freeze everything with aspire/fancy 100* maps } strains.Add(time, strain); time += interval; a.Clear(); } } return(new StrainsResult { Strains = strains, PpCalculator = ppCalculator, WorkingBeatmap = workingBeatmap, PlayMode = playMode, MapLocation = mapLocation }); }
public void CreateTokens(MapSearchResult map) { foreach (var tokenkv in Tokens.AllTokens.Where(t => t.Value.PluginName == Name)) { tokenkv.Value.Reset(); } if (!map.FoundBeatmaps || !map.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation)) { return; } var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var playMode = (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, map.PlayMode.HasValue ? (int?)map.PlayMode : null); _ppCalculator = PpCalculatorHelpers.GetPpCalculator((int)playMode, mapLocation, _ppCalculator); if (_ppCalculator == null) { return;//Ctb not supported :( } if (playMode == PlayMode.OsuMania) { _ppCalculator.Score = 1_000_000; } else { _ppCalculator.Score = 0; } _ppCalculator.Mods = null; _tokenSetter("GameMode", playMode.ToString()); string mods = ""; if (playMode == PlayMode.OsuMania) { _tokenSetter("1 000 000PP", GetPp(_ppCalculator, 0, mods, 1_000_000), format: PpFormat); _tokenSetter("990 000PP", GetPp(_ppCalculator, 0, mods, 990_000), format: PpFormat); _tokenSetter("950 000PP", GetPp(_ppCalculator, 0, mods, 950_000), format: PpFormat); _tokenSetter("900 000PP", GetPp(_ppCalculator, 0, mods, 900_000), format: PpFormat); _tokenSetter("800 000PP", GetPp(_ppCalculator, 0, mods, 800_000), format: PpFormat); _tokenSetter("700 000PP", GetPp(_ppCalculator, 0, mods, 700_000), format: PpFormat); _tokenSetter("600 000PP", GetPp(_ppCalculator, 0, mods, 600_000), format: PpFormat); } else { _tokenSetter("SSPP", GetPp(_ppCalculator, 100d), format: PpFormat); _tokenSetter("99.9PP", GetPp(_ppCalculator, 99.9d), format: PpFormat); _tokenSetter("99PP", GetPp(_ppCalculator, 99d), format: PpFormat); _tokenSetter("98PP", GetPp(_ppCalculator, 98d), format: PpFormat); _tokenSetter("95PP", GetPp(_ppCalculator, 95d), format: PpFormat); _tokenSetter("90PP", GetPp(_ppCalculator, 90d), format: PpFormat); } _tokenSetter("MaxCombo", _ppCalculator.GetMaxCombo()); mods = map.Mods?.WorkingMods ?? ""; if (playMode == PlayMode.OsuMania) { _tokenSetter("m1 000 000PP", GetPp(_ppCalculator, 0, mods, 1_000_000), format: PpFormat); _tokenSetter("m990 000PP", GetPp(_ppCalculator, 0, mods, 990_000), format: PpFormat); _tokenSetter("m950 000PP", GetPp(_ppCalculator, 0, mods, 950_000), format: PpFormat); _tokenSetter("m900 000PP", GetPp(_ppCalculator, 0, mods, 900_000), format: PpFormat); _tokenSetter("m800 000PP", GetPp(_ppCalculator, 0, mods, 800_000), format: PpFormat); _tokenSetter("m700 000PP", GetPp(_ppCalculator, 0, mods, 700_000), format: PpFormat); _tokenSetter("m600 000PP", GetPp(_ppCalculator, 0, mods, 600_000), format: PpFormat); } else { _tokenSetter("mSSPP", GetPp(_ppCalculator, 100d, mods), format: PpFormat); _tokenSetter("m99.9PP", GetPp(_ppCalculator, 99.9d, mods), format: PpFormat); _tokenSetter("m99PP", GetPp(_ppCalculator, 99d, mods), format: PpFormat); _tokenSetter("m98PP", GetPp(_ppCalculator, 98d, mods), format: PpFormat); _tokenSetter("m95PP", GetPp(_ppCalculator, 95d, mods), format: PpFormat); _tokenSetter("m90PP", GetPp(_ppCalculator, 90d, mods), format: PpFormat); } }
public Tokens GetMapReplacements(MapSearchResult map) { var ret = new Tokens { { "GameMode", new Token(null) }, { "MaxCombo", new Token(null) }, { "SSPP", new Token(null) }, { "99.9PP", new Token(null) }, { "99PP", new Token(null) }, { "98PP", new Token(null) }, { "95PP", new Token(null) }, { "90PP", new Token(null) }, { "1 000 000PP", new Token(null) }, { "990 000PP", new Token(null) }, { "950 000PP", new Token(null) }, { "900 000PP", new Token(null) }, { "800 000PP", new Token(null) }, { "700 000PP", new Token(null) }, { "600 000PP", new Token(null) }, { "mMod", new Token(null) }, { "mSSPP", new Token(null) }, { "m99.9PP", new Token(null) }, { "m99PP", new Token(null) }, { "m98PP", new Token(null) }, { "m95PP", new Token(null) }, { "m90PP", new Token(null) }, { "m1 000 000PP", new Token(null) }, { "m990 000PP", new Token(null) }, { "m950 000PP", new Token(null) }, { "m900 000PP", new Token(null) }, { "m800 000PP", new Token(null) }, { "m700 000PP", new Token(null) }, { "m600 000PP", new Token(null) }, }; if (!map.FoundBeatmaps || !map.BeatmapsFound[0].IsValidBeatmap(_settings, out var mapLocation) ) { return(ret); } var workingBeatmap = new ProcessorWorkingBeatmap(mapLocation); var playMode = (PlayMode)PpCalculatorHelpers.GetRulesetId(workingBeatmap.RulesetID, map.PlayMode.HasValue ? (int?)map.PlayMode : null); _ppCalculator = PpCalculatorHelpers.GetPpCalculator((int)playMode, mapLocation, _ppCalculator); if (_ppCalculator == null) { return(ret);//Ctb not supported :( } if (playMode == PlayMode.OsuMania) { _ppCalculator.Score = 1_000_000; } else { _ppCalculator.Score = 0; } _ppCalculator.Mods = null; ret["GameMode"] = new TokenWithFormat(playMode.ToString()); string mods = ""; if (playMode == PlayMode.OsuMania) { ret["1 000 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 1_000_000), format: PpFormat); ret["990 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 990_000), format: PpFormat); ret["950 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 950_000), format: PpFormat); ret["900 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 900_000), format: PpFormat); ret["800 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 800_000), format: PpFormat); ret["700 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 700_000), format: PpFormat); ret["600 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 600_000), format: PpFormat); } else { ret["SSPP"] = new TokenWithFormat(GetPp(_ppCalculator, 100d), format: PpFormat); ret["99.9PP"] = new TokenWithFormat(GetPp(_ppCalculator, 99.9d), format: PpFormat); ret["99PP"] = new TokenWithFormat(GetPp(_ppCalculator, 99d), format: PpFormat); ret["98PP"] = new TokenWithFormat(GetPp(_ppCalculator, 98d), format: PpFormat); ret["95PP"] = new TokenWithFormat(GetPp(_ppCalculator, 95d), format: PpFormat); ret["90PP"] = new TokenWithFormat(GetPp(_ppCalculator, 90d), format: PpFormat); } ret["MaxCombo"] = new TokenWithFormat(_ppCalculator.GetMaxCombo()); string modsStr; if (map.Action == OsuStatus.Playing || map.Action == OsuStatus.Watching) { mods = map.Mods?.WorkingMods ?? ""; modsStr = map.Mods?.ShownMods ?? ""; _lastShortMods = mods; _lastModsStr = modsStr; } else { mods = _lastShortMods; modsStr = _lastModsStr; } ret["mMod"] = new Token(modsStr); if (playMode == PlayMode.OsuMania) { ret["m1 000 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 1_000_000), format: PpFormat); ret["m990 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 990_000), format: PpFormat); ret["m950 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 950_000), format: PpFormat); ret["m900 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 900_000), format: PpFormat); ret["m800 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 800_000), format: PpFormat); ret["m700 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 700_000), format: PpFormat); ret["m600 000PP"] = new TokenWithFormat(GetPp(_ppCalculator, 0, mods, 600_000), format: PpFormat); } else { ret["mSSPP"] = new TokenWithFormat(GetPp(_ppCalculator, 100d, mods), format: PpFormat); ret["m99.9PP"] = new TokenWithFormat(GetPp(_ppCalculator, 99.9d, mods), format: PpFormat); ret["m99PP"] = new TokenWithFormat(GetPp(_ppCalculator, 99d, mods), format: PpFormat); ret["m98PP"] = new TokenWithFormat(GetPp(_ppCalculator, 98d, mods), format: PpFormat); ret["m95PP"] = new TokenWithFormat(GetPp(_ppCalculator, 95d, mods), format: PpFormat); ret["m90PP"] = new TokenWithFormat(GetPp(_ppCalculator, 90d, mods), format: PpFormat); } return(ret); }