Skip to content

Commit

Permalink
add no accuracy pp for relax concept
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku committed Feb 8, 2024
1 parent 67bf90f commit ecb4821
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ woot-precision = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuk
cursordance = { package = "akatsuki-pp", git = "https://github.com/CursorDance/akatsuki-pp-rs", rev = "56a71011e13274e63f6548611f3d5c822377c0d3", features = [
"async_tokio",
] }
no-accuracy = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "d3ab5af7a63f17a2a40bbce573b06ea451375638", features = [
"async_tokio",
] }

[profile.release]
lto = "fat"
Expand Down
25 changes: 25 additions & 0 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use skill_rebalance::{
GameMode as SkillRebalanceGameMode,
};
use woot_precision::Beatmap as WootBeatmap;
use no_accuracy::Beatmap as NoAccuracyBeatmap;

fn round(x: f32, decimals: u32) -> f32 {
let y = 10i32.pow(decimals) as f32;
Expand Down Expand Up @@ -143,6 +144,29 @@ async fn calculate_cursordance_pp(
Ok(pp)
}

async fn calculate_no_accuracy_pp(
score: &RippleScore,
context: Arc<Context>,
) -> anyhow::Result<f32> {
let beatmap_bytes =
usecases::beatmaps::fetch_beatmap_osu_file(score.beatmap_id, context).await?;
let beatmap = NoAccuracyBeatmap::from_bytes(&beatmap_bytes).await?;

let result = no_accuracy::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<RippleScore>,
Expand All @@ -157,6 +181,7 @@ async fn process_scores(
13 => calculate_skill_rebalance_pp(score, context.clone()).await?,
15 => calculate_woot_precision_pp(score, context.clone()).await?,
16 => calculate_cursordance_pp(score, context.clone()).await?,
17 => calculate_no_accuracy_pp(score, context.clone()).await?,
_ => unreachable!(),
};

Expand Down

0 comments on commit ecb4821

Please sign in to comment.