summaryrefslogtreecommitdiffstats
path: root/src/client/ui.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/client/ui.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/client/ui.rs b/src/client/ui.rs
index e7f510b..bb5b55f 100644
--- a/src/client/ui.rs
+++ b/src/client/ui.rs
@@ -81,6 +81,11 @@ const COMMANDS: &[CommandHelp] = &[
81 description: "list remembered hosts", 81 description: "list remembered hosts",
82 }, 82 },
83 CommandHelp { 83 CommandHelp {
84 name: "history",
85 usage: "history [count]",
86 description: "show your recent wins and losses",
87 },
88 CommandHelp {
84 name: "quit", 89 name: "quit",
85 usage: "quit", 90 usage: "quit",
86 description: "quit the program", 91 description: "quit the program",
@@ -267,6 +272,30 @@ pub fn terminal_size_warning(columns: u16, rows: u16) -> Option<String> {
267 )) 272 ))
268} 273}
269 274
275/// One line per settled play, newest first.
276pub fn history_lines(records: &[crate::history::PlayRecord]) -> Vec<String> {
277 if records.is_empty() {
278 return vec!["No plays recorded yet.".to_string()];
279 }
280
281 let mut lines = vec![
282 format!("Recent plays ({}):", records.len()),
283 " when game bet won balance result".to_string(),
284 ];
285 for record in records {
286 lines.push(format!(
287 " {:<16} {:<8} {:>6} {:>6} {:>7} {}",
288 record.short_time(),
289 record.game,
290 record.bet,
291 record.winnings,
292 record.balance_after,
293 record.summary()
294 ));
295 }
296 lines
297}
298
270/// Render remembered hosts. 299/// Render remembered hosts.
271/// 300///
272/// Two addresses that present the same certificate key are the same server, so 301/// Two addresses that present the same certificate key are the same server, so