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> {
fn bool2string(boolean: bool) -> String {
if boolean { "achieved" } else { "not achieved" }.to_string()
fn collectible(current: usize, total: usize) -> 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![
format!("Repair Your Suit ({})\n",
bool2string(self.repair_suit)),
format!("Consume A Pizza ({})\n",
bool2string(self.drink_a_pizza)),
format!("Ride Every Vehicle ({}/{})\n",
self.vehicles_ridden.len(),
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)),
"Repair Your Suit\n".to_string(),
"Consume A Pizza\n".to_string(),
format!("Ride Every Vehicle{ride}\n"),
format!("Talk To Everyone{talk}\n"),
"Find Earth\n".to_string(),
"Let Jupiter Eclipse The Sun\n".to_string(),
]
}
}