Display scores smartly based on classic/lazer

This commit is contained in:
Natsu Kagami 2024-02-14 01:02:31 +01:00 committed by Natsu Kagami
parent 23795d281e
commit 46684a2a9e
4 changed files with 10 additions and 5 deletions

View file

@ -400,7 +400,7 @@ impl<'a> ScoreEmbedBuilder<'a> {
"Score stats",
format!(
"**{}** | {} | **{:.2}%**",
grouped_number(s.score),
grouped_number(s.score.unwrap_or(s.normalized_score as u64)),
max_combo,
accuracy
),

View file

@ -386,7 +386,9 @@ async fn show_leaderboard(
OrderBy::PP => scores.sort_by(|(a, _, _), (b, _, _)| {
b.partial_cmp(a).unwrap_or(std::cmp::Ordering::Equal)
}),
OrderBy::Score => scores.sort_by(|(_, _, a), (_, _, b)| b.score.cmp(&a.score)),
OrderBy::Score => {
scores.sort_by(|(_, _, a), (_, _, b)| b.normalized_score.cmp(&a.normalized_score))
}
};
scores
};
@ -411,6 +413,7 @@ async fn show_leaderboard(
.await?;
return Ok(());
}
let has_lazer_score = scores.iter().any(|(_, _, v)| v.score.is_none());
paginate_reply_fn(
move |page: u8, ctx: &Context, m: &mut Message| {
@ -454,7 +457,7 @@ async fn show_leaderboard(
.iter()
.map(|(pp, _, s)| match order {
OrderBy::PP => format!("{:.2}", pp),
OrderBy::Score => crate::discord::embeds::grouped_number(s.score),
OrderBy::Score => crate::discord::embeds::grouped_number(if has_lazer_score { s.normalized_score as u64 } else { s.score.unwrap() }),
})
.collect::<Vec<_>>();
let pw = pp.iter().map(|v| v.len()).max().unwrap_or(pp_label.len());

View file

@ -542,7 +542,8 @@ pub struct Score {
pub replay_available: bool,
pub beatmap_id: u64,
pub score: u64,
pub score: Option<u64>,
pub normalized_score: u32,
pub pp: Option<f64>,
pub rank: Rank,
pub mods: Mods, // Later

View file

@ -144,7 +144,8 @@ impl From<rosu::score::Score> for Score {
date: time_to_utc(s.ended_at),
replay_available: s.replay,
beatmap_id: s.map_id as u64,
score: s.score as u64,
score: Some(s.legacy_score as u64).filter(|v| *v > 0),
normalized_score: s.score,
pp: s.pp.map(|v| v as f64),
rank: s.grade.into(),
mods: s