add percentage in cards game
This commit is contained in:
parent
c67ae2834d
commit
021a6c67ea
|
@ -297,20 +297,20 @@ async fn new_card_setup<W: IsA<gtk::Window>>(window: Rc<W>) {
|
||||||
let conn = Connection::open(get_db_path()).unwrap();
|
let conn = Connection::open(get_db_path()).unwrap();
|
||||||
|
|
||||||
conn.execute("INSERT OR REPLACE INTO cards ( id,
|
conn.execute("INSERT OR REPLACE INTO cards ( id,
|
||||||
imagename,
|
imagename,
|
||||||
hieroglyph,
|
hieroglyph,
|
||||||
reading,
|
reading,
|
||||||
translation,
|
translation,
|
||||||
is_learning
|
is_learning
|
||||||
) VALUES (
|
) VALUES (
|
||||||
(SELECT id FROM cards WHERE hieroglyph = ?2),
|
(SELECT id FROM cards WHERE hieroglyph = ?2),
|
||||||
?1,
|
?1,
|
||||||
?2,
|
?2,
|
||||||
?3,
|
?3,
|
||||||
?4,
|
?4,
|
||||||
(SELECT is_learning FROM cards WHERE hieroglyph = ?2 OR TRUE
|
(SELECT is_learning FROM cards WHERE hieroglyph = ?2 OR TRUE
|
||||||
)
|
)
|
||||||
)", (&new_filename, &hieroglyph, &reading, &translation)).unwrap();
|
)", (&new_filename, &hieroglyph, &reading, &translation)).unwrap();
|
||||||
w.close();
|
w.close();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -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)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue