mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 08:48:54 +00:00
Improve formatting slightly
This commit is contained in:
parent
fdae8be75b
commit
51a2054385
3 changed files with 30 additions and 18 deletions
|
@ -122,6 +122,8 @@ mod scores {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod table {
|
pub mod table {
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::discord::oppai_cache::Accuracy;
|
use crate::discord::oppai_cache::Accuracy;
|
||||||
use crate::discord::{Beatmap, BeatmapCache, BeatmapInfo, BeatmapMetaCache};
|
use crate::discord::{Beatmap, BeatmapCache, BeatmapInfo, BeatmapMetaCache};
|
||||||
use crate::models::{Mode, Score};
|
use crate::models::{Mode, Score};
|
||||||
|
@ -194,7 +196,7 @@ mod scores {
|
||||||
let pp = plays
|
let pp = plays
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| async move {
|
.map(|p| async move {
|
||||||
match p.pp.map(|pp| format!("{:.2}pp", pp)) {
|
match p.pp.map(|pp| format!("{:.2}", pp)) {
|
||||||
Some(v) => Ok(v),
|
Some(v) => Ok(v),
|
||||||
None => {
|
None => {
|
||||||
let b = beatmap_cache.get_beatmap(p.beatmap_id).await?;
|
let b = beatmap_cache.get_beatmap(p.beatmap_id).await?;
|
||||||
|
@ -211,7 +213,7 @@ mod scores {
|
||||||
p.mods,
|
p.mods,
|
||||||
)
|
)
|
||||||
.ok()
|
.ok()
|
||||||
.map(|pp| format!("{:.2}pp [?]", pp))
|
.map(|pp| format!("{:.2}[?]", pp))
|
||||||
}
|
}
|
||||||
.unwrap_or_else(|| "-".to_owned()));
|
.unwrap_or_else(|| "-".to_owned()));
|
||||||
r
|
r
|
||||||
|
@ -226,18 +228,27 @@ mod scores {
|
||||||
let ranks = plays
|
let ranks = plays
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, p)| match p.rank {
|
.map(|(i, p)| -> Cow<'static, str> {
|
||||||
crate::models::Rank::F => beatmaps[i]
|
match p.rank {
|
||||||
.as_ref()
|
crate::models::Rank::F => beatmaps[i]
|
||||||
.and_then(|(_, i)| i.map(|i| i.objects))
|
.as_ref()
|
||||||
.map(|total| {
|
.and_then(|(_, i)| i.map(|i| i.objects))
|
||||||
(p.count_300 + p.count_100 + p.count_50 + p.count_miss) as f64
|
.map(|total| {
|
||||||
/ (total as f64)
|
(p.count_300 + p.count_100 + p.count_50 + p.count_miss) as f64
|
||||||
* 100.0
|
/ (total as f64)
|
||||||
})
|
* 100.0
|
||||||
.map(|p| format!("F [{:.0}%]", p))
|
})
|
||||||
.unwrap_or_else(|| "F".to_owned()),
|
.map(|p| format!("{:.0}% F", p).into())
|
||||||
v => v.to_string(),
|
.unwrap_or_else(|| "F".into()),
|
||||||
|
crate::models::Rank::SS => "SS".into(),
|
||||||
|
crate::models::Rank::S => if p.perfect {
|
||||||
|
format!("{}x FC S", p.max_combo)
|
||||||
|
} else {
|
||||||
|
format!("{}x S", p.max_combo)
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
_v => format!("{}x {}m {}", p.max_combo, p.count_miss, p.rank).into(),
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
@ -300,7 +311,7 @@ mod scores {
|
||||||
// Each row
|
// Each row
|
||||||
for (id, (play, beatmap)) in plays.iter().zip(beatmaps.iter()).enumerate() {
|
for (id, (play, beatmap)) in plays.iter().zip(beatmaps.iter()).enumerate() {
|
||||||
m.push_line(format!(
|
m.push_line(format!(
|
||||||
"{:>3} | {:>pw$} | {:>8} | {:^rw$} | {:mw$} | {:bw$}",
|
"{:>3} | {:>pw$} | {:>8} | {:>rw$} | {:mw$} | {:bw$}",
|
||||||
id + start + 1,
|
id + start + 1,
|
||||||
pp[id],
|
pp[id],
|
||||||
format!("{:.2}%", play.accuracy(self.mode)),
|
format!("{:.2}%", play.accuracy(self.mode)),
|
||||||
|
|
|
@ -354,11 +354,11 @@ impl<'a> ScoreEmbedBuilder<'a> {
|
||||||
.unwrap_or_else(|| format!("**{}x**", s.max_combo));
|
.unwrap_or_else(|| format!("**{}x**", s.max_combo));
|
||||||
let top_record = self
|
let top_record = self
|
||||||
.top_record
|
.top_record
|
||||||
.map(|v| format!("| #{} top record!", v))
|
.map(|v| format!(" | #{} top record!", v))
|
||||||
.unwrap_or_else(|| "".to_owned());
|
.unwrap_or_else(|| "".to_owned());
|
||||||
let world_record = self
|
let world_record = self
|
||||||
.world_record
|
.world_record
|
||||||
.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);
|
||||||
let creator = if b.difficulty_name.contains("'s") {
|
let creator = if b.difficulty_name.contains("'s") {
|
||||||
|
|
|
@ -13,6 +13,7 @@ use crate::{
|
||||||
models::{Mode, Mods, Score},
|
models::{Mode, Mods, Score},
|
||||||
request::UserID,
|
request::UserID,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serenity::{
|
use serenity::{
|
||||||
framework::standard::{macros::command, Args, CommandResult},
|
framework::standard::{macros::command, Args, CommandResult},
|
||||||
model::{channel::Message, id::UserId},
|
model::{channel::Message, id::UserId},
|
||||||
|
@ -150,7 +151,7 @@ pub async fn server_rank(ctx: &Context, m: &Message, mut args: Args) -> CommandR
|
||||||
"Page **{}**/**{}**. Last updated: `{}`",
|
"Page **{}**/**{}**. Last updated: `{}`",
|
||||||
page + 1,
|
page + 1,
|
||||||
(total_len + ITEMS_PER_PAGE - 1) / ITEMS_PER_PAGE,
|
(total_len + ITEMS_PER_PAGE - 1) / ITEMS_PER_PAGE,
|
||||||
last_update.to_rfc2822()
|
last_update.format("<t:%s:R>"),
|
||||||
));
|
));
|
||||||
m.edit(ctx, |f| f.content(content.to_string())).await?;
|
m.edit(ctx, |f| f.content(content.to_string())).await?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|
Loading…
Add table
Reference in a new issue