diff --git a/youmubot-osu/src/discord/embeds.rs b/youmubot-osu/src/discord/embeds.rs index ed1bba0..b8ff7a2 100644 --- a/youmubot-osu/src/discord/embeds.rs +++ b/youmubot-osu/src/discord/embeds.rs @@ -1,6 +1,6 @@ use super::BeatmapWithMode; use crate::{ - discord::oppai_cache::{BeatmapContent, BeatmapInfo}, + discord::oppai_cache::{BeatmapContent, BeatmapInfo, OppaiAccuracy}, models::{Beatmap, Mode, Mods, Rank, Score, User}, }; use chrono::Utc; @@ -224,7 +224,7 @@ impl<'a> ScoreEmbedBuilder<'a> { content .get_pp_from( oppai_rs::Combo::non_fc(s.max_combo as u32, s.count_miss as u32), - accuracy as f32, + OppaiAccuracy::from_hits(s.count_100 as u32, s.count_50 as u32), Some(op), s.mods, ) @@ -236,7 +236,12 @@ impl<'a> ScoreEmbedBuilder<'a> { mode.to_oppai_mode() .and_then(|op| { content - .get_pp_from(oppai_rs::Combo::FC(0), accuracy as f32, Some(op), s.mods) + .get_pp_from( + oppai_rs::Combo::FC(0), + OppaiAccuracy::from_hits(s.count_100 as u32, s.count_50 as u32), + Some(op), + s.mods, + ) .ok() }) .filter(|&v| { diff --git a/youmubot-osu/src/discord/mod.rs b/youmubot-osu/src/discord/mod.rs index 465359c..7e30f83 100644 --- a/youmubot-osu/src/discord/mod.rs +++ b/youmubot-osu/src/discord/mod.rs @@ -1,6 +1,6 @@ use crate::{ discord::beatmap_cache::BeatmapMetaCache, - discord::oppai_cache::BeatmapCache, + discord::oppai_cache::{BeatmapCache, OppaiAccuracy}, models::{Beatmap, Mode, Mods, Score, User}, request::UserID, Client as OsuHttpClient, @@ -384,7 +384,10 @@ async fn list_plays<'a>( max_combo: p.max_combo as u32, misses: p.count_miss as u32, }, - p.accuracy(mode) as f32, + OppaiAccuracy::from_hits( + p.count_100 as u32, + p.count_50 as u32, + ), Some(op), p.mods, ) diff --git a/youmubot-osu/src/discord/oppai_cache.rs b/youmubot-osu/src/discord/oppai_cache.rs index a446330..94ba773 100644 --- a/youmubot-osu/src/discord/oppai_cache.rs +++ b/youmubot-osu/src/discord/oppai_cache.rs @@ -1,6 +1,8 @@ use std::{ffi::CString, sync::Arc}; use youmubot_prelude::*; +pub use oppai_rs::Accuracy as OppaiAccuracy; + /// the information collected from a download/Oppai request. #[derive(Debug)] pub struct BeatmapContent { @@ -20,7 +22,7 @@ impl BeatmapContent { pub fn get_pp_from( &self, combo: oppai_rs::Combo, - accuracy: f32, + accuracy: impl Into, mode: Option, mods: impl Into, ) -> Result { diff --git a/youmubot-osu/src/discord/server_rank.rs b/youmubot-osu/src/discord/server_rank.rs index 2d7f9f5..76d4007 100644 --- a/youmubot-osu/src/discord/server_rank.rs +++ b/youmubot-osu/src/discord/server_rank.rs @@ -4,7 +4,10 @@ use super::{ ModeArg, OsuClient, }; use crate::{ - discord::{oppai_cache::BeatmapCache, BeatmapWithMode}, + discord::{ + oppai_cache::{BeatmapCache, OppaiAccuracy}, + BeatmapWithMode, + }, models::{Mode, Mods, Score}, request::UserID, }; @@ -275,12 +278,12 @@ async fn show_leaderboard( let mode = bm.1; let oppai = data.get::().unwrap(); let oppai_map = oppai.get_beatmap(bm.0.beatmap_id).await?; - let get_oppai_pp = move |combo: u64, misses: u64, acc: f64, mods: Mods| { + let get_oppai_pp = move |combo: u64, misses: u64, acc: OppaiAccuracy, mods: Mods| { mode.to_oppai_mode().and_then(|mode| { oppai_map .get_pp_from( oppai_rs::Combo::non_fc(combo as u32, misses as u32), - acc as f32, + acc, Some(mode), mods, ) @@ -354,7 +357,10 @@ async fn show_leaderboard( get_oppai_pp( score.max_combo, score.count_miss, - score.accuracy(mode), + OppaiAccuracy::from_hits( + score.count_100 as u32, + score.count_50 as u32, + ), score.mods, ) })