diff --git a/Cargo.lock b/Cargo.lock index 60a9cdb..7537dbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,6 +44,14 @@ dependencies = [ "tokio", ] +[[package]] +name = "akatsuki-pp" +version = "0.9.6" +source = "git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=099528892c2a8183880c0538fe7e454775751cca#099528892c2a8183880c0538fe7e454775751cca" +dependencies = [ + "tokio", +] + [[package]] name = "akatsuki-pp" version = "0.9.6" @@ -1853,6 +1861,7 @@ version = "0.1.0" dependencies = [ "akatsuki-pp 0.9.3", "akatsuki-pp 0.9.4", + "akatsuki-pp 0.9.6 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=099528892c2a8183880c0538fe7e454775751cca)", "akatsuki-pp 0.9.6 (git+https://github.com/CursorDance/akatsuki-pp-rs?rev=56a71011e13274e63f6548611f3d5c822377c0d3)", "akatsuki-pp 0.9.6 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=588f8fe090bbf262cb86cd95ac9c9c9f35b0da03)", "akatsuki-pp 0.9.6 (git+https://github.com/osuAkatsuki/akatsuki-pp-rs?rev=5c97207f25cf9fd07252dca1ba68d785e2147ce1)", diff --git a/Cargo.toml b/Cargo.toml index 8f77880..5b613f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,6 +65,9 @@ simplify-relax = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuk improved-miss-penalty = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "588f8fe090bbf262cb86cd95ac9c9c9f35b0da03", features = [ "async_tokio", ] } +accuracy-fun = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "099528892c2a8183880c0538fe7e454775751cca", features = [ + "async_tokio", +] } [profile.release] lto = "fat" diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 24ff539..0951d5b 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -19,6 +19,7 @@ use crate::{ usecases, }; +use accuracy_fun::Beatmap as AccuracyFunBeatmap; use conceptual_rework::{ Beatmap as ConceptualBeatmap, BeatmapExt as ConceptualBeatmapExt, GameMode as ConceptualGameMode, @@ -215,6 +216,29 @@ async fn calculate_improved_miss_penalty_pp( Ok(pp) } +async fn calculate_accuracy_fun_pp( + score: &RippleScore, + context: Arc, +) -> anyhow::Result { + let beatmap_bytes = + usecases::beatmaps::fetch_beatmap_osu_file(score.beatmap_id, context).await?; + let beatmap = AccuracyFunBeatmap::from_bytes(&beatmap_bytes).await?; + + let result = accuracy_fun::osu_2019::OsuPP::new(&beatmap) + .mods(score.mods as u32) + .combo(score.max_combo as usize) + .misses(score.count_misses as usize) + .accuracy(score.accuracy) + .calculate(); + + let mut pp = round(result.pp as f32, 2); + if pp.is_infinite() || pp.is_nan() { + pp = 0.0; + } + + Ok(pp) +} + async fn process_scores( rework: &Rework, scores: Vec, @@ -232,6 +256,7 @@ async fn process_scores( 17 => calculate_no_accuracy_pp(score, context.clone()).await?, 18 => calculate_simplfy_relax_pp(score, context.clone()).await?, 19 => calculate_improved_miss_penalty_pp(score, context.clone()).await?, + 20 => calculate_accuracy_fun_pp(score, context.clone()).await?, _ => unreachable!(), };