mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
Allow more flexible inputs in embeds
This commit is contained in:
parent
a158e8fbe1
commit
0e72f12b6d
1 changed files with 16 additions and 13 deletions
|
@ -343,19 +343,20 @@ impl<'a> ScoreEmbedBuilder<'a> {
|
||||||
} else {
|
} else {
|
||||||
pp.map(|v| v.1)
|
pp.map(|v| v.1)
|
||||||
};
|
};
|
||||||
let pp_gained = s.pp.map(|full_pp| {
|
let pp_gained = {
|
||||||
self.top_record
|
let effective_pp = s.effective_pp.or_else(|| {
|
||||||
.map(|top| {
|
s.pp.zip(self.top_record)
|
||||||
let after_pp = u.pp.unwrap();
|
.map(|(pp, top)| pp * (0.95f64).powi(top as i32 - 1))
|
||||||
let effective_pp = full_pp * (0.95f64).powi(top as i32 - 1);
|
});
|
||||||
let before_pp = after_pp - effective_pp;
|
match (s.pp, effective_pp) {
|
||||||
format!(
|
(Some(pp), Some(epp)) => Some(format!(
|
||||||
"**pp gained**: **{:.2}**pp (+**{:.2}**pp | {:.2}pp \\➡️ {:.2}pp)",
|
"**pp gained**: **{:.2}**pp (**+{:.2}**pp)",
|
||||||
full_pp, effective_pp, before_pp, after_pp
|
pp, epp
|
||||||
)
|
)),
|
||||||
})
|
(Some(pp), None) => Some(format!("**pp gained**: **{:.2}**pp", pp)),
|
||||||
.unwrap_or_else(|| format!("**pp gained**: **{:.2}**pp", full_pp))
|
_ => None,
|
||||||
});
|
}
|
||||||
|
};
|
||||||
let score_line = pp
|
let score_line = pp
|
||||||
.map(|pp| format!("{} | {}", &score_line, pp))
|
.map(|pp| format!("{} | {}", &score_line, pp))
|
||||||
.unwrap_or(score_line);
|
.unwrap_or(score_line);
|
||||||
|
@ -370,6 +371,8 @@ impl<'a> ScoreEmbedBuilder<'a> {
|
||||||
.unwrap_or_else(|| "".to_owned());
|
.unwrap_or_else(|| "".to_owned());
|
||||||
let world_record = self
|
let world_record = self
|
||||||
.world_record
|
.world_record
|
||||||
|
.map(|v| v as u32)
|
||||||
|
.or(s.global_rank)
|
||||||
.map(|v| format!(" | #{} on Global Rankings!", v))
|
.map(|v| format!(" | #{} on Global Rankings!", v))
|
||||||
.unwrap_or_else(|| "".to_owned());
|
.unwrap_or_else(|| "".to_owned());
|
||||||
let diff = b.difficulty.apply_mods(s.mods, stars);
|
let diff = b.difficulty.apply_mods(s.mods, stars);
|
||||||
|
|
Loading…
Add table
Reference in a new issue