Import newly released charts
This commit is contained in:
parent
2ac13510f2
commit
238d81f3bd
10 changed files with 28 additions and 13 deletions
|
@ -240,7 +240,7 @@ pub struct Chart {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct CachedSong {
|
||||
pub song: Song,
|
||||
chart_ids: [Option<NonZeroU16>; 5],
|
||||
chart_ids: [Option<NonZeroU16>; Difficulty::DIFFICULTIES.len()],
|
||||
}
|
||||
|
||||
impl CachedSong {
|
||||
|
@ -253,8 +253,11 @@ impl CachedSong {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn charts(&self) -> impl Iterator<Item = u32> {
|
||||
self.chart_ids.into_iter().flatten().map(|i| i.get() as u32)
|
||||
pub fn charts(&self) -> impl Iterator<Item = (Difficulty, u32)> {
|
||||
self.chart_ids
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, id)| id.map(|id| (Difficulty::DIFFICULTIES[i], id.get() as u32)))
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
|
|
@ -158,7 +158,7 @@ impl JacketCache {
|
|||
bitmap,
|
||||
});
|
||||
} else {
|
||||
for chart_id in song_cache.lookup_song(song_id)?.charts() {
|
||||
for (_, chart_id) in song_cache.lookup_song(song_id)?.charts() {
|
||||
let chart = song_cache.lookup_chart_mut(chart_id)?;
|
||||
if chart.jacket_source.is_none() {
|
||||
chart.cached_jacket = Some(Jacket {
|
||||
|
|
|
@ -13,7 +13,7 @@ use super::discord::MessageContext;
|
|||
// }}}
|
||||
|
||||
// {{{ Top command
|
||||
/// Compute different things
|
||||
/// Compute various things
|
||||
#[poise::command(
|
||||
prefix_command,
|
||||
slash_command,
|
||||
|
|
|
@ -24,7 +24,7 @@ use super::discord::{CreateReplyExtra, MessageContext};
|
|||
// }}}
|
||||
|
||||
// {{{ Top command
|
||||
/// Chart-related stats
|
||||
/// Chart-related utilities.
|
||||
#[poise::command(
|
||||
prefix_command,
|
||||
slash_command,
|
||||
|
|
|
@ -323,7 +323,7 @@ mod show_tests {
|
|||
}
|
||||
// }}}
|
||||
// {{{ Discord wrapper
|
||||
/// Show scores given their ides
|
||||
/// Show scores given their IDs.
|
||||
#[poise::command(prefix_command, slash_command)]
|
||||
pub async fn show(
|
||||
mut ctx: Context<'_>,
|
||||
|
|
|
@ -26,7 +26,7 @@ use super::discord::MessageContext;
|
|||
// }}}
|
||||
|
||||
// {{{ Stats
|
||||
/// Stats display
|
||||
/// Query various stats.
|
||||
#[poise::command(
|
||||
prefix_command,
|
||||
slash_command,
|
||||
|
|
|
@ -80,8 +80,16 @@ pub fn guess_chart_name<'a>(
|
|||
let plausible_difficulty = match difficulty {
|
||||
Some(difficulty) => difficulty == chart.difficulty,
|
||||
None => {
|
||||
let chart_count = cached_song.charts().count();
|
||||
chart_count == 1 || chart.difficulty == Difficulty::FTR
|
||||
let has_ftr = cached_song.charts().any(|(d, _)| d == Difficulty::FTR);
|
||||
let main_diff = if has_ftr {
|
||||
Difficulty::FTR
|
||||
} else {
|
||||
let (max_diff, _) =
|
||||
cached_song.charts().max_by_key(|(d, _)| *d).unwrap();
|
||||
max_diff
|
||||
};
|
||||
|
||||
chart.difficulty == main_diff
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue