private void CalculatePPAndDifficulty(string beatmap) { EZPPResult ezpp = EZPP.Calculate(beatmap, MaxCombo, Count100, Count50, CountMiss, EnabledMods); MapMaxCombo = ezpp.MaxCombo; MapTotalHitObjects = ezpp.TotalHitObjects; PP = ezpp.PP; double objectsEncountered = Count300 + Count100 + Count50 + CountMiss; Accuracy = (double)((Count300 * 300.0) + (Count100 * 100.0) + (Count50 * 50.0)) / (double)(objectsEncountered * 300.0); Accuracy *= 100.0; //100 to 300 ratio double expectedCount100 = ((double)Count100 * MapTotalHitObjects) / objectsEncountered; //50 to 300 ratio double expectedCount50 = ((double)Count50 * MapTotalHitObjects) / objectsEncountered; ezpp = EZPP.Calculate(beatmap, ezpp.MaxCombo, (int)Math.Floor(expectedCount100), (int)Math.Floor(expectedCount50), 0, EnabledMods); PP_IF_FC = ezpp.PP; IF_FC_Accuracy = ezpp.Accuracy; CompletionPercentage = (objectsEncountered / ezpp.TotalHitObjects) * 100; StarRating = ezpp.StarRating; CS = ezpp.CS; AR = ezpp.AR; OD = ezpp.OD; HP = ezpp.HP; BPM = ezpp.BPM; SongName = ezpp.SongName; DifficultyName = ezpp.DifficultyName; ArtistName = ezpp.ArtistName; }
public static EZPPResult Calculate(string mapData, int maxCombo, int n100, int n50, int nMisses, Mods mods, float accuracy = -1) { lock (ezppLock) { //Create ezpp instance ezppInstance = ezpp_new(); EZPPResult result = new EZPPResult(); //give mods to ezpp ezpp_set_mods(ezppInstance, (int)mods); //give misscount to ezpp ezpp_set_nmiss(ezppInstance, nMisses); //give max combo to ezpp ezpp_set_combo(ezppInstance, maxCombo); //Give accuracy to ezpp if it's over 0, otherwise set the n100 and n50 if (accuracy > 0) { ezpp_set_accuracy_percent(ezppInstance, accuracy); } else { ezpp_set_accuracy(ezppInstance, n100, n50); } //give a duplicate of map data to ezpp, so it can calculate above values ^^ ezpp_data_dup(ezppInstance, mapData, mapData.Length); //Calculate pp first result.PP = ezpp_pp(ezppInstance); result.StarRating = ezpp_stars(ezppInstance); result.Accuracy = ezpp_accuracy_percent(ezppInstance); result.MaxCombo = ezpp_max_combo(ezppInstance); result.TotalHitObjects = ezpp_nobjects(ezppInstance); result.DifficultyName = ConvertUnsafeCString(ezpp_version(ezppInstance)); result.SongName = ConvertUnsafeCString(ezpp_title(ezppInstance)); result.ArtistName = ConvertUnsafeCString(ezpp_artist(ezppInstance)); result.AR = ezpp_ar(ezppInstance); result.CS = ezpp_cs(ezppInstance); result.HP = ezpp_hp(ezppInstance); result.OD = ezpp_od(ezppInstance); //Get the MS Per beat for the first object of the map result.BPM = 60000f / ezpp_timing_ms_per_beat(ezppInstance, 0); if (mods.HasFlag(Mods.DT)) { result.BPM = result.BPM * 1.5f; } else if (mods.HasFlag(Mods.HT)) { result.BPM = result.BPM * 0.75f; } //Destroy ezpp ezpp_free(ezppInstance); return(result); } }