Skip to content

Commit

Permalink
add improved-miss-penalty-and-acc-rework to processor
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku committed Nov 24, 2024
1 parent fdedd22 commit a53de94
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ fix-inconsistent-powers = { package = "akatsuki-pp", git = "https://github.com/o
"async_tokio",
] }
aim-accuracy-fix = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "2bb69c851b3ac08e5efbc4c95a4664581618c2af" }
improved-miss-penalty-and-acc-rework = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "2cdb0cc102c142fa8a6625b63fa23bb5ea5d8a47" }
md5 = "0.7.0"
26 changes: 26 additions & 0 deletions src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,31 @@ async fn calculate_aim_accuracy_fix_pp(
Ok(pp)
}

async fn calculate_improved_miss_penalty_and_acc_rework_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 = improved_miss_penalty_and_acc_rework::Beatmap::from_bytes(&beatmap_bytes)?;

let result = improved_miss_penalty_and_acc_rework::osu_2019::OsuPP::from_map(&beatmap)
.mods(score.mods as u32)
.combo(score.max_combo as u32)
.n300(score.count_300 as u32)
.n100(score.count_100 as u32)
.n50(score.count_50 as u32)
.misses(score.count_misses as u32)
.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 @@ -223,6 +248,7 @@ async fn process_scores(
24 => calculate_remove_manual_adjustments_pp(score, context.clone()).await?,
25 => calculate_fix_inconsistent_powers_pp(score, context.clone()).await?,
26 => calculate_aim_accuracy_fix_pp(score, context.clone()).await?,
27 => calculate_improved_miss_penalty_and_acc_rework_pp(score, context.clone()).await?,
_ => unreachable!(),
};

Expand Down

0 comments on commit a53de94

Please sign in to comment.