less clutter in achievement display

This commit is contained in:
yuni 2024-05-14 05:41:26 +02:00
parent fce2cfdce1
commit 22d7a8cc4c

View file

@ -325,24 +325,22 @@ impl AchievementTracker {
] ]
} }
pub fn to_textsections(&self) -> Vec<String> { pub fn to_textsections(&self) -> Vec<String> {
fn bool2string(boolean: bool) -> String { fn collectible(current: usize, total: usize) -> String {
if boolean { "achieved" } else { "not achieved" }.to_string() if current < total {
format!(" ({}/{})", current, total)
} else {
"".to_string()
}
} }
let ride = collectible(self.vehicles_ridden.len(), self.all_vehicles.len());
let talk = collectible(self.people_talked_to.len(), self.all_people.len());
vec![ vec![
format!("Repair Your Suit ({})\n", "Repair Your Suit\n".to_string(),
bool2string(self.repair_suit)), "Consume A Pizza\n".to_string(),
format!("Consume A Pizza ({})\n", format!("Ride Every Vehicle{ride}\n"),
bool2string(self.drink_a_pizza)), format!("Talk To Everyone{talk}\n"),
format!("Ride Every Vehicle ({}/{})\n", "Find Earth\n".to_string(),
self.vehicles_ridden.len(), "Let Jupiter Eclipse The Sun\n".to_string(),
self.all_vehicles.len()),
format!("Talk To Everyone ({}/{})\n",
self.people_talked_to.len(),
self.all_people.len()),
format!("Find Earth ({})\n",
bool2string(self.find_earth)),
format!("Let Jupiter Eclipse The Sun ({})\n",
bool2string(self.in_jupiters_shadow)),
] ]
} }
} }