add percentage in cards game

This commit is contained in:
leca 2024-05-18 02:01:48 +03:00
parent c67ae2834d
commit 021a6c67ea
2 changed files with 17 additions and 16 deletions

View File

@ -22,9 +22,10 @@ impl MemoryCardsGameScene {
pub fn update_stats(&self) { pub fn update_stats(&self) {
self.imp().stats_label.set_text(&format!( self.imp().stats_label.set_text(&format!(
"Correct|Incorrect: {}|{}", "Correct|Incorrect: {}|{} ({:.2}%)",
self.imp().correct.borrow(), self.imp().correct.borrow(),
self.imp().incorrect.borrow() self.imp().incorrect.borrow(),
100.0 * f64::from(*self.imp().correct.borrow() as i32) / f64::from((*self.imp().incorrect.borrow() + *self.imp().correct.borrow()) as i32)
)); ));
} }