From e1fca20a5b834a50423a47ffd17ab5aa7a46f7cb Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sun, 9 Aug 2020 23:00:39 -0400 Subject: [PATCH] Add gained pp --- youmubot-osu/src/discord/embeds.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/youmubot-osu/src/discord/embeds.rs b/youmubot-osu/src/discord/embeds.rs index 8ea1bba..d4f3024 100644 --- a/youmubot-osu/src/discord/embeds.rs +++ b/youmubot-osu/src/discord/embeds.rs @@ -219,6 +219,19 @@ pub(crate) fn score_embed<'a>( } else { pp.map(|v| v.1) }; + let pp_gained = s.pp.map(|full_pp| { + top_record + .map(|top| { + let after_pp = u.pp.unwrap(); + let effective_pp = full_pp * (0.95f64).powi(top as i32); + let before_pp = after_pp - effective_pp; + format!( + "**pp gained**: **{:.2}**pp (+**{:.2}**pp | {:.2}pp \\➡️ {:.2}pp)", + full_pp, effective_pp, before_pp, after_pp + ) + }) + .unwrap_or_else(|| format!("**pp gained**: **{:.2}**pp", full_pp)) + }); let score_line = pp .map(|pp| format!("{} | {}", &score_line, pp)) .unwrap_or(score_line); @@ -248,7 +261,8 @@ pub(crate) fn score_embed<'a>( .description(format!( r#"**Beatmap**: {} - {} [{}]**{} ** **Links**: [[Listing]]({}) [[Download]]({}) [[Bloodcat]]({}) -**Played on**: {}"#, +**Played on**: {} +{}"#, b.artist, b.title, b.difficulty_name, @@ -257,6 +271,7 @@ pub(crate) fn score_embed<'a>( b.download_link(false), b.download_link(true), s.date.format("%F %T"), + pp_gained.as_ref().map(|v| &v[..]).unwrap_or(""), )) .image(b.cover_url()) .field( @@ -304,7 +319,11 @@ pub(crate) fn user_embed<'a>( .field("World Rank", format!("#{}", grouped_number(u.rank)), true) .field( "Country Rank", - format!(":flag_{}: #{}", u.country.to_lowercase(), grouped_number(u.country_rank)), + format!( + ":flag_{}: #{}", + u.country.to_lowercase(), + grouped_number(u.country_rank) + ), true, ) .field("Accuracy", format!("{:.2}%", u.accuracy), true)