range refactor, clippy

This commit is contained in:
Vinzenz Schroeter 2025-07-08 20:01:39 +02:00
commit 0bf317dd6d
6 changed files with 35 additions and 57 deletions

View file

@ -67,14 +67,10 @@ impl UnlockSystem {
}
}
pub fn previous(&self) -> Option<&String> {
self.last_unlock.as_ref()
}
pub fn draw(&self, chars: WindowMut<char, CharGrid>, bitmap: WindowMut<bool, Bitmap>) {
let title = format!(" Stage {}/{} ", self.bought, self.total_unlock_count);
let (mut chars, mut bitmap) = draw_border_panel(chars, bitmap, &title, INNER_BORDER);
let (chars, bitmap) = draw_border_panel(chars, bitmap, &title, INNER_BORDER);
let (all_unlocks_pixels, bitmap) = bitmap.split_vertical_mut(TILE_SIZE).unwrap();
self.all_unlocks_bar.draw(all_unlocks_pixels);
@ -103,7 +99,7 @@ impl UnlockSystem {
self.all_unlocks_bar.progress = self.bought as f64 / self.total_unlock_count as f64;
}
fn gen_bar_enable_unlocks(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
fn gen_bar_enable_unlocks(bars: &[Row]) -> impl Iterator<Item = Unlock> {
bars.iter().enumerate().map(|(index, bar)| Unlock {
name: format!("Start {}", bar.name()),
cost: 10f64.powi(index as i32),
@ -135,7 +131,7 @@ impl UnlockSystem {
})
}
fn gen_bar_productivity_unlocks(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
fn gen_bar_productivity_unlocks(bars: &[Row]) -> impl Iterator<Item = Unlock> {
bars.iter().enumerate().flat_map(|(index, bar)| {
(1..=20).map(move |level| Unlock {
name: format!("{} productivity {level}", bar.name()),
@ -147,7 +143,7 @@ impl UnlockSystem {
})
}
fn gen_bar_speed_unlocks(bars: &Vec<Row>) -> impl Iterator<Item = Unlock> {
fn gen_bar_speed_unlocks(bars: &[Row]) -> impl Iterator<Item = Unlock> {
bars.iter().enumerate().flat_map(|(index, bar)| {
(1..=15).map(move |level| Unlock {
name: format!("{} speed {level}", bar.name()),