Skip to content

Commit

Permalink
add simplify relax rework
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku committed Apr 27, 2024
1 parent 608c1ef commit b603dcf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ cursordance = { package = "akatsuki-pp", git = "https://github.com/CursorDance/a
no-accuracy = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "d3ab5af7a63f17a2a40bbce573b06ea451375638", features = [
"async_tokio",
] }
simplify-relax = { package = "akatsuki-pp", git = "https://github.com/osuAkatsuki/akatsuki-pp-rs", rev = "ce896ca661de4aa4c0c6739a703c4a162426878b", 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 @@ -25,6 +25,7 @@ use conceptual_rework::{
};
use cursordance::Beatmap as CdBeatmap;
use no_accuracy::Beatmap as NoAccuracyBeatmap;
use simplify_relax::Beatmap as SimplifyRelaxBeatmap;
use skill_rebalance::{
Beatmap as SkillRebalanceBeatmap, BeatmapExt as SkillRebalanceBeatmapExt,
GameMode as SkillRebalanceGameMode,
Expand Down Expand Up @@ -167,6 +168,29 @@ async fn calculate_no_accuracy_pp(
Ok(pp)
}

async fn calculate_simplfy_relax_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 = SimplifyRelaxBeatmap::from_bytes(&beatmap_bytes).await?;

let result = simplify_relax::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 @@ -182,6 +206,7 @@ async fn process_scores(
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?,
18 => calculate_simplfy_relax_pp(score, context.clone()).await?,
_ => unreachable!(),
};

Expand Down

0 comments on commit b603dcf

Please sign in to comment.