Skip to content

Commit

Permalink
fix: commander's orders were skipped if they were also on the list of…
Browse files Browse the repository at this point in the history
… maps to conquer
  • Loading branch information
motzel committed Jun 15, 2024
1 parent dec1644 commit c99c59e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bl-bot"
version = "0.18.9"
version = "0.18.10"
description = "Beat Leader Discord Bot"
readme = "README.md"
repository = "https://github.com/motzel/bl-bot"
Expand Down
23 changes: 12 additions & 11 deletions src/discord/bot/beatleader/clan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,6 @@ impl Playlist {
})
.collect::<Vec<_>>();

let playlist_maps_leaderboard_ids = playlist_maps
.iter()
.map(|m| m.leaderboard.id.to_lowercase())
.collect::<Vec<_>>();

let playlist_title = match playlist_name {
Some(playlist_name) => playlist_name,
None => format!(
Expand Down Expand Up @@ -735,6 +730,7 @@ impl Playlist {

let id = Playlist::generate_id();

let mut commander_orders_leaderboard_id = vec![];
let commander_orders: Vec<PlaylistItem> = if playlist_type == ClanWarsSort::ToConquer
&& (skip_commander_orders.is_none() || !skip_commander_orders.unwrap())
{
Expand All @@ -749,17 +745,17 @@ impl Playlist {
let score_fc = player_leaderboard_ids.get(&leaderboard_id).map(|v| v.1);
let map_stars = map.stars;

let filters_match = !playlist_maps_leaderboard_ids.contains(&leaderboard_id)
&& (score_timepost.is_none()
|| (played_filter.is_some()
&& played_filter.unwrap() > score_timepost.unwrap()))
let filters_match = (score_timepost.is_none()
|| (played_filter.is_some()
&& played_filter.unwrap() > score_timepost.unwrap()))
&& (max_stars_value == 0.0 || map_stars <= max_stars_value)
&& (score_fc.is_none()
|| fc_status.is_none()
|| (fc_status == Some(false) && score_fc == Some(false))
|| (fc_status == Some(true) && score_fc == Some(true)));

if filters_match {
commander_orders_leaderboard_id.push(leaderboard_id);
Some(map.into())
} else {
None
Expand All @@ -769,8 +765,13 @@ impl Playlist {
} else {
vec![]
};
let songs =
Playlist::songs_from_scores(playlist_maps.into_iter().take(count as usize).collect());
let songs = Playlist::songs_from_scores(
playlist_maps
.into_iter()
.filter(|score| !commander_orders_leaderboard_id.contains(&score.leaderboard.id))
.take(count as usize)
.collect(),
);

Ok(Playlist {
id: id.clone(),
Expand Down

0 comments on commit c99c59e

Please sign in to comment.