diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 16:17:19 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 16:17:19 +0100 |
| commit | f07221b4e1d8aa464a44fe566884ccc0565406e9 (patch) | |
| tree | 48020a68cee1c95521d594dc6803c1f7ec01c801 /src/client/ui.rs | |
| parent | add nginx + php-fpm deployment example (diff) | |
| download | zagan-bet-f07221b4e1d8aa464a44fe566884ccc0565406e9.tar.gz zagan-bet-f07221b4e1d8aa464a44fe566884ccc0565406e9.zip | |
v3.2.0: straight and split bets anywhere on the felt; add history command
Diffstat (limited to 'src/client/ui.rs')
| -rw-r--r-- | src/client/ui.rs | 29 |
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. | ||
| 276 | pub 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 |
